xref: /trunk/main/svtools/source/contnr/svtreebx.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SVTREEBX_CXX
28cdf0e10cSrcweir #include <vcl/svapp.hxx>
29cdf0e10cSrcweir #ifndef GCC
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class TabBar;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // #102891# -----------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <svtools/svlbox.hxx>
37cdf0e10cSrcweir #include <svtools/svlbitm.hxx>
38cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
39cdf0e10cSrcweir #include <tools/diagnose_ex.h>
40cdf0e10cSrcweir #include <svimpbox.hxx>
41cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
42cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /*
49cdf0e10cSrcweir     Bugs/ToDo
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     - Berechnung Rectangle beim Inplace-Editing (Bug bei manchen Fonts)
52cdf0e10cSrcweir     - SetSpaceBetweenEntries: Offset wird in SetEntryHeight nicht
53cdf0e10cSrcweir       beruecksichtigt
54cdf0e10cSrcweir */
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define TREEFLAG_FIXEDHEIGHT        0x0010
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
DBG_NAME(SvTreeListBox)59cdf0e10cSrcweir DBG_NAME(SvTreeListBox)
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #define SV_LBOX_DEFAULT_INDENT_PIXEL 20
62cdf0e10cSrcweir 
63cdf0e10cSrcweir SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle )
64cdf0e10cSrcweir     : SvLBox( pParent, nWinStyle )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     DBG_CTOR(SvTreeListBox,0);
67cdf0e10cSrcweir     InitTreeView();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     SetSublistOpenWithLeftRight();
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
SvTreeListBox(Window * pParent,const ResId & rResId)72cdf0e10cSrcweir SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId )
73cdf0e10cSrcweir     : SvLBox( pParent,rResId )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     DBG_CTOR(SvTreeListBox,0);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     InitTreeView();
78cdf0e10cSrcweir     Resize();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     SetSublistOpenWithLeftRight();
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
InitTreeView()83cdf0e10cSrcweir void SvTreeListBox::InitTreeView()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
86cdf0e10cSrcweir     pCheckButtonData = NULL;
87cdf0e10cSrcweir     pEdEntry = NULL;
88cdf0e10cSrcweir     pEdItem = NULL;
89cdf0e10cSrcweir     nEntryHeight = 0;
90cdf0e10cSrcweir     pEdCtrl = NULL;
91cdf0e10cSrcweir     nFirstSelTab = 0;
92cdf0e10cSrcweir     nLastSelTab = 0;
93cdf0e10cSrcweir     nFocusWidth = -1;
942bfcd321SSteve Yin     nAllItemAccRoleType = 0;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     Link* pLink = new Link( LINK(this,SvTreeListBox, DefaultCompare) );
97cdf0e10cSrcweir     pLBoxImpl->m_pLink = pLink;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     nTreeFlags = TREEFLAG_RECALCTABS;
100cdf0e10cSrcweir     nIndent = SV_LBOX_DEFAULT_INDENT_PIXEL;
101cdf0e10cSrcweir     nEntryHeightOffs = SV_ENTRYHEIGHTOFFS_PIXEL;
102cdf0e10cSrcweir     pImp = new SvImpLBox( this, GetModel(), GetStyle() );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     aContextBmpMode = SVLISTENTRYFLAG_EXPANDED;
105cdf0e10cSrcweir     nContextBmpWidthMax = 0;
106cdf0e10cSrcweir     SetFont( GetFont() );
107cdf0e10cSrcweir     SetSpaceBetweenEntries( 0 );
108cdf0e10cSrcweir     SetLineColor();
109cdf0e10cSrcweir     InitSettings( sal_True, sal_True, sal_True );
110cdf0e10cSrcweir     ImplInitStyle();
111cdf0e10cSrcweir     SetTabs();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
~SvTreeListBox()115cdf0e10cSrcweir SvTreeListBox::~SvTreeListBox()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     DBG_DTOR(SvTreeListBox,0);
118cdf0e10cSrcweir     pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
119cdf0e10cSrcweir     delete pImp;
120cdf0e10cSrcweir     delete pLBoxImpl->m_pLink;
121cdf0e10cSrcweir     ClearTabList();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
SetExtendedWinBits(ExtendedWinBits _nBits)124cdf0e10cSrcweir void SvTreeListBox::SetExtendedWinBits( ExtendedWinBits _nBits )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     pImp->SetExtendedWindowBits( _nBits );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
GetExtendedWinBits() const129cdf0e10cSrcweir ExtendedWinBits SvTreeListBox::GetExtendedWinBits() const
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     return pImp->GetExtendedWindowBits();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
SetModel(SvLBoxTreeList * pNewModel)134cdf0e10cSrcweir void SvTreeListBox::SetModel( SvLBoxTreeList* pNewModel )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
137cdf0e10cSrcweir     pImp->SetModel( pNewModel );
138cdf0e10cSrcweir     SvLBox::SetModel( pNewModel );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
DisconnectFromModel()141cdf0e10cSrcweir void SvTreeListBox::DisconnectFromModel()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
144cdf0e10cSrcweir     SvLBox::DisconnectFromModel();
145cdf0e10cSrcweir     pImp->SetModel( GetModel() );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
IsA()149cdf0e10cSrcweir sal_uInt16 SvTreeListBox::IsA()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
152cdf0e10cSrcweir     return SV_LISTBOX_ID_TREEBOX;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
SetSublistOpenWithReturn(sal_Bool b)155cdf0e10cSrcweir void SvTreeListBox::SetSublistOpenWithReturn( sal_Bool b )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     pImp->bSubLstOpRet = b;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
IsSublistOpenWithReturn() const160cdf0e10cSrcweir sal_Bool SvTreeListBox::IsSublistOpenWithReturn() const
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     return pImp->bSubLstOpRet;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
SetSublistOpenWithLeftRight(sal_Bool b)165cdf0e10cSrcweir void SvTreeListBox::SetSublistOpenWithLeftRight( sal_Bool b )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     pImp->bSubLstOpLR = b;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
IsSublistOpenWithLeftRight() const170cdf0e10cSrcweir sal_Bool SvTreeListBox::IsSublistOpenWithLeftRight() const
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     return pImp->bSubLstOpLR;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
Resize()175cdf0e10cSrcweir void SvTreeListBox::Resize()
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
178cdf0e10cSrcweir     if( IsEditingActive() )
179cdf0e10cSrcweir         EndEditing( sal_True );
180cdf0e10cSrcweir     SvLBox::Resize();
181cdf0e10cSrcweir     pImp->Resize();
182cdf0e10cSrcweir     nFocusWidth = -1;
183cdf0e10cSrcweir     pImp->ShowCursor( sal_False );
184cdf0e10cSrcweir     pImp->ShowCursor( sal_True );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir /* Faelle:
188cdf0e10cSrcweir 
189cdf0e10cSrcweir    A) Entries haben Bitmaps
190cdf0e10cSrcweir        0. Keine Buttons
191cdf0e10cSrcweir        1. Node-Buttons (optional auch an Root-Items)
192cdf0e10cSrcweir        2. Node-Buttons (optional auch an Root-Items) + CheckButton
193cdf0e10cSrcweir        3. CheckButton
194cdf0e10cSrcweir    B) Entries haben keine Bitmaps  (->ueber WindowBits wg. D&D !!!!!!)
195cdf0e10cSrcweir        0. Keine Buttons
196cdf0e10cSrcweir        1. Node-Buttons (optional auch an Root-Items)
197cdf0e10cSrcweir        2. Node-Buttons (optional auch an Root-Items) + CheckButton
198cdf0e10cSrcweir        3. CheckButton
199cdf0e10cSrcweir */
200cdf0e10cSrcweir 
201cdf0e10cSrcweir #define NO_BUTTONS              0
202cdf0e10cSrcweir #define NODE_BUTTONS            1
203cdf0e10cSrcweir #define NODE_AND_CHECK_BUTTONS  2
204cdf0e10cSrcweir #define CHECK_BUTTONS           3
205cdf0e10cSrcweir 
206cdf0e10cSrcweir #define TABFLAGS_TEXT (SV_LBOXTAB_DYNAMIC |        \
207cdf0e10cSrcweir                        SV_LBOXTAB_ADJUST_LEFT |    \
208cdf0e10cSrcweir                        SV_LBOXTAB_EDITABLE |       \
209cdf0e10cSrcweir                        SV_LBOXTAB_SHOW_SELECTION)
210cdf0e10cSrcweir 
211cdf0e10cSrcweir #define TABFLAGS_CONTEXTBMP (SV_LBOXTAB_DYNAMIC | SV_LBOXTAB_ADJUST_CENTER)
212cdf0e10cSrcweir 
213cdf0e10cSrcweir #define TABFLAGS_CHECKBTN (SV_LBOXTAB_DYNAMIC |        \
214cdf0e10cSrcweir                            SV_LBOXTAB_ADJUST_CENTER |  \
215cdf0e10cSrcweir                            SV_LBOXTAB_PUSHABLE)
216cdf0e10cSrcweir 
217cdf0e10cSrcweir #define TAB_STARTPOS    2
218cdf0e10cSrcweir 
219cdf0e10cSrcweir // bei Aenderungen GetTextOffset beruecksichtigen
SetTabs()220cdf0e10cSrcweir void SvTreeListBox::SetTabs()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
223cdf0e10cSrcweir     if( IsEditingActive() )
224cdf0e10cSrcweir         EndEditing( sal_True );
225cdf0e10cSrcweir     nTreeFlags &= (~TREEFLAG_RECALCTABS);
226cdf0e10cSrcweir     nFocusWidth = -1;
227cdf0e10cSrcweir     const WinBits nStyle( GetStyle() );
228cdf0e10cSrcweir     sal_Bool bHasButtons = (nStyle & WB_HASBUTTONS)!=0;
229cdf0e10cSrcweir     sal_Bool bHasButtonsAtRoot = (nStyle & (WB_HASLINESATROOT |
230cdf0e10cSrcweir                                               WB_HASBUTTONSATROOT))!=0;
231cdf0e10cSrcweir     long nStartPos = TAB_STARTPOS;
232cdf0e10cSrcweir     long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     long nCheckWidth = 0;
235cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_CHKBTN )
236cdf0e10cSrcweir         nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width();
237cdf0e10cSrcweir     long nCheckWidthDIV2 = nCheckWidth / 2;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     long nContextWidth = nContextBmpWidthMax;
240cdf0e10cSrcweir     long nContextWidthDIV2 = nContextWidth / 2;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     ClearTabList();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     int nCase = NO_BUTTONS;
245cdf0e10cSrcweir     if( !(nTreeFlags & TREEFLAG_CHKBTN) )
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         if( bHasButtons )
248cdf0e10cSrcweir             nCase = NODE_BUTTONS;
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir     else
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         if( bHasButtons )
253cdf0e10cSrcweir             nCase = NODE_AND_CHECK_BUTTONS;
254cdf0e10cSrcweir          else
255cdf0e10cSrcweir             nCase = CHECK_BUTTONS;
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     switch( nCase )
259cdf0e10cSrcweir     {
260cdf0e10cSrcweir         case NO_BUTTONS :
261cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // wg. Zentrierung
262cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
263cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
264cdf0e10cSrcweir             // Abstand setzen nur wenn Bitmaps da
265cdf0e10cSrcweir             if( nContextBmpWidthMax )
266cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
267cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_TEXT );
268cdf0e10cSrcweir             break;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir         case NODE_BUTTONS :
271cdf0e10cSrcweir             if( bHasButtonsAtRoot )
272cdf0e10cSrcweir                 nStartPos += ( nIndent + (nNodeWidthPixel/2) );
273cdf0e10cSrcweir             else
274cdf0e10cSrcweir                 nStartPos += nContextWidthDIV2;
275cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
276cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
277cdf0e10cSrcweir             // Abstand setzen nur wenn Bitmaps da
278cdf0e10cSrcweir             if( nContextBmpWidthMax )
279cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
280cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_TEXT );
281cdf0e10cSrcweir             break;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir         case NODE_AND_CHECK_BUTTONS :
284cdf0e10cSrcweir             if( bHasButtonsAtRoot )
285cdf0e10cSrcweir                 nStartPos += ( nIndent + nNodeWidthPixel );
286cdf0e10cSrcweir             else
287cdf0e10cSrcweir                 nStartPos += nCheckWidthDIV2;
288cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CHECKBTN );
289cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;  // rechter Rand des CheckButtons
290cdf0e10cSrcweir             nStartPos += 3;  // Abstand CheckButton Context-Bmp
291cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // Mitte der Context-Bmp
292cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
293cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
294cdf0e10cSrcweir             // Abstand setzen nur wenn Bitmaps da
295cdf0e10cSrcweir             if( nContextBmpWidthMax )
296cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
297cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_TEXT );
298cdf0e10cSrcweir             break;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir         case CHECK_BUTTONS :
301cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;
302cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CHECKBTN );
303cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;  // rechter Rand CheckButton
304cdf0e10cSrcweir             nStartPos += 3;  // Abstand CheckButton Context-Bmp
305cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // Mitte der Context-Bmp
306cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
307cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
308cdf0e10cSrcweir             // Abstand setzen nur wenn Bitmaps da
309cdf0e10cSrcweir             if( nContextBmpWidthMax )
310cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
311cdf0e10cSrcweir             AddTab( nStartPos, TABFLAGS_TEXT );
312cdf0e10cSrcweir             break;
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir     pImp->NotifyTabsChanged();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
InitEntry(SvLBoxEntry * pEntry,const XubString & aStr,const Image & aCollEntryBmp,const Image & aExpEntryBmp,SvLBoxButtonKind eButtonKind)317cdf0e10cSrcweir void SvTreeListBox::InitEntry( SvLBoxEntry* pEntry,
318cdf0e10cSrcweir   const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp,
319cdf0e10cSrcweir   SvLBoxButtonKind eButtonKind)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
322cdf0e10cSrcweir     SvLBoxButton* pButton;
323cdf0e10cSrcweir     SvLBoxString* pString;
324cdf0e10cSrcweir     SvLBoxContextBmp* pContextBmp;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_CHKBTN )
327cdf0e10cSrcweir     {
328cdf0e10cSrcweir         pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
329cdf0e10cSrcweir         pEntry->AddItem( pButton );
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     pContextBmp= new SvLBoxContextBmp( pEntry,0, aCollEntryBmp,aExpEntryBmp,
333cdf0e10cSrcweir                                      aContextBmpMode );
334cdf0e10cSrcweir     pEntry->AddItem( pContextBmp );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     pString = new SvLBoxString( pEntry, 0, aStr );
337cdf0e10cSrcweir     pEntry->AddItem( pString );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
GetEntryText(SvLBoxEntry * pEntry) const340cdf0e10cSrcweir String SvTreeListBox::GetEntryText(SvLBoxEntry* pEntry) const
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
343cdf0e10cSrcweir     DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): no entry" );
344cdf0e10cSrcweir     SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
345cdf0e10cSrcweir     DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): item not found" );
346cdf0e10cSrcweir     return pItem->GetText();
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
GetEntryAltText(SvLBoxEntry *) const3492bfcd321SSteve Yin String  SvTreeListBox::GetEntryAltText( SvLBoxEntry* ) const
3502bfcd321SSteve Yin {
3512bfcd321SSteve Yin     String tmp;
3522bfcd321SSteve Yin     return tmp;
3532bfcd321SSteve Yin }
GetEntryLongDescription(SvLBoxEntry *) const3542bfcd321SSteve Yin String SvTreeListBox::GetEntryLongDescription( SvLBoxEntry* ) const
3552bfcd321SSteve Yin {
3562bfcd321SSteve Yin     String tmp;
3572bfcd321SSteve Yin     return tmp;
3582bfcd321SSteve Yin }
3592bfcd321SSteve Yin 
SearchEntryTextWithHeadTitle(SvLBoxEntry * pEntry)3602bfcd321SSteve Yin String SvTreeListBox::SearchEntryTextWithHeadTitle( SvLBoxEntry* pEntry )
3612bfcd321SSteve Yin {
3622bfcd321SSteve Yin     DBG_CHKTHIS(SvTreeListBox,0);
3632bfcd321SSteve Yin     DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" );
3642bfcd321SSteve Yin     String sRet;
3652bfcd321SSteve Yin 
3662bfcd321SSteve Yin     sal_uInt16 nCount = pEntry->ItemCount();
3672bfcd321SSteve Yin     sal_uInt16 nCur = 0;
3682bfcd321SSteve Yin     sal_uInt16 nHeaderCur = 0;
3692bfcd321SSteve Yin     SvLBoxItem* pItem;
3702bfcd321SSteve Yin     while( nCur < nCount )
3712bfcd321SSteve Yin     {
3722bfcd321SSteve Yin         // MT: SV_ITEM_ID_EXTENDRLBOXSTRING / GetExtendText() was in use in IA2 cws, but only used in sc: ScSolverOptionsString. Needed?
3732bfcd321SSteve Yin         pItem = pEntry->GetItem( nCur );
3742bfcd321SSteve Yin         if ( (pItem->IsA() == SV_ITEM_ID_LBOXSTRING /* || pItem->IsA() == SV_ITEM_ID_EXTENDRLBOXSTRING */ ) &&
3752bfcd321SSteve Yin              static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 )
3762bfcd321SSteve Yin         {
3772bfcd321SSteve Yin 
3782bfcd321SSteve Yin             //want to the column header
3792bfcd321SSteve Yin             if( headString.Len() > 0)
3802bfcd321SSteve Yin             {
3812bfcd321SSteve Yin                 xub_StrLen nEnd = headString.Search( sal_Unicode( '\t' ) );
3822bfcd321SSteve Yin                 if( nEnd == STRING_NOTFOUND )
3832bfcd321SSteve Yin                 {
3842bfcd321SSteve Yin                     if(sRet.Len()>0)
3852bfcd321SSteve Yin                     {
3862bfcd321SSteve Yin                         sRet += ',';
3872bfcd321SSteve Yin                     }
3882bfcd321SSteve Yin                     if(headString.Len()>0)
3892bfcd321SSteve Yin                     {
3902bfcd321SSteve Yin                         sRet += headString ;
3912bfcd321SSteve Yin                         sRet += ':' ;
3922bfcd321SSteve Yin                     }
3932bfcd321SSteve Yin                 }
3942bfcd321SSteve Yin                 else
3952bfcd321SSteve Yin                 {
3962bfcd321SSteve Yin                     String  aString=headString.GetToken(nHeaderCur, sal_Unicode( '\t' ) );
3972bfcd321SSteve Yin                     if(sRet.Len()>0)
3982bfcd321SSteve Yin                     {
3992bfcd321SSteve Yin                         sRet += ',';
4002bfcd321SSteve Yin                     }
4012bfcd321SSteve Yin                     if( aString.Len() > 0)
4022bfcd321SSteve Yin                     {
4032bfcd321SSteve Yin                         sRet += aString ;
4042bfcd321SSteve Yin                         sRet += ':' ;
4052bfcd321SSteve Yin                     }
4062bfcd321SSteve Yin                     nHeaderCur++;
4072bfcd321SSteve Yin                 }
4082bfcd321SSteve Yin                 // if (pItem->IsA() == SV_ITEM_ID_LBOXSTRING)
4092bfcd321SSteve Yin                     sRet += static_cast<SvLBoxString*>( pItem )->GetText();
4102bfcd321SSteve Yin                 // else
4112bfcd321SSteve Yin                 //  sRet += static_cast<SvLBoxString*>( pItem )->GetExtendText();
4122bfcd321SSteve Yin             }
4132bfcd321SSteve Yin             else
4142bfcd321SSteve Yin             {
4152bfcd321SSteve Yin                 // if (pItem->IsA() == SV_ITEM_ID_LBOXSTRING)
4162bfcd321SSteve Yin                     sRet += static_cast<SvLBoxString*>( pItem )->GetText();
4172bfcd321SSteve Yin                 // else
4182bfcd321SSteve Yin                 //  sRet += static_cast<SvLBoxString*>( pItem )->GetExtendText();
4192bfcd321SSteve Yin                 sRet += ',';
4202bfcd321SSteve Yin             }
4212bfcd321SSteve Yin             //end want to the column header
4222bfcd321SSteve Yin         }
4232bfcd321SSteve Yin         nCur++;
4242bfcd321SSteve Yin     }
4252bfcd321SSteve Yin 
4262bfcd321SSteve Yin     if (sRet.Len() > 0)
4272bfcd321SSteve Yin         sRet = sRet.Erase(sRet.Len() - 1);
4282bfcd321SSteve Yin     return sRet;
4292bfcd321SSteve Yin }
SearchEntryText(SvLBoxEntry * pEntry) const430cdf0e10cSrcweir String SvTreeListBox::SearchEntryText( SvLBoxEntry* pEntry ) const
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
433cdf0e10cSrcweir     DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" );
434cdf0e10cSrcweir     String sRet;
435cdf0e10cSrcweir     sal_uInt16 nCount = pEntry->ItemCount();
436cdf0e10cSrcweir     sal_uInt16 nCur = 0;
437cdf0e10cSrcweir     SvLBoxItem* pItem;
438cdf0e10cSrcweir     while( nCur < nCount )
439cdf0e10cSrcweir     {
440cdf0e10cSrcweir         pItem = pEntry->GetItem( nCur );
441cdf0e10cSrcweir         if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING &&
442cdf0e10cSrcweir              static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 )
443cdf0e10cSrcweir         {
444cdf0e10cSrcweir             sRet = static_cast<SvLBoxString*>( pItem )->GetText();
445cdf0e10cSrcweir             break;
446cdf0e10cSrcweir         }
447cdf0e10cSrcweir         nCur++;
448cdf0e10cSrcweir     }
449cdf0e10cSrcweir     return sRet;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
GetExpandedEntryBmp(SvLBoxEntry * pEntry,BmpColorMode _eMode) const452cdf0e10cSrcweir const Image& SvTreeListBox::GetExpandedEntryBmp(SvLBoxEntry* pEntry, BmpColorMode _eMode) const
453cdf0e10cSrcweir {
454cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
455cdf0e10cSrcweir     DBG_ASSERT(pEntry,"Entry?");
456cdf0e10cSrcweir     SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
457cdf0e10cSrcweir     DBG_ASSERT(pItem,"GetContextBmp:Item not found");
458cdf0e10cSrcweir     return pItem->GetBitmap2( _eMode );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
GetCollapsedEntryBmp(SvLBoxEntry * pEntry,BmpColorMode _eMode) const461cdf0e10cSrcweir const Image& SvTreeListBox::GetCollapsedEntryBmp( SvLBoxEntry* pEntry, BmpColorMode _eMode ) const
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
464cdf0e10cSrcweir     DBG_ASSERT(pEntry,"Entry?");
465cdf0e10cSrcweir     SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
466cdf0e10cSrcweir     DBG_ASSERT(pItem,"GetContextBmp:Item not found");
467cdf0e10cSrcweir     return pItem->GetBitmap1( _eMode );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(SvTreeListBox,CheckButtonClick,SvLBoxButtonData *,pData)470cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
473cdf0e10cSrcweir     pHdlEntry = pData->GetActEntry();
474cdf0e10cSrcweir     CheckButtonHdl();
475cdf0e10cSrcweir     return 0;
476cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvTreeListBox,CheckButtonClick,SvLBoxButtonData *,pData)477cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
478cdf0e10cSrcweir 
479cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,SvLBoxEntry* pParent,
480cdf0e10cSrcweir                                      sal_Bool bChildsOnDemand, sal_uLong nPos, void* pUser,
481cdf0e10cSrcweir                                      SvLBoxButtonKind eButtonKind )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
484cdf0e10cSrcweir     nTreeFlags |= TREEFLAG_MANINS;
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     const Image& rDefExpBmp = pImp->GetDefaultEntryExpBmp( );
487cdf0e10cSrcweir     const Image& rDefColBmp = pImp->GetDefaultEntryColBmp( );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     aCurInsertedExpBmp = rDefExpBmp;
490cdf0e10cSrcweir     aCurInsertedColBmp = rDefColBmp;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     SvLBoxEntry* pEntry = CreateEntry();
493cdf0e10cSrcweir     pEntry->SetUserData( pUser );
494cdf0e10cSrcweir     InitEntry( pEntry, aText, rDefColBmp, rDefExpBmp, eButtonKind );
495cdf0e10cSrcweir     pEntry->EnableChildsOnDemand( bChildsOnDemand );
496cdf0e10cSrcweir 
497cdf0e10cSrcweir     // Add the HC versions of the default images
498cdf0e10cSrcweir     SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
499cdf0e10cSrcweir     if( pBmpItem )
500cdf0e10cSrcweir     {
501cdf0e10cSrcweir         pBmpItem->SetBitmap1( pImp->GetDefaultEntryColBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
502cdf0e10cSrcweir         pBmpItem->SetBitmap2( pImp->GetDefaultEntryExpBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
503cdf0e10cSrcweir     }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     if( !pParent )
506cdf0e10cSrcweir         SvLBox::Insert( pEntry, nPos );
507cdf0e10cSrcweir     else
508cdf0e10cSrcweir         SvLBox::Insert( pEntry, pParent, nPos );
509cdf0e10cSrcweir 
510cdf0e10cSrcweir     aPrevInsertedExpBmp = rDefExpBmp;
511cdf0e10cSrcweir     aPrevInsertedColBmp = rDefColBmp;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir     nTreeFlags &= (~TREEFLAG_MANINS);
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     return pEntry;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
InsertEntry(const XubString & aText,const Image & aExpEntryBmp,const Image & aCollEntryBmp,SvLBoxEntry * pParent,sal_Bool bChildsOnDemand,sal_uLong nPos,void * pUser,SvLBoxButtonKind eButtonKind)518cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,
519cdf0e10cSrcweir     const Image& aExpEntryBmp, const Image& aCollEntryBmp,
520cdf0e10cSrcweir     SvLBoxEntry* pParent, sal_Bool bChildsOnDemand, sal_uLong nPos, void* pUser,
521cdf0e10cSrcweir     SvLBoxButtonKind eButtonKind )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
524cdf0e10cSrcweir     nTreeFlags |= TREEFLAG_MANINS;
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     aCurInsertedExpBmp = aExpEntryBmp;
527cdf0e10cSrcweir     aCurInsertedColBmp = aCollEntryBmp;
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     SvLBoxEntry* pEntry = CreateEntry();
530cdf0e10cSrcweir     pEntry->SetUserData( pUser );
531cdf0e10cSrcweir     InitEntry( pEntry, aText, aCollEntryBmp, aExpEntryBmp, eButtonKind );
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     pEntry->EnableChildsOnDemand( bChildsOnDemand );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     if( !pParent )
536cdf0e10cSrcweir         SvLBox::Insert( pEntry, nPos );
537cdf0e10cSrcweir     else
538cdf0e10cSrcweir         SvLBox::Insert( pEntry, pParent, nPos );
539cdf0e10cSrcweir 
540cdf0e10cSrcweir     aPrevInsertedExpBmp = aExpEntryBmp;
541cdf0e10cSrcweir     aPrevInsertedColBmp = aCollEntryBmp;
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     nTreeFlags &= (~TREEFLAG_MANINS);
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     return pEntry;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
SetEntryText(SvLBoxEntry * pEntry,const XubString & aStr)548cdf0e10cSrcweir void SvTreeListBox::SetEntryText( SvLBoxEntry* pEntry, const XubString& aStr)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
551cdf0e10cSrcweir     SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
552cdf0e10cSrcweir     DBG_ASSERT(pItem,"SetText:Item not found");
553cdf0e10cSrcweir     pItem->SetText( pEntry, aStr );
554cdf0e10cSrcweir     pItem->InitViewData( this, pEntry, 0 );
555cdf0e10cSrcweir     GetModel()->InvalidateEntry( pEntry );
556cdf0e10cSrcweir }
557cdf0e10cSrcweir 
SetExpandedEntryBmp(SvLBoxEntry * pEntry,const Image & aBmp,BmpColorMode _eMode)558cdf0e10cSrcweir void SvTreeListBox::SetExpandedEntryBmp( SvLBoxEntry* pEntry, const Image& aBmp, BmpColorMode _eMode )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
561cdf0e10cSrcweir     SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     DBG_ASSERT(pItem,"SetExpBmp:Item not found");
564cdf0e10cSrcweir     pItem->SetBitmap2( aBmp, _eMode );
565cdf0e10cSrcweir 
566cdf0e10cSrcweir     GetModel()->InvalidateEntry( pEntry );
567cdf0e10cSrcweir     SetEntryHeight( pEntry );
568cdf0e10cSrcweir     Size aSize = aBmp.GetSizePixel();
569cdf0e10cSrcweir     // #97680# ---------------
570cdf0e10cSrcweir     short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
571cdf0e10cSrcweir     if( nWidth > nContextBmpWidthMax )
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         nContextBmpWidthMax = nWidth;
574cdf0e10cSrcweir         SetTabs();
575cdf0e10cSrcweir     }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
SetCollapsedEntryBmp(SvLBoxEntry * pEntry,const Image & aBmp,BmpColorMode _eMode)578cdf0e10cSrcweir void SvTreeListBox::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,const Image& aBmp, BmpColorMode _eMode )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
581cdf0e10cSrcweir     SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
582cdf0e10cSrcweir 
583cdf0e10cSrcweir     DBG_ASSERT(pItem,"SetExpBmp:Item not found");
584cdf0e10cSrcweir     pItem->SetBitmap1( aBmp, _eMode );
585cdf0e10cSrcweir 
586cdf0e10cSrcweir     GetModel()->InvalidateEntry( pEntry );
587cdf0e10cSrcweir     SetEntryHeight( pEntry );
588cdf0e10cSrcweir     Size aSize = aBmp.GetSizePixel();
589cdf0e10cSrcweir     // #97680# -----------
590cdf0e10cSrcweir     short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
591cdf0e10cSrcweir     if( nWidth > nContextBmpWidthMax )
592cdf0e10cSrcweir     {
593cdf0e10cSrcweir         nContextBmpWidthMax = nWidth;
594cdf0e10cSrcweir         SetTabs();
595cdf0e10cSrcweir     }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
ImpEntryInserted(SvLBoxEntry * pEntry)598cdf0e10cSrcweir void SvTreeListBox::ImpEntryInserted( SvLBoxEntry* pEntry )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     SvLBoxEntry* pParent = (SvLBoxEntry*)pModel->GetParent( pEntry );
603cdf0e10cSrcweir     if( pParent )
604cdf0e10cSrcweir     {
605cdf0e10cSrcweir         sal_uInt16 nFlags = pParent->GetFlags();
606cdf0e10cSrcweir         nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
607cdf0e10cSrcweir         pParent->SetFlags( nFlags );
608cdf0e10cSrcweir     }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir     if(!((nTreeFlags & TREEFLAG_MANINS) &&
611cdf0e10cSrcweir          (aPrevInsertedExpBmp == aCurInsertedExpBmp)  &&
612cdf0e10cSrcweir          (aPrevInsertedColBmp == aCurInsertedColBmp) ))
613cdf0e10cSrcweir     {
614cdf0e10cSrcweir         Size aSize = GetCollapsedEntryBmp( pEntry ).GetSizePixel();
615cdf0e10cSrcweir         if( aSize.Width() > nContextBmpWidthMax )
616cdf0e10cSrcweir         {
617cdf0e10cSrcweir             nContextBmpWidthMax = (short)aSize.Width();
618cdf0e10cSrcweir             nTreeFlags |= TREEFLAG_RECALCTABS;
619cdf0e10cSrcweir         }
620cdf0e10cSrcweir         aSize = GetExpandedEntryBmp( pEntry ).GetSizePixel();
621cdf0e10cSrcweir         if( aSize.Width() > nContextBmpWidthMax )
622cdf0e10cSrcweir         {
623cdf0e10cSrcweir             nContextBmpWidthMax = (short)aSize.Width();
624cdf0e10cSrcweir             nTreeFlags |= TREEFLAG_RECALCTABS;
625cdf0e10cSrcweir         }
626cdf0e10cSrcweir     }
627cdf0e10cSrcweir     SetEntryHeight( (SvLBoxEntry*)pEntry );
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 
SetCheckButtonState(SvLBoxEntry * pEntry,SvButtonState eState)632cdf0e10cSrcweir void SvTreeListBox::SetCheckButtonState( SvLBoxEntry* pEntry, SvButtonState eState)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
635cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_CHKBTN )
636cdf0e10cSrcweir     {
637cdf0e10cSrcweir         SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
638cdf0e10cSrcweir         if(!(pItem && pItem->CheckModification()))
639cdf0e10cSrcweir             return ;
640cdf0e10cSrcweir         switch( eState )
641cdf0e10cSrcweir         {
642cdf0e10cSrcweir             case SV_BUTTON_CHECKED:
643cdf0e10cSrcweir                 pItem->SetStateChecked();
644cdf0e10cSrcweir                 break;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir             case SV_BUTTON_UNCHECKED:
647cdf0e10cSrcweir                 pItem->SetStateUnchecked();
648cdf0e10cSrcweir                 break;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir             case SV_BUTTON_TRISTATE:
651cdf0e10cSrcweir                 pItem->SetStateTristate();
652cdf0e10cSrcweir                 break;
653cdf0e10cSrcweir         }
654cdf0e10cSrcweir         InvalidateEntry( pEntry );
655cdf0e10cSrcweir     }
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
GetCheckButtonState(SvLBoxEntry * pEntry) const658cdf0e10cSrcweir SvButtonState SvTreeListBox::GetCheckButtonState( SvLBoxEntry* pEntry ) const
659cdf0e10cSrcweir {
660cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
661cdf0e10cSrcweir     SvButtonState eState = SV_BUTTON_UNCHECKED;
662cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_CHKBTN )
663cdf0e10cSrcweir     {
664cdf0e10cSrcweir         SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
665cdf0e10cSrcweir         if(!pItem)
666cdf0e10cSrcweir             return SV_BUTTON_TRISTATE;
667cdf0e10cSrcweir         sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
668cdf0e10cSrcweir         eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
669cdf0e10cSrcweir     }
670cdf0e10cSrcweir     return eState;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
CheckButtonHdl()673cdf0e10cSrcweir void SvTreeListBox::CheckButtonHdl()
674cdf0e10cSrcweir {
675cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
676cdf0e10cSrcweir     aCheckButtonHdl.Call( this );
677cdf0e10cSrcweir     if ( pCheckButtonData )
678cdf0e10cSrcweir         pImp->CallEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)pCheckButtonData->GetActEntry() );
679cdf0e10cSrcweir }
680cdf0e10cSrcweir 
681cdf0e10cSrcweir // *********************************************************************
682cdf0e10cSrcweir // *********************************************************************
683cdf0e10cSrcweir 
684cdf0e10cSrcweir //
685cdf0e10cSrcweir //  TODO: Momentan werden die Daten so geklont, dass sie dem
686cdf0e10cSrcweir //  Standard-TreeView-Format entsprechen. Hier sollte eigentlich
687cdf0e10cSrcweir //  das Model als Referenz dienen. Dies fuehrt dazu, dass
688cdf0e10cSrcweir //  SvLBoxEntry::Clone _nicht_ gerufen wird, sondern nur dessen
689cdf0e10cSrcweir //  Basisklasse SvListEntry
690cdf0e10cSrcweir //
691cdf0e10cSrcweir 
CloneEntry(SvLBoxEntry * pSource)692cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::CloneEntry( SvLBoxEntry* pSource )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
695cdf0e10cSrcweir     XubString aStr;
696cdf0e10cSrcweir     Image aCollEntryBmp;
697cdf0e10cSrcweir     Image aExpEntryBmp;
698cdf0e10cSrcweir     SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox;
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
701cdf0e10cSrcweir     if( pStringItem )
702cdf0e10cSrcweir         aStr = pStringItem->GetText();
703cdf0e10cSrcweir     SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
704cdf0e10cSrcweir     if( pBmpItem )
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         aCollEntryBmp = pBmpItem->GetBitmap1( BMP_COLOR_NORMAL );
707cdf0e10cSrcweir         aExpEntryBmp  = pBmpItem->GetBitmap2( BMP_COLOR_NORMAL );
708cdf0e10cSrcweir     }
709cdf0e10cSrcweir     SvLBoxButton* pButtonItem = (SvLBoxButton*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
710cdf0e10cSrcweir     if( pButtonItem )
711cdf0e10cSrcweir         eButtonKind = pButtonItem->GetKind();
712cdf0e10cSrcweir     SvLBoxEntry* pClone = CreateEntry();
713cdf0e10cSrcweir     InitEntry( pClone, aStr, aCollEntryBmp, aExpEntryBmp, eButtonKind );
714cdf0e10cSrcweir     pClone->SvListEntry::Clone( pSource );
715cdf0e10cSrcweir     pClone->EnableChildsOnDemand( pSource->HasChildsOnDemand() );
716cdf0e10cSrcweir     pClone->SetUserData( pSource->GetUserData() );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     if ( pBmpItem )
719cdf0e10cSrcweir     {
720cdf0e10cSrcweir         SvLBoxContextBmp* pCloneBitmap = static_cast< SvLBoxContextBmp* >( pClone->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
721cdf0e10cSrcweir         if ( pCloneBitmap )
722cdf0e10cSrcweir         {
723cdf0e10cSrcweir             pCloneBitmap->SetBitmap1( pBmpItem->GetBitmap1( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
724cdf0e10cSrcweir             pCloneBitmap->SetBitmap2( pBmpItem->GetBitmap2( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
725cdf0e10cSrcweir         }
726cdf0e10cSrcweir     }
727cdf0e10cSrcweir 
728cdf0e10cSrcweir     return pClone;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir 
731cdf0e10cSrcweir // *********************************************************************
732cdf0e10cSrcweir // *********************************************************************
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 
ShowExpandBitmapOnCursor(sal_Bool bYes)735cdf0e10cSrcweir void SvTreeListBox::ShowExpandBitmapOnCursor( sal_Bool bYes )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
738cdf0e10cSrcweir     if( bYes )
739cdf0e10cSrcweir         aContextBmpMode = SVLISTENTRYFLAG_FOCUSED;
740cdf0e10cSrcweir     else
741cdf0e10cSrcweir         aContextBmpMode = SVLISTENTRYFLAG_EXPANDED;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir 
SetIndent(short nNewIndent)744cdf0e10cSrcweir void SvTreeListBox::SetIndent( short nNewIndent )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
747cdf0e10cSrcweir     nIndent = nNewIndent;
748cdf0e10cSrcweir     SetTabs();
749cdf0e10cSrcweir     if( IsUpdateMode() )
750cdf0e10cSrcweir         Invalidate();
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
GetDefaultExpandedEntryBmp(BmpColorMode _eMode) const753cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultExpandedEntryBmp( BmpColorMode _eMode ) const
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     return pImp->GetDefaultEntryExpBmp( _eMode );
756cdf0e10cSrcweir }
757cdf0e10cSrcweir 
GetDefaultCollapsedEntryBmp(BmpColorMode _eMode) const758cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultCollapsedEntryBmp( BmpColorMode _eMode ) const
759cdf0e10cSrcweir {
760cdf0e10cSrcweir     return pImp->GetDefaultEntryColBmp( _eMode );
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
SetDefaultExpandedEntryBmp(const Image & aBmp,BmpColorMode _eMode)763cdf0e10cSrcweir void SvTreeListBox::SetDefaultExpandedEntryBmp( const Image& aBmp, BmpColorMode _eMode )
764cdf0e10cSrcweir {
765cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
766cdf0e10cSrcweir     Size aSize = aBmp.GetSizePixel();
767cdf0e10cSrcweir     if( aSize.Width() > nContextBmpWidthMax )
768cdf0e10cSrcweir         nContextBmpWidthMax = (short)aSize.Width();
769cdf0e10cSrcweir     SetTabs();
770cdf0e10cSrcweir 
771cdf0e10cSrcweir     pImp->SetDefaultEntryExpBmp( aBmp, _eMode );
772cdf0e10cSrcweir }
773cdf0e10cSrcweir 
SetDefaultCollapsedEntryBmp(const Image & aBmp,BmpColorMode _eMode)774cdf0e10cSrcweir void SvTreeListBox::SetDefaultCollapsedEntryBmp( const Image& aBmp, BmpColorMode _eMode )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
777cdf0e10cSrcweir     Size aSize = aBmp.GetSizePixel();
778cdf0e10cSrcweir     if( aSize.Width() > nContextBmpWidthMax )
779cdf0e10cSrcweir         nContextBmpWidthMax = (short)aSize.Width();
780cdf0e10cSrcweir     SetTabs();
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     pImp->SetDefaultEntryColBmp( aBmp, _eMode );
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
EnableCheckButton(SvLBoxButtonData * pData)785cdf0e10cSrcweir void SvTreeListBox::EnableCheckButton( SvLBoxButtonData* pData )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
788cdf0e10cSrcweir     DBG_ASSERT(!GetEntryCount(),"EnableCheckButton: Entry count != 0");
789cdf0e10cSrcweir     if( !pData )
790cdf0e10cSrcweir         nTreeFlags &= (~TREEFLAG_CHKBTN);
791cdf0e10cSrcweir     else
792cdf0e10cSrcweir     {
793cdf0e10cSrcweir         SetCheckButtonData( pData );
794cdf0e10cSrcweir         nTreeFlags |= TREEFLAG_CHKBTN;
795cdf0e10cSrcweir         pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir     SetTabs();
799cdf0e10cSrcweir     if( IsUpdateMode() )
800cdf0e10cSrcweir         Invalidate();
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
SetCheckButtonData(SvLBoxButtonData * pData)803cdf0e10cSrcweir void SvTreeListBox::SetCheckButtonData( SvLBoxButtonData* pData )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
806cdf0e10cSrcweir     if ( pData )
807cdf0e10cSrcweir         pCheckButtonData = pData;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
GetDefaultExpandedNodeImage(BmpColorMode _eMode)810cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultExpandedNodeImage( BmpColorMode _eMode )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir     return SvImpLBox::GetDefaultExpandedNodeImage( _eMode );
813cdf0e10cSrcweir }
814cdf0e10cSrcweir 
GetDefaultCollapsedNodeImage(BmpColorMode _eMode)815cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultCollapsedNodeImage( BmpColorMode _eMode )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir     return SvImpLBox::GetDefaultCollapsedNodeImage( _eMode );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
SetNodeBitmaps(const Image & rCollapsedNodeBmp,const Image & rExpandedNodeBmp,BmpColorMode _eMode)820cdf0e10cSrcweir void SvTreeListBox::SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp, BmpColorMode _eMode )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
823cdf0e10cSrcweir     SetExpandedNodeBmp( rExpandedNodeBmp, _eMode );
824cdf0e10cSrcweir     SetCollapsedNodeBmp( rCollapsedNodeBmp, _eMode );
825cdf0e10cSrcweir     SetTabs();
826cdf0e10cSrcweir }
827cdf0e10cSrcweir 
SetDontKnowNodeBitmap(const Image & rDontKnowBmp,BmpColorMode _eMode)828cdf0e10cSrcweir void SvTreeListBox::SetDontKnowNodeBitmap( const Image& rDontKnowBmp, BmpColorMode _eMode )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir     pImp->SetDontKnowNodeBmp( rDontKnowBmp, _eMode );
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
EditingEntry(SvLBoxEntry *,Selection &)833cdf0e10cSrcweir sal_Bool SvTreeListBox::EditingEntry( SvLBoxEntry*, Selection& )
834cdf0e10cSrcweir {
835cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
836cdf0e10cSrcweir     return sal_True;
837cdf0e10cSrcweir }
838cdf0e10cSrcweir 
EditedEntry(SvLBoxEntry *,const XubString &)839cdf0e10cSrcweir sal_Bool SvTreeListBox::EditedEntry( SvLBoxEntry* /*pEntry*/,const XubString& /*rNewText*/)
840cdf0e10cSrcweir {
841cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
842cdf0e10cSrcweir     return sal_True;
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
EnableInplaceEditing(sal_Bool bOn)845cdf0e10cSrcweir void SvTreeListBox::EnableInplaceEditing( sal_Bool bOn )
846cdf0e10cSrcweir {
847cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
848cdf0e10cSrcweir     SvLBox::EnableInplaceEditing( bOn );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)851cdf0e10cSrcweir void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
854cdf0e10cSrcweir     // unter OS/2 bekommen wir auch beim Editieren Key-Up/Down
855cdf0e10cSrcweir     if( IsEditingActive() )
856cdf0e10cSrcweir         return;
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     nImpFlags |= SVLBOX_IS_TRAVELSELECT;
859cdf0e10cSrcweir 
860cdf0e10cSrcweir #ifdef OVDEBUG
861cdf0e10cSrcweir     sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
862cdf0e10cSrcweir     switch ( nCode )
863cdf0e10cSrcweir     {
864cdf0e10cSrcweir         case KEY_F1:
865cdf0e10cSrcweir         {
866cdf0e10cSrcweir             SvLBoxEntry* pEntry = First();
867cdf0e10cSrcweir             pEntry = NextVisible( pEntry );
868cdf0e10cSrcweir             SetEntryText( pEntry, "SetEntryText" );
869cdf0e10cSrcweir             Sound::Beep();
870cdf0e10cSrcweir         }
871cdf0e10cSrcweir         break;
872cdf0e10cSrcweir     }
873cdf0e10cSrcweir #endif
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     if( !pImp->KeyInput( rKEvt ) )
876cdf0e10cSrcweir         SvLBox::KeyInput( rKEvt );
877cdf0e10cSrcweir 
878cdf0e10cSrcweir     nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
879cdf0e10cSrcweir }
880cdf0e10cSrcweir 
RequestingChilds(SvLBoxEntry * pParent)881cdf0e10cSrcweir void SvTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
884cdf0e10cSrcweir     if( !pParent->HasChilds() )
885cdf0e10cSrcweir         InsertEntry( String::CreateFromAscii("<dummy>"), pParent, sal_False, LIST_APPEND );
886cdf0e10cSrcweir }
887cdf0e10cSrcweir 
GetFocus()888cdf0e10cSrcweir void SvTreeListBox::GetFocus()
889cdf0e10cSrcweir {
890cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
8912bfcd321SSteve Yin     //Solution:If there is no item in the tree,draw focus.
8922bfcd321SSteve Yin     if( !SvLBox::First())
8932bfcd321SSteve Yin     {
8942bfcd321SSteve Yin         Invalidate();
8952bfcd321SSteve Yin     }
896cdf0e10cSrcweir     pImp->GetFocus();
897cdf0e10cSrcweir     SvLBox::GetFocus();
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     SvLBoxEntry* pEntry = FirstSelected();
9002bfcd321SSteve Yin     if ( !pEntry )
9012bfcd321SSteve Yin     {
9022bfcd321SSteve Yin         pEntry = pImp->GetCurrentEntry();
9032bfcd321SSteve Yin     }
9042bfcd321SSteve Yin     if (pImp->pCursor)
9052bfcd321SSteve Yin     {
9062bfcd321SSteve Yin         if (pEntry != pImp->pCursor)
9072bfcd321SSteve Yin             pEntry = pImp->pCursor;
9082bfcd321SSteve Yin     }
909cdf0e10cSrcweir     if ( pEntry )
9102bfcd321SSteve Yin         pImp->CallEventListeners( VCLEVENT_LISTBOX_TREEFOCUS, pEntry );
911cdf0e10cSrcweir 
912cdf0e10cSrcweir }
913cdf0e10cSrcweir 
LoseFocus()914cdf0e10cSrcweir void SvTreeListBox::LoseFocus()
915cdf0e10cSrcweir {
916cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
9172bfcd321SSteve Yin     //Solution:If there is no item in the tree,delete visual focus.
9182bfcd321SSteve Yin     if( !SvLBox::First())
9192bfcd321SSteve Yin     {
9202bfcd321SSteve Yin         Invalidate();
9212bfcd321SSteve Yin     }
922cdf0e10cSrcweir     pImp->LoseFocus();
923cdf0e10cSrcweir     SvLBox::LoseFocus();
924cdf0e10cSrcweir }
925cdf0e10cSrcweir 
ModelHasCleared()926cdf0e10cSrcweir void SvTreeListBox::ModelHasCleared()
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
929cdf0e10cSrcweir     pImp->pCursor = 0; //sonst Absturz beim Inplace-Editieren im GetFocus
930cdf0e10cSrcweir     delete pEdCtrl;
931cdf0e10cSrcweir     pEdCtrl = NULL;
932cdf0e10cSrcweir     pImp->Clear();
933cdf0e10cSrcweir     nFocusWidth = -1;
934cdf0e10cSrcweir 
935cdf0e10cSrcweir     nContextBmpWidthMax = 0;
936cdf0e10cSrcweir     SetDefaultExpandedEntryBmp( GetDefaultExpandedEntryBmp() );
937cdf0e10cSrcweir     SetDefaultCollapsedEntryBmp( GetDefaultCollapsedEntryBmp() );
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     if( !(nTreeFlags & TREEFLAG_FIXEDHEIGHT ))
940cdf0e10cSrcweir         nEntryHeight = 0;
941cdf0e10cSrcweir     AdjustEntryHeight( GetFont() );
942cdf0e10cSrcweir     AdjustEntryHeight( GetDefaultExpandedEntryBmp() );
943cdf0e10cSrcweir     AdjustEntryHeight( GetDefaultCollapsedEntryBmp() );
944cdf0e10cSrcweir 
945cdf0e10cSrcweir     SvLBox::ModelHasCleared();
946cdf0e10cSrcweir //  if( IsUpdateMode() )
947cdf0e10cSrcweir //      Invalidate();
948cdf0e10cSrcweir }
949cdf0e10cSrcweir 
ShowTargetEmphasis(SvLBoxEntry * pEntry,sal_Bool)950cdf0e10cSrcweir void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool /* bShow  */ )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
953cdf0e10cSrcweir     pImp->PaintDDCursor( pEntry );
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
ScrollOutputArea(short nDeltaEntries)956cdf0e10cSrcweir void SvTreeListBox::ScrollOutputArea( short nDeltaEntries )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
959cdf0e10cSrcweir     if( !nDeltaEntries || !pImp->aVerSBar.IsVisible() )
960cdf0e10cSrcweir         return;
961cdf0e10cSrcweir 
962cdf0e10cSrcweir     long nThumb = pImp->aVerSBar.GetThumbPos();
963cdf0e10cSrcweir     long nMax = pImp->aVerSBar.GetRange().Max();
964cdf0e10cSrcweir 
965cdf0e10cSrcweir     NotifyBeginScroll();
966cdf0e10cSrcweir     if( nDeltaEntries < 0 )
967cdf0e10cSrcweir     {
968cdf0e10cSrcweir         // das Fenster nach oben verschieben
969cdf0e10cSrcweir         nDeltaEntries *= -1;
970cdf0e10cSrcweir         long nVis = pImp->aVerSBar.GetVisibleSize();
971cdf0e10cSrcweir         long nTemp = nThumb + nVis;
972cdf0e10cSrcweir         if( nDeltaEntries > (nMax - nTemp) )
973cdf0e10cSrcweir             nDeltaEntries = (short)(nMax - nTemp);
974cdf0e10cSrcweir         pImp->PageDown( (sal_uInt16)nDeltaEntries );
975cdf0e10cSrcweir     }
976cdf0e10cSrcweir     else
977cdf0e10cSrcweir     {
978cdf0e10cSrcweir         if( nDeltaEntries > nThumb )
979cdf0e10cSrcweir             nDeltaEntries = (short)nThumb;
980cdf0e10cSrcweir         pImp->PageUp( (sal_uInt16)nDeltaEntries );
981cdf0e10cSrcweir     }
982cdf0e10cSrcweir     pImp->SyncVerThumb();
983cdf0e10cSrcweir     NotifyEndScroll();
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
SetSelectionMode(SelectionMode eSelectMode)986cdf0e10cSrcweir void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
989cdf0e10cSrcweir     SvLBox::SetSelectionMode( eSelectMode );
990cdf0e10cSrcweir     pImp->SetSelectionMode( eSelectMode );
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
SetDragDropMode(DragDropMode nDDMode)993cdf0e10cSrcweir void SvTreeListBox::SetDragDropMode( DragDropMode nDDMode )
994cdf0e10cSrcweir {
995cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
996cdf0e10cSrcweir     SvLBox::SetDragDropMode( nDDMode );
997cdf0e10cSrcweir     pImp->SetDragDropMode( nDDMode );
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
GetHeightOffset(const Image & rBmp,Size & aSizeLogic)1000cdf0e10cSrcweir short SvTreeListBox::GetHeightOffset(const Image& rBmp, Size& aSizeLogic )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1003cdf0e10cSrcweir     short nOffset = 0;
1004cdf0e10cSrcweir     aSizeLogic = rBmp.GetSizePixel();
1005cdf0e10cSrcweir     if( GetEntryHeight() > aSizeLogic.Height() )
1006cdf0e10cSrcweir         nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
1007cdf0e10cSrcweir     return nOffset;
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
GetHeightOffset(const Font &,Size & aSizeLogic)1010cdf0e10cSrcweir short SvTreeListBox::GetHeightOffset(const Font& /* rFont */, Size& aSizeLogic )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1013cdf0e10cSrcweir     short nOffset = 0;
1014cdf0e10cSrcweir     aSizeLogic = Size(GetTextWidth('X'), GetTextHeight());
1015cdf0e10cSrcweir     if( GetEntryHeight() > aSizeLogic.Height() )
1016cdf0e10cSrcweir         nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
1017cdf0e10cSrcweir     return nOffset;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
SetEntryHeight(SvLBoxEntry * pEntry)1020cdf0e10cSrcweir void SvTreeListBox::SetEntryHeight( SvLBoxEntry* pEntry )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1023cdf0e10cSrcweir     short nHeight, nHeightMax=0;
1024cdf0e10cSrcweir     sal_uInt16 nCount = pEntry->ItemCount();
1025cdf0e10cSrcweir     sal_uInt16 nCur = 0;
1026cdf0e10cSrcweir     SvViewDataEntry* pViewData = GetViewDataEntry( pEntry );
1027cdf0e10cSrcweir     while( nCur < nCount )
1028cdf0e10cSrcweir     {
1029cdf0e10cSrcweir         SvLBoxItem* pItem = pEntry->GetItem( nCur );
1030cdf0e10cSrcweir         nHeight = (short)(pItem->GetSize( pViewData, nCur ).Height());
1031cdf0e10cSrcweir         if( nHeight > nHeightMax )
1032cdf0e10cSrcweir             nHeightMax = nHeight;
1033cdf0e10cSrcweir         nCur++;
1034cdf0e10cSrcweir     }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir     if( nHeightMax > nEntryHeight )
1037cdf0e10cSrcweir     {
1038cdf0e10cSrcweir         nEntryHeight = nHeightMax;
1039cdf0e10cSrcweir         SvLBox::SetFont( GetFont() );
1040cdf0e10cSrcweir         pImp->SetEntryHeight( nHeightMax );
1041cdf0e10cSrcweir     }
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir 
SetEntryHeight(short nHeight,sal_Bool bAlways)1044cdf0e10cSrcweir void SvTreeListBox::SetEntryHeight( short nHeight, sal_Bool bAlways )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir     if( bAlways || nHeight > nEntryHeight )
1049cdf0e10cSrcweir     {
1050cdf0e10cSrcweir         nEntryHeight = nHeight;
1051cdf0e10cSrcweir         if( nEntryHeight )
1052cdf0e10cSrcweir             nTreeFlags |= TREEFLAG_FIXEDHEIGHT;
1053cdf0e10cSrcweir         else
1054cdf0e10cSrcweir             nTreeFlags &= ~TREEFLAG_FIXEDHEIGHT;
1055cdf0e10cSrcweir         SvLBox::SetFont( GetFont() );
1056cdf0e10cSrcweir         pImp->SetEntryHeight( nHeight );
1057cdf0e10cSrcweir     }
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 
AdjustEntryHeight(const Image & rBmp)1061cdf0e10cSrcweir void SvTreeListBox::AdjustEntryHeight( const Image& rBmp )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1064cdf0e10cSrcweir     Size aSize;
1065cdf0e10cSrcweir     GetHeightOffset( rBmp, aSize );
1066cdf0e10cSrcweir     if( aSize.Height() > nEntryHeight )
1067cdf0e10cSrcweir     {
1068cdf0e10cSrcweir         nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
1069cdf0e10cSrcweir         pImp->SetEntryHeight( nEntryHeight );
1070cdf0e10cSrcweir     }
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir 
AdjustEntryHeight(const Font & rFont)1073cdf0e10cSrcweir void SvTreeListBox::AdjustEntryHeight( const Font& rFont )
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1076cdf0e10cSrcweir     Size aSize;
1077cdf0e10cSrcweir     GetHeightOffset( rFont, aSize );
1078cdf0e10cSrcweir     if( aSize.Height()  >  nEntryHeight )
1079cdf0e10cSrcweir     {
1080cdf0e10cSrcweir         nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
1081cdf0e10cSrcweir         pImp->SetEntryHeight( nEntryHeight );
1082cdf0e10cSrcweir     }
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
Expand(SvLBoxEntry * pParent)1085cdf0e10cSrcweir sal_Bool SvTreeListBox::Expand( SvLBoxEntry* pParent )
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1088cdf0e10cSrcweir     pHdlEntry = pParent;
1089cdf0e10cSrcweir     sal_Bool bExpanded = sal_False;
1090cdf0e10cSrcweir     sal_uInt16 nFlags;
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir     if( pParent->HasChildsOnDemand() )
1093cdf0e10cSrcweir         RequestingChilds( pParent );
1094cdf0e10cSrcweir     if( pParent->HasChilds() )
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir         nImpFlags |= SVLBOX_IS_EXPANDING;
1097cdf0e10cSrcweir         if( ExpandingHdl() )
1098cdf0e10cSrcweir         {
1099cdf0e10cSrcweir             bExpanded = sal_True;
1100cdf0e10cSrcweir             SvListView::Expand( pParent );
1101cdf0e10cSrcweir             pImp->EntryExpanded( pParent );
1102cdf0e10cSrcweir             pHdlEntry = pParent;
1103cdf0e10cSrcweir             ExpandedHdl();
1104cdf0e10cSrcweir         }
1105cdf0e10cSrcweir         nFlags = pParent->GetFlags();
1106cdf0e10cSrcweir         nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
1107cdf0e10cSrcweir         nFlags |= SV_ENTRYFLAG_HAD_CHILDREN;
1108cdf0e10cSrcweir         pParent->SetFlags( nFlags );
1109cdf0e10cSrcweir     }
1110cdf0e10cSrcweir     else
1111cdf0e10cSrcweir     {
1112cdf0e10cSrcweir         nFlags = pParent->GetFlags();
1113cdf0e10cSrcweir         nFlags |= SV_ENTRYFLAG_NO_NODEBMP;
1114cdf0e10cSrcweir         pParent->SetFlags( nFlags );
1115cdf0e10cSrcweir         GetModel()->InvalidateEntry( pParent ); // neu zeichnen
1116cdf0e10cSrcweir     }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     // --> OD 2009-04-01 #i92103#
1119cdf0e10cSrcweir     if ( bExpanded )
1120cdf0e10cSrcweir     {
1121cdf0e10cSrcweir         pImp->CallEventListeners( VCLEVENT_ITEM_EXPANDED, pParent );
1122cdf0e10cSrcweir     }
1123cdf0e10cSrcweir     // <--
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir     return bExpanded;
1126cdf0e10cSrcweir }
1127cdf0e10cSrcweir 
Collapse(SvLBoxEntry * pParent)1128cdf0e10cSrcweir sal_Bool SvTreeListBox::Collapse( SvLBoxEntry* pParent )
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1131cdf0e10cSrcweir     nImpFlags &= ~SVLBOX_IS_EXPANDING;
1132cdf0e10cSrcweir     pHdlEntry = pParent;
1133cdf0e10cSrcweir     sal_Bool bCollapsed = sal_False;
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir     if( ExpandingHdl() )
1136cdf0e10cSrcweir     {
1137cdf0e10cSrcweir         bCollapsed = sal_True;
1138cdf0e10cSrcweir         pImp->CollapsingEntry( pParent );
1139cdf0e10cSrcweir         SvListView::Collapse( pParent );
1140cdf0e10cSrcweir         pImp->EntryCollapsed( pParent );
1141cdf0e10cSrcweir         pHdlEntry = pParent;
1142cdf0e10cSrcweir         ExpandedHdl();
1143cdf0e10cSrcweir     }
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir     // --> OD 2009-04-01 #i92103#
1146cdf0e10cSrcweir     if ( bCollapsed )
1147cdf0e10cSrcweir     {
1148cdf0e10cSrcweir         pImp->CallEventListeners( VCLEVENT_ITEM_COLLAPSED, pParent );
1149cdf0e10cSrcweir     }
1150cdf0e10cSrcweir     // <--
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir     return bCollapsed;
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir 
Select(SvLBoxEntry * pEntry,sal_Bool bSelect)1155cdf0e10cSrcweir sal_Bool SvTreeListBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1158cdf0e10cSrcweir     DBG_ASSERT(pEntry,"Select: Null-Ptr");
1159cdf0e10cSrcweir     sal_Bool bRetVal = SvListView::Select( pEntry, bSelect );
1160cdf0e10cSrcweir     DBG_ASSERT(IsSelected(pEntry)==bSelect,"Select failed");
1161cdf0e10cSrcweir     if( bRetVal )
1162cdf0e10cSrcweir     {
1163cdf0e10cSrcweir         pImp->EntrySelected( pEntry, bSelect );
1164cdf0e10cSrcweir         pHdlEntry = pEntry;
1165cdf0e10cSrcweir         if( bSelect )
1166cdf0e10cSrcweir         {
1167cdf0e10cSrcweir             SelectHdl();
11682bfcd321SSteve Yin             // pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
11692bfcd321SSteve Yin             CallEventListeners( VCLEVENT_LISTBOX_TREESELECT, pEntry);
1170cdf0e10cSrcweir         }
1171cdf0e10cSrcweir         else
1172cdf0e10cSrcweir             DeselectHdl();
1173cdf0e10cSrcweir     }
1174cdf0e10cSrcweir     return bRetVal;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
SelectChilds(SvLBoxEntry * pParent,sal_Bool bSelect)1177cdf0e10cSrcweir sal_uLong SvTreeListBox::SelectChilds( SvLBoxEntry* pParent, sal_Bool bSelect )
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1180cdf0e10cSrcweir     pImp->DestroyAnchor();
1181cdf0e10cSrcweir     sal_uLong nRet = 0;
1182cdf0e10cSrcweir     if( !pParent->HasChilds() )
1183cdf0e10cSrcweir         return 0;
1184cdf0e10cSrcweir     sal_uInt16 nRefDepth = pModel->GetDepth( pParent );
1185cdf0e10cSrcweir     SvLBoxEntry* pChild = FirstChild( pParent );
1186cdf0e10cSrcweir     do {
1187cdf0e10cSrcweir         nRet++;
1188cdf0e10cSrcweir         Select( pChild, bSelect );
1189cdf0e10cSrcweir         pChild = Next( pChild );
1190cdf0e10cSrcweir     } while( pChild && pModel->GetDepth( pChild ) > nRefDepth );
1191cdf0e10cSrcweir     return nRet;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
SelectAll(sal_Bool bSelect,sal_Bool)1194cdf0e10cSrcweir void SvTreeListBox::SelectAll( sal_Bool bSelect, sal_Bool )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1197cdf0e10cSrcweir     pImp->SelAllDestrAnch(
1198cdf0e10cSrcweir         bSelect,
1199cdf0e10cSrcweir         sal_True,       // Anker loeschen,
1200cdf0e10cSrcweir         sal_True );     // auch bei SINGLE_SELECTION den Cursor deselektieren
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
ModelHasInsertedTree(SvListEntry * pEntry)1203cdf0e10cSrcweir void SvTreeListBox::ModelHasInsertedTree( SvListEntry* pEntry )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1206cdf0e10cSrcweir     sal_uInt16 nRefDepth = pModel->GetDepth( (SvLBoxEntry*)pEntry );
1207cdf0e10cSrcweir     SvLBoxEntry* pTmp = (SvLBoxEntry*)pEntry;
1208cdf0e10cSrcweir     do
1209cdf0e10cSrcweir     {
1210cdf0e10cSrcweir         ImpEntryInserted( pTmp );
1211cdf0e10cSrcweir         pTmp = Next( pTmp );
1212cdf0e10cSrcweir     } while( pTmp && nRefDepth < pModel->GetDepth( pTmp ) );
1213cdf0e10cSrcweir     pImp->TreeInserted( (SvLBoxEntry*)pEntry );
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir 
ModelHasInserted(SvListEntry * pEntry)1216cdf0e10cSrcweir void SvTreeListBox::ModelHasInserted( SvListEntry* pEntry )
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1219cdf0e10cSrcweir     ImpEntryInserted( (SvLBoxEntry*)pEntry );
1220cdf0e10cSrcweir     pImp->EntryInserted( (SvLBoxEntry*)pEntry );
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir 
ModelIsMoving(SvListEntry * pSource,SvListEntry *,sal_uLong)1223cdf0e10cSrcweir void SvTreeListBox::ModelIsMoving(SvListEntry* pSource,
1224cdf0e10cSrcweir                                         SvListEntry* /* pTargetParent */,
1225cdf0e10cSrcweir                                         sal_uLong /* nChildPos */ )
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1228cdf0e10cSrcweir     pImp->MovingEntry( (SvLBoxEntry*)pSource );
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir 
ModelHasMoved(SvListEntry * pSource)1231cdf0e10cSrcweir void SvTreeListBox::ModelHasMoved( SvListEntry* pSource )
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1234cdf0e10cSrcweir     pImp->EntryMoved( (SvLBoxEntry*)pSource );
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir 
ModelIsRemoving(SvListEntry * pEntry)1237cdf0e10cSrcweir void SvTreeListBox::ModelIsRemoving( SvListEntry* pEntry )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1240cdf0e10cSrcweir     if(pEdEntry == pEntry)
1241cdf0e10cSrcweir         pEdEntry = NULL;
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir     pImp->RemovingEntry( (SvLBoxEntry*)pEntry );
1244cdf0e10cSrcweir     NotifyRemoving( (SvLBoxEntry*)pEntry );
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
ModelHasRemoved(SvListEntry * pEntry)1247cdf0e10cSrcweir void SvTreeListBox::ModelHasRemoved( SvListEntry* pEntry  )
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1250cdf0e10cSrcweir     if ( pEntry == pHdlEntry)
1251cdf0e10cSrcweir         pHdlEntry = NULL;
1252cdf0e10cSrcweir     pImp->EntryRemoved();
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir 
SetCollapsedNodeBmp(const Image & rBmp,BmpColorMode _eMode)1255cdf0e10cSrcweir void SvTreeListBox::SetCollapsedNodeBmp( const Image& rBmp, BmpColorMode _eMode )
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1258cdf0e10cSrcweir     AdjustEntryHeight( rBmp );
1259cdf0e10cSrcweir     pImp->SetCollapsedNodeBmp( rBmp, _eMode );
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir 
SetExpandedNodeBmp(const Image & rBmp,BmpColorMode _eMode)1262cdf0e10cSrcweir void SvTreeListBox::SetExpandedNodeBmp( const Image& rBmp, BmpColorMode _eMode )
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1265cdf0e10cSrcweir     AdjustEntryHeight( rBmp );
1266cdf0e10cSrcweir     pImp->SetExpandedNodeBmp( rBmp, _eMode );
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 
SetFont(const Font & rFont)1270cdf0e10cSrcweir void SvTreeListBox::SetFont( const Font& rFont )
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1273cdf0e10cSrcweir     Font aTempFont( rFont );
1274cdf0e10cSrcweir     aTempFont.SetTransparent( sal_True );
1275cdf0e10cSrcweir     Control::SetFont( aTempFont );
1276cdf0e10cSrcweir     AdjustEntryHeight( aTempFont );
1277cdf0e10cSrcweir     // immer Invalidieren, sonst fallen wir
1278cdf0e10cSrcweir     // bei SetEntryHeight auf die Nase
1279cdf0e10cSrcweir     RecalcViewData();
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 
Paint(const Rectangle & rRect)1283cdf0e10cSrcweir void SvTreeListBox::Paint( const Rectangle& rRect )
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1286cdf0e10cSrcweir     SvLBox::Paint( rRect );
1287cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_RECALCTABS )
1288cdf0e10cSrcweir         SetTabs();
1289cdf0e10cSrcweir     pImp->Paint( rRect );
12902bfcd321SSteve Yin     //Solution:Add visual focus draw
12912bfcd321SSteve Yin     if( !SvLBox::First() )
12922bfcd321SSteve Yin     {
12932bfcd321SSteve Yin         if( HasFocus() )
12942bfcd321SSteve Yin         {
12952bfcd321SSteve Yin             long tempHeight = GetTextHeight();
12962bfcd321SSteve Yin             Rectangle tempRect(
12972bfcd321SSteve Yin                                 Point(0,0),Size(GetSizePixel().Width(),tempHeight)
12982bfcd321SSteve Yin                                );
12992bfcd321SSteve Yin             ShowFocus(tempRect);
13002bfcd321SSteve Yin         }
13012bfcd321SSteve Yin 
13022bfcd321SSteve Yin         else{
13032bfcd321SSteve Yin             HideFocus();
13042bfcd321SSteve Yin         }
13052bfcd321SSteve Yin     }
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)1308cdf0e10cSrcweir void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1311cdf0e10cSrcweir     pImp->MouseButtonDown( rMEvt );
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)1314cdf0e10cSrcweir void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1317cdf0e10cSrcweir     pImp->MouseButtonUp( rMEvt );
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)1320cdf0e10cSrcweir void SvTreeListBox::MouseMove( const MouseEvent& rMEvt )
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1323cdf0e10cSrcweir     pImp->MouseMove( rMEvt );
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir 
SetUpdateMode(sal_Bool bUpdate)1327cdf0e10cSrcweir void SvTreeListBox::SetUpdateMode( sal_Bool bUpdate )
1328cdf0e10cSrcweir {
1329cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1330cdf0e10cSrcweir     pImp->SetUpdateMode( bUpdate );
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir 
SetUpdateModeFast(sal_Bool bUpdate)1333cdf0e10cSrcweir void SvTreeListBox::SetUpdateModeFast( sal_Bool bUpdate )
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1336cdf0e10cSrcweir     pImp->SetUpdateModeFast( bUpdate );
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir 
SetSpaceBetweenEntries(short nOffsLogic)1339cdf0e10cSrcweir void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1342cdf0e10cSrcweir     if( nOffsLogic != nEntryHeightOffs )
1343cdf0e10cSrcweir     {
1344cdf0e10cSrcweir         nEntryHeight = nEntryHeight - nEntryHeightOffs;
1345cdf0e10cSrcweir         nEntryHeightOffs = (short)nOffsLogic;
1346cdf0e10cSrcweir         nEntryHeight = nEntryHeight + nOffsLogic;
1347cdf0e10cSrcweir         AdjustEntryHeight( GetFont() );
1348cdf0e10cSrcweir         RecalcViewData();
1349cdf0e10cSrcweir         pImp->SetEntryHeight( nEntryHeight );
1350cdf0e10cSrcweir     }
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
SetCursor(SvLBoxEntry * pEntry,sal_Bool bForceNoSelect)1353cdf0e10cSrcweir void SvTreeListBox::SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1356cdf0e10cSrcweir     pImp->SetCursor(pEntry, bForceNoSelect);
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir 
SetCurEntry(SvLBoxEntry * pEntry)1359cdf0e10cSrcweir void SvTreeListBox::SetCurEntry( SvLBoxEntry* pEntry )
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1362cdf0e10cSrcweir     pImp->SetCurEntry( pEntry );
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir 
GetCollapsedNodeBmp(BmpColorMode _eMode) const1365cdf0e10cSrcweir Image SvTreeListBox::GetCollapsedNodeBmp( BmpColorMode _eMode ) const
1366cdf0e10cSrcweir {
1367cdf0e10cSrcweir     return pImp->GetCollapsedNodeBmp( _eMode );
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir 
GetExpandedNodeBmp(BmpColorMode _eMode) const1370cdf0e10cSrcweir Image SvTreeListBox::GetExpandedNodeBmp( BmpColorMode _eMode ) const
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir     return pImp->GetExpandedNodeBmp( _eMode );
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir 
GetEntryPosition(SvLBoxEntry * pEntry) const1375cdf0e10cSrcweir Point SvTreeListBox::GetEntryPosition( SvLBoxEntry* pEntry ) const
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir     return pImp->GetEntryPosition( pEntry );
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir 
ShowEntry(SvLBoxEntry * pEntry)1380cdf0e10cSrcweir void SvTreeListBox::ShowEntry( SvLBoxEntry* pEntry )
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir     MakeVisible( pEntry );
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir 
MakeVisible(SvLBoxEntry * pEntry)1385cdf0e10cSrcweir void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir     pImp->MakeVisible(pEntry);
1388cdf0e10cSrcweir }
1389cdf0e10cSrcweir 
MakeVisible(SvLBoxEntry * pEntry,sal_Bool bMoveToTop)1390cdf0e10cSrcweir void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir     pImp->MakeVisible( pEntry, bMoveToTop );
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir 
ModelHasEntryInvalidated(SvListEntry * pEntry)1395cdf0e10cSrcweir void SvTreeListBox::ModelHasEntryInvalidated( SvListEntry* pEntry )
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1398cdf0e10cSrcweir     // die einzelnen Items des Entries reinitialisieren
1399cdf0e10cSrcweir     SvLBox::ModelHasEntryInvalidated( pEntry );
1400cdf0e10cSrcweir     // repainten
1401cdf0e10cSrcweir     pImp->InvalidateEntry( (SvLBoxEntry*)pEntry );
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
EditItemText(SvLBoxEntry * pEntry,SvLBoxString * pItem,const Selection & rSelection)1404cdf0e10cSrcweir void SvTreeListBox::EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem,
1405cdf0e10cSrcweir     const Selection& rSelection )
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1408cdf0e10cSrcweir     DBG_ASSERT(pEntry&&pItem,"EditItemText: Bad params");
1409cdf0e10cSrcweir     if( IsSelected( pEntry ))
1410cdf0e10cSrcweir     {
1411cdf0e10cSrcweir         pImp->ShowCursor( sal_False );
1412cdf0e10cSrcweir         SvListView::Select( pEntry, sal_False );
1413cdf0e10cSrcweir         PaintEntry( pEntry );
1414cdf0e10cSrcweir         SvListView::Select( pEntry, sal_True );
1415cdf0e10cSrcweir         pImp->ShowCursor( sal_True );
1416cdf0e10cSrcweir     }
1417cdf0e10cSrcweir     pEdEntry = pEntry;
1418cdf0e10cSrcweir     pEdItem = pItem;
1419cdf0e10cSrcweir     SvLBoxTab* pTab = GetTab( pEntry, pItem );
1420cdf0e10cSrcweir     DBG_ASSERT(pTab,"EditItemText:Tab not found");
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir     Size aItemSize( pItem->GetSize(this, pEntry) );
1423cdf0e10cSrcweir     Point aPos = GetEntryPosition( pEntry );
1424cdf0e10cSrcweir     aPos.Y() += ( nEntryHeight - aItemSize.Height() ) / 2;
1425cdf0e10cSrcweir     aPos.X() = GetTabPos( pEntry, pTab );
1426cdf0e10cSrcweir     long nOutputWidth = pImp->GetOutputSize().Width();
1427cdf0e10cSrcweir     Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() );
1428cdf0e10cSrcweir     sal_uInt16 nPos = aTabs.GetPos( pTab );
1429cdf0e10cSrcweir     if( nPos+1 < aTabs.Count() )
1430cdf0e10cSrcweir     {
1431cdf0e10cSrcweir         SvLBoxTab* pRightTab = (SvLBoxTab*)aTabs.GetObject( nPos + 1 );
1432cdf0e10cSrcweir         long nRight = GetTabPos( pEntry, pRightTab );
1433cdf0e10cSrcweir         if( nRight <= nOutputWidth )
1434cdf0e10cSrcweir             aSize.Width() = nRight - aPos.X();
1435cdf0e10cSrcweir     }
1436cdf0e10cSrcweir     Point aOrigin( GetMapMode().GetOrigin() );
1437cdf0e10cSrcweir     aPos += aOrigin; // in Win-Koord umrechnen
1438cdf0e10cSrcweir     aSize.Width() -= aOrigin.X();
1439cdf0e10cSrcweir     Rectangle aRect( aPos, aSize );
1440cdf0e10cSrcweir #ifdef OS2
1441cdf0e10cSrcweir     // Platz lassen fuer WB_BORDER
1442cdf0e10cSrcweir     aRect.Left() -= 2;
1443cdf0e10cSrcweir     aRect.Top() -= 3;
1444cdf0e10cSrcweir     aRect.Bottom() += 3;
1445cdf0e10cSrcweir #endif
1446cdf0e10cSrcweir     EditText( pItem->GetText(), aRect, rSelection );
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir 
CancelEditing()1449cdf0e10cSrcweir void SvTreeListBox::CancelEditing()
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1452cdf0e10cSrcweir     SvLBox::CancelTextEditing();
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir 
EditEntry(SvLBoxEntry * pEntry)1455cdf0e10cSrcweir void SvTreeListBox::EditEntry( SvLBoxEntry* pEntry )
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir     pImp->aEditClickPos = Point( -1, -1 );
1458cdf0e10cSrcweir     ImplEditEntry( pEntry );
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
ImplEditEntry(SvLBoxEntry * pEntry)1461cdf0e10cSrcweir void SvTreeListBox::ImplEditEntry( SvLBoxEntry* pEntry )
1462cdf0e10cSrcweir {
1463cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1464cdf0e10cSrcweir     if( IsEditingActive() )
1465cdf0e10cSrcweir         EndEditing();
1466cdf0e10cSrcweir     if( !pEntry )
1467cdf0e10cSrcweir         pEntry = GetCurEntry();
1468cdf0e10cSrcweir     if( pEntry )
1469cdf0e10cSrcweir     {
1470cdf0e10cSrcweir         long nClickX = pImp->aEditClickPos.X();
1471cdf0e10cSrcweir         bool bIsMouseTriggered = nClickX >= 0;
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir         SvLBoxString* pItem = NULL;
1474cdf0e10cSrcweir         sal_uInt16 nCount = pEntry->ItemCount();
1475cdf0e10cSrcweir         for( sal_uInt16 i = 0 ; i < nCount ; i++ )
1476cdf0e10cSrcweir         {
1477cdf0e10cSrcweir             SvLBoxItem* pTmpItem = pEntry->GetItem( i );
1478cdf0e10cSrcweir             if( pTmpItem->IsA() != SV_ITEM_ID_LBOXSTRING )
1479cdf0e10cSrcweir                 continue;
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir             SvLBoxTab* pTab = GetTab( pEntry, pTmpItem );
1482cdf0e10cSrcweir             long nTabPos = pTab->GetPos();
1483cdf0e10cSrcweir             long nNextTabPos = -1;
1484cdf0e10cSrcweir             if( i < nCount - 1 )
1485cdf0e10cSrcweir             {
1486cdf0e10cSrcweir                 SvLBoxItem* pNextItem = pEntry->GetItem( i + 1 );
1487cdf0e10cSrcweir                 SvLBoxTab* pNextTab = GetTab( pEntry, pNextItem );
1488cdf0e10cSrcweir                 nNextTabPos = pNextTab->GetPos();
1489cdf0e10cSrcweir             }
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir             if( pTab && pTab->IsEditable() )
1492cdf0e10cSrcweir             {
1493cdf0e10cSrcweir                 if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) )
1494cdf0e10cSrcweir                 {
1495cdf0e10cSrcweir                     pItem = static_cast<SvLBoxString*>( pTmpItem );
1496cdf0e10cSrcweir                     break;
1497cdf0e10cSrcweir                 }
1498cdf0e10cSrcweir             }
1499cdf0e10cSrcweir         }
1500cdf0e10cSrcweir 
1501cdf0e10cSrcweir         Selection aSel( SELECTION_MIN, SELECTION_MAX );
1502cdf0e10cSrcweir         if( pItem && EditingEntry( pEntry, aSel ) )
1503cdf0e10cSrcweir         {
1504cdf0e10cSrcweir             SelectAll( sal_False );
1505cdf0e10cSrcweir             MakeVisible( pEntry );
1506cdf0e10cSrcweir             EditItemText( pEntry, pItem, aSel );
1507cdf0e10cSrcweir         }
1508cdf0e10cSrcweir     }
1509cdf0e10cSrcweir }
1510cdf0e10cSrcweir 
AreChildrenTransient() const1511cdf0e10cSrcweir sal_Bool SvTreeListBox::AreChildrenTransient() const
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir     return pImp->AreChildrenTransient();
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir 
SetChildrenNotTransient()1516cdf0e10cSrcweir void SvTreeListBox::SetChildrenNotTransient()
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir     pImp->SetChildrenNotTransient();
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir 
EditedText(const XubString & rStr)1521cdf0e10cSrcweir void SvTreeListBox::EditedText( const XubString& rStr )
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1525cdf0e10cSrcweir     if(pEdEntry) // we have to check if this entry is null that means that it is removed while editing
1526cdf0e10cSrcweir     {
1527cdf0e10cSrcweir         Point aPos = GetEntryPosition( pEdEntry );
1528cdf0e10cSrcweir         if( EditedEntry( pEdEntry, rStr ) )
1529cdf0e10cSrcweir         {
1530cdf0e10cSrcweir             ((SvLBoxString*)pEdItem)->SetText( pEdEntry, rStr );
1531cdf0e10cSrcweir             pModel->InvalidateEntry( pEdEntry );
1532cdf0e10cSrcweir         }
1533cdf0e10cSrcweir         //if( GetSelectionMode() == SINGLE_SELECTION )
1534cdf0e10cSrcweir         //{
1535cdf0e10cSrcweir         if( GetSelectionCount() == 0 )
1536cdf0e10cSrcweir             Select( pEdEntry );
1537cdf0e10cSrcweir         if( GetSelectionMode() == MULTIPLE_SELECTION && !GetCurEntry() )
1538cdf0e10cSrcweir             SetCurEntry( pEdEntry );
1539cdf0e10cSrcweir         //}
1540cdf0e10cSrcweir     }
1541cdf0e10cSrcweir }
1542cdf0e10cSrcweir 
EditingRequest(SvLBoxEntry * pEntry,SvLBoxItem * pItem,const Point &)1543cdf0e10cSrcweir void SvTreeListBox::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
1544cdf0e10cSrcweir                                     const Point& )
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1547cdf0e10cSrcweir     if( IsEditingActive() )
1548cdf0e10cSrcweir         EndEditing();
1549cdf0e10cSrcweir     if( pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
1550cdf0e10cSrcweir     {
1551cdf0e10cSrcweir         Selection aSel( SELECTION_MIN, SELECTION_MAX );
1552cdf0e10cSrcweir         if( EditingEntry( pEntry, aSel ) )
1553cdf0e10cSrcweir         {
1554cdf0e10cSrcweir             SelectAll( sal_False );
1555cdf0e10cSrcweir             EditItemText( pEntry, (SvLBoxString*)pItem, aSel );
1556cdf0e10cSrcweir         }
1557cdf0e10cSrcweir     }
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 
GetDropTarget(const Point & rPos)1562cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos )
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1565cdf0e10cSrcweir     // Scrollen
1566cdf0e10cSrcweir     if( rPos.Y() < 12 )
1567cdf0e10cSrcweir     {
1568cdf0e10cSrcweir         SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
1569cdf0e10cSrcweir         ScrollOutputArea( +1 );
1570cdf0e10cSrcweir     }
1571cdf0e10cSrcweir     else
1572cdf0e10cSrcweir     {
1573cdf0e10cSrcweir         Size aSize( pImp->GetOutputSize() );
1574cdf0e10cSrcweir         if( rPos.Y() > aSize.Height() - 12 )
1575cdf0e10cSrcweir         {
1576cdf0e10cSrcweir             SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
1577cdf0e10cSrcweir             ScrollOutputArea( -1 );
1578cdf0e10cSrcweir         }
1579cdf0e10cSrcweir     }
1580cdf0e10cSrcweir 
1581cdf0e10cSrcweir     SvLBoxEntry* pTarget = pImp->GetEntry( rPos );
1582cdf0e10cSrcweir     // bei Droppen in leere Flaeche -> den letzten Eintrag nehmen
1583cdf0e10cSrcweir     if( !pTarget )
1584cdf0e10cSrcweir         return (SvLBoxEntry*)LastVisible();
1585cdf0e10cSrcweir     else if( (GetDragDropMode() & SV_DRAGDROP_ENABLE_TOP) &&
1586cdf0e10cSrcweir              pTarget == First() && rPos.Y() < 6 )
1587cdf0e10cSrcweir         return 0;
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir     return pTarget;
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir 
GetEntry(const Point & rPos,sal_Bool bHit) const1593cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetEntry( const Point& rPos, sal_Bool bHit ) const
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1596cdf0e10cSrcweir     SvLBoxEntry* pEntry = pImp->GetEntry( rPos );
1597cdf0e10cSrcweir     if( pEntry && bHit )
1598cdf0e10cSrcweir     {
1599cdf0e10cSrcweir         long nLine = pImp->GetEntryLine( pEntry );
1600cdf0e10cSrcweir         if( !(pImp->EntryReallyHit( pEntry, rPos, nLine)) )
1601cdf0e10cSrcweir             return 0;
1602cdf0e10cSrcweir     }
1603cdf0e10cSrcweir     return pEntry;
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir 
GetCurEntry() const1606cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetCurEntry() const
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1609cdf0e10cSrcweir     return pImp->GetCurEntry();
1610cdf0e10cSrcweir }
1611cdf0e10cSrcweir 
ImplInitStyle()1612cdf0e10cSrcweir void SvTreeListBox::ImplInitStyle()
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir     const WinBits nWindowStyle = GetStyle();
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir     nTreeFlags |= TREEFLAG_RECALCTABS;
1619cdf0e10cSrcweir     if( nWindowStyle & WB_SORT )
1620cdf0e10cSrcweir     {
1621cdf0e10cSrcweir         GetModel()->SetSortMode( SortAscending );
1622cdf0e10cSrcweir         GetModel()->SetCompareHdl( LINK(this,SvTreeListBox,DefaultCompare));
1623cdf0e10cSrcweir     }
1624cdf0e10cSrcweir     else
1625cdf0e10cSrcweir     {
1626cdf0e10cSrcweir         GetModel()->SetSortMode( SortNone );
1627cdf0e10cSrcweir         GetModel()->SetCompareHdl( Link() );
1628cdf0e10cSrcweir     }
1629cdf0e10cSrcweir     pImp->SetStyle( nWindowStyle );
1630cdf0e10cSrcweir     pImp->Resize();
1631cdf0e10cSrcweir     Invalidate();
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir 
PaintEntry(SvLBoxEntry * pEntry)1634cdf0e10cSrcweir void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry )
1635cdf0e10cSrcweir {
1636cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1637cdf0e10cSrcweir     DBG_ASSERT(pEntry,"PaintEntry:No Entry");
1638cdf0e10cSrcweir     if( pEntry )
1639cdf0e10cSrcweir         pImp->PaintEntry( pEntry );
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir 
InvalidateEntry(SvLBoxEntry * pEntry)1642cdf0e10cSrcweir void SvTreeListBox::InvalidateEntry( SvLBoxEntry* pEntry )
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1645cdf0e10cSrcweir     DBG_ASSERT(pEntry,"InvalidateEntry:No Entry");
1646cdf0e10cSrcweir     if( pEntry )
1647cdf0e10cSrcweir     {
1648cdf0e10cSrcweir         GetModel()->InvalidateEntry( pEntry );
1649cdf0e10cSrcweir     //  pImp->InvalidateEntry( pEntry );
1650cdf0e10cSrcweir     }
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir 
PaintEntry(SvLBoxEntry * pEntry,long nLine,sal_uInt16 nTabFlags)1654cdf0e10cSrcweir long SvTreeListBox::PaintEntry(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags)
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir     return PaintEntry1(pEntry,nLine,nTabFlags);
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir #define SV_TAB_BORDER 8
1660cdf0e10cSrcweir 
PaintEntry1(SvLBoxEntry * pEntry,long nLine,sal_uInt16 nTabFlags,sal_Bool bHasClipRegion)1661cdf0e10cSrcweir long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags,
1662cdf0e10cSrcweir     sal_Bool bHasClipRegion )
1663cdf0e10cSrcweir {
1664cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir     Rectangle aRect; // multi purpose
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir     sal_Bool bHorSBar = pImp->HasHorScrollBar();
1669cdf0e10cSrcweir     PreparePaint( pEntry );
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir     // #97680# ------------------
1672cdf0e10cSrcweir     pImp->UpdateContextBmpWidthMax( pEntry );
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_RECALCTABS )
1675cdf0e10cSrcweir         SetTabs();
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir     short nTempEntryHeight = GetEntryHeight();
1678cdf0e10cSrcweir     long nWidth = pImp->GetOutputSize().Width();
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir     // wurde innerhalb des PreparePaints die horizontale ScrollBar
1681cdf0e10cSrcweir     // angeschaltet? Wenn ja, muss die ClipRegion neu gesetzt werden
1682cdf0e10cSrcweir     if( !bHorSBar && pImp->HasHorScrollBar() )
1683cdf0e10cSrcweir         SetClipRegion( Region(pImp->GetClipRegionRect()) );
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir     Point aEntryPos( GetMapMode().GetOrigin() );
1686cdf0e10cSrcweir     aEntryPos.X() *= -1; // Umrechnung Dokumentkoord.
1687cdf0e10cSrcweir     long nMaxRight = nWidth + aEntryPos.X() - 1;
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir     Color aBackupTextColor( GetTextColor() );
1690cdf0e10cSrcweir     Font aBackupFont( GetFont() );
1691cdf0e10cSrcweir     Color aBackupColor = GetFillColor();
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir     bool bCurFontIsSel = false;
1694cdf0e10cSrcweir     sal_Bool bInUse = pEntry->HasInUseEmphasis();
1695cdf0e10cSrcweir     // wenn eine ClipRegion von aussen gesetzt wird, dann
1696cdf0e10cSrcweir     // diese nicht zuruecksetzen
1697cdf0e10cSrcweir     const WinBits nWindowStyle = GetStyle();
1698cdf0e10cSrcweir     const sal_Bool bResetClipRegion = !bHasClipRegion;
1699cdf0e10cSrcweir     const sal_Bool bHideSelection = ((nWindowStyle & WB_HIDESELECTION) && !HasFocus())!=0;
1700cdf0e10cSrcweir     const StyleSettings& rSettings = GetSettings().GetStyleSettings();
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir     Font aHighlightFont( GetFont() );
1703cdf0e10cSrcweir     const Color aHighlightTextColor( rSettings.GetHighlightTextColor() );
1704cdf0e10cSrcweir     aHighlightFont.SetColor( aHighlightTextColor );
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir     Size aRectSize( 0, nTempEntryHeight );
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir     if( !bHasClipRegion && nWindowStyle & WB_HSCROLL )
1709cdf0e10cSrcweir     {
1710cdf0e10cSrcweir         SetClipRegion( Region(pImp->GetClipRegionRect()) );
1711cdf0e10cSrcweir         bHasClipRegion = sal_True;
1712cdf0e10cSrcweir     }
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir     SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry );
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
1717cdf0e10cSrcweir     sal_uInt16 nItemCount = pEntry->ItemCount();
1718cdf0e10cSrcweir     sal_uInt16 nCurTab = 0;
1719cdf0e10cSrcweir     sal_uInt16 nCurItem = 0;
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir     while( nCurTab < nTabCount && nCurItem < nItemCount )
1722cdf0e10cSrcweir     {
1723cdf0e10cSrcweir         SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nCurTab );
1724cdf0e10cSrcweir         sal_uInt16 nNextTab = nCurTab + 1;
1725cdf0e10cSrcweir         SvLBoxTab* pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0;
1726cdf0e10cSrcweir         SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0;
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir         sal_uInt16 nFlags = pTab->nFlags;
1729cdf0e10cSrcweir         Size aSize( pItem->GetSize( pViewDataEntry, nCurItem ));
1730cdf0e10cSrcweir         long nTabPos = GetTabPos( pEntry, pTab );
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir         long nNextTabPos;
1733cdf0e10cSrcweir         if( pNextTab )
1734cdf0e10cSrcweir             nNextTabPos = GetTabPos( pEntry, pNextTab );
1735cdf0e10cSrcweir         else
1736cdf0e10cSrcweir         {
1737cdf0e10cSrcweir             nNextTabPos = nMaxRight;
1738cdf0e10cSrcweir             if( nTabPos > nMaxRight )
1739cdf0e10cSrcweir                 nNextTabPos += 50;
1740cdf0e10cSrcweir         }
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir         long nX;
1743cdf0e10cSrcweir         if( pTab->nFlags & SV_LBOXTAB_ADJUST_RIGHT )
1744cdf0e10cSrcweir             //verhindern, das rechter Rand von der Tabtrennung abgeschnitten wird
1745cdf0e10cSrcweir             nX = nTabPos + pTab->CalcOffset(aSize.Width(), (nNextTabPos-SV_TAB_BORDER-1) -nTabPos);
1746cdf0e10cSrcweir         else
1747cdf0e10cSrcweir             nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos-nTabPos);
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir         if( nFlags & nTabFlags )
1750cdf0e10cSrcweir         {
1751cdf0e10cSrcweir             if( !bHasClipRegion && nX + aSize.Width() >= nMaxRight )
1752cdf0e10cSrcweir             {
1753cdf0e10cSrcweir                 SetClipRegion( Region(pImp->GetClipRegionRect()) );
1754cdf0e10cSrcweir                 bHasClipRegion = sal_True;
1755cdf0e10cSrcweir             }
1756cdf0e10cSrcweir             aEntryPos.X() = nX;
1757cdf0e10cSrcweir             aEntryPos.Y() = nLine;
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir             // Hintergrund-Muster & Farbe bestimmen
1760cdf0e10cSrcweir 
1761cdf0e10cSrcweir             Wallpaper aWallpaper = GetBackground();
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir             int bSelTab = nFlags & SV_LBOXTAB_SHOW_SELECTION;
1764cdf0e10cSrcweir             sal_uInt16 nItemType = pItem->IsA();
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir             if ( pViewDataEntry->IsSelected() && bSelTab && !pViewDataEntry->IsCursored() )
1767cdf0e10cSrcweir             {
1768cdf0e10cSrcweir                 Color aNewWallColor = rSettings.GetHighlightColor();
1769cdf0e10cSrcweir                 if ( !bInUse || nItemType != SV_ITEM_ID_LBOXCONTEXTBMP )
1770cdf0e10cSrcweir                 {
1771cdf0e10cSrcweir                     // if the face color is bright then the deactive color is also bright
1772cdf0e10cSrcweir                     // -> so you can't see any deactive selection
1773cdf0e10cSrcweir                     if ( bHideSelection && !rSettings.GetFaceColor().IsBright() &&
1774cdf0e10cSrcweir                          aWallpaper.GetColor().IsBright() != rSettings.GetDeactiveColor().IsBright() )
1775cdf0e10cSrcweir                         aNewWallColor = rSettings.GetDeactiveColor();
1776cdf0e10cSrcweir                     // set font color to highlight
1777cdf0e10cSrcweir                     if ( !bCurFontIsSel )
1778cdf0e10cSrcweir                     {
1779cdf0e10cSrcweir                         SetTextColor( aHighlightTextColor );
1780cdf0e10cSrcweir                         SetFont( aHighlightFont );
1781cdf0e10cSrcweir                         bCurFontIsSel = true;
1782cdf0e10cSrcweir                     }
1783cdf0e10cSrcweir                 }
1784cdf0e10cSrcweir                 aWallpaper.SetColor( aNewWallColor );
1785cdf0e10cSrcweir             }
1786cdf0e10cSrcweir             else  // keine Selektion
1787cdf0e10cSrcweir             {
1788cdf0e10cSrcweir                 if( bInUse && nItemType == SV_ITEM_ID_LBOXCONTEXTBMP )
1789cdf0e10cSrcweir                     aWallpaper.SetColor( rSettings.GetFieldColor() );
1790cdf0e10cSrcweir                 else if( bCurFontIsSel )
1791cdf0e10cSrcweir                 {
1792cdf0e10cSrcweir                     bCurFontIsSel = false;
1793cdf0e10cSrcweir                     SetTextColor( aBackupTextColor );
1794cdf0e10cSrcweir                     SetFont( aBackupFont );
1795cdf0e10cSrcweir                 }
1796cdf0e10cSrcweir             }
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir             // Hintergrund zeichnen
1799cdf0e10cSrcweir             if( !(nTreeFlags & TREEFLAG_USESEL))
1800cdf0e10cSrcweir             {
1801cdf0e10cSrcweir                 // nur den Bereich zeichnen, den das Item einnimmt
1802cdf0e10cSrcweir                 aRectSize.Width() = aSize.Width();
1803cdf0e10cSrcweir                 aRect.SetPos( aEntryPos );
1804cdf0e10cSrcweir                 aRect.SetSize( aRectSize );
1805cdf0e10cSrcweir             }
1806cdf0e10cSrcweir             else
1807cdf0e10cSrcweir             {
1808cdf0e10cSrcweir                 // vom aktuellen bis zum naechsten Tab zeichnen
1809cdf0e10cSrcweir                 if( nCurTab != 0 )
1810cdf0e10cSrcweir                     aRect.Left() = nTabPos;
1811cdf0e10cSrcweir                 else
1812cdf0e10cSrcweir                     // beim nullten Tab immer ab Spalte 0 zeichnen
1813cdf0e10cSrcweir                     // (sonst Probleme bei Tabs mit Zentrierung)
1814cdf0e10cSrcweir                     aRect.Left() = 0;
1815cdf0e10cSrcweir                 aRect.Top() = nLine;
1816cdf0e10cSrcweir                 aRect.Bottom() = nLine + nTempEntryHeight - 1;
1817cdf0e10cSrcweir                 if( pNextTab )
1818cdf0e10cSrcweir                 {
1819cdf0e10cSrcweir                     long nRight;
1820cdf0e10cSrcweir                     nRight = GetTabPos(pEntry,pNextTab)-1;
1821cdf0e10cSrcweir                     if( nRight > nMaxRight )
1822cdf0e10cSrcweir                         nRight = nMaxRight;
1823cdf0e10cSrcweir                     aRect.Right() = nRight;
1824cdf0e10cSrcweir                 }
1825cdf0e10cSrcweir                 else
1826cdf0e10cSrcweir                     aRect.Right() = nMaxRight;
1827cdf0e10cSrcweir             }
1828cdf0e10cSrcweir             // bei anwenderdefinierter Selektion, die bei einer Tabposition
1829cdf0e10cSrcweir             // groesser 0 beginnt den Hintergrund des 0.ten Items nicht
1830cdf0e10cSrcweir             // fuellen, da sonst z.B. TablistBoxen mit Linien nicht
1831cdf0e10cSrcweir             // realisiert werden koennen.
1832cdf0e10cSrcweir             if( !(nCurTab==0 && (nTreeFlags & TREEFLAG_USESEL) && nFirstSelTab) )
1833cdf0e10cSrcweir             {
1834cdf0e10cSrcweir                 SetFillColor( aWallpaper.GetColor() );
1835cdf0e10cSrcweir                 // Bei kleinen hor. Resizes tritt dieser Fall auf
1836cdf0e10cSrcweir                 if( aRect.Left() < aRect.Right() )
1837cdf0e10cSrcweir                     DrawRect( aRect );
1838cdf0e10cSrcweir             }
1839cdf0e10cSrcweir             // Item zeichnen
1840cdf0e10cSrcweir             // vertikal zentrieren
1841cdf0e10cSrcweir             aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2;
1842cdf0e10cSrcweir             pItem->Paint( aEntryPos, *this, pViewDataEntry->GetFlags(), pEntry );
1843cdf0e10cSrcweir 
1844cdf0e10cSrcweir             // Trennungslinie zwischen Tabs
1845cdf0e10cSrcweir             if( pNextTab && pItem->IsA() == SV_ITEM_ID_LBOXSTRING &&
1846cdf0e10cSrcweir                 // nicht am rechten Fensterrand!
1847cdf0e10cSrcweir                 aRect.Right() < nMaxRight )
1848cdf0e10cSrcweir             {
1849cdf0e10cSrcweir                 aRect.Left() = aRect.Right() - SV_TAB_BORDER;
1850cdf0e10cSrcweir                 DrawRect( aRect );
1851cdf0e10cSrcweir             }
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir             SetFillColor( aBackupColor );
1854cdf0e10cSrcweir         }
1855cdf0e10cSrcweir         nCurItem++;
1856cdf0e10cSrcweir         nCurTab++;
1857cdf0e10cSrcweir     }
1858cdf0e10cSrcweir     if( pViewDataEntry->IsCursored() && !HasFocus() )
1859cdf0e10cSrcweir     {
1860cdf0e10cSrcweir         // Cursor-Emphasis
1861cdf0e10cSrcweir         SetFillColor();
1862cdf0e10cSrcweir         Color aOldLineColor = GetLineColor();
1863cdf0e10cSrcweir         SetLineColor( Color( COL_BLACK ) );
1864cdf0e10cSrcweir         aRect = GetFocusRect( pEntry, nLine );
1865cdf0e10cSrcweir         aRect.Top()++;
1866cdf0e10cSrcweir         aRect.Bottom()--;
1867cdf0e10cSrcweir         DrawRect( aRect );
1868cdf0e10cSrcweir         SetLineColor( aOldLineColor );
1869cdf0e10cSrcweir         SetFillColor( aBackupColor );
1870cdf0e10cSrcweir     }
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir     if( bCurFontIsSel )
1873cdf0e10cSrcweir     {
1874cdf0e10cSrcweir         SetTextColor( aBackupTextColor );
1875cdf0e10cSrcweir         SetFont( aBackupFont );
1876cdf0e10cSrcweir     }
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir     sal_uInt16 nFirstDynTabPos;
1879cdf0e10cSrcweir     SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab( nFirstDynTabPos );
1880cdf0e10cSrcweir     long nDynTabPos = GetTabPos( pEntry, pFirstDynamicTab );
1881cdf0e10cSrcweir     nDynTabPos += pImp->nNodeBmpTabDistance;
1882cdf0e10cSrcweir     nDynTabPos += pImp->nNodeBmpWidth / 2;
1883cdf0e10cSrcweir     nDynTabPos += 4; // 4 Pixel Reserve, damit die Node-Bitmap
1884cdf0e10cSrcweir                      // nicht zu nah am naechsten Tab steht
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir     if( (!(pEntry->GetFlags() & SV_ENTRYFLAG_NO_NODEBMP)) &&
1887cdf0e10cSrcweir         (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab &&
1888cdf0e10cSrcweir         ( pEntry->HasChilds() || pEntry->HasChildsOnDemand() ) )
1889cdf0e10cSrcweir     {
1890cdf0e10cSrcweir         // ersten festen Tab suchen, und pruefen ob die Node-Bitmap
1891cdf0e10cSrcweir         // in ihn hineinragt
1892cdf0e10cSrcweir         sal_uInt16 nNextTab = nFirstDynTabPos;
1893cdf0e10cSrcweir         SvLBoxTab* pNextTab;
1894cdf0e10cSrcweir         do
1895cdf0e10cSrcweir         {
1896cdf0e10cSrcweir             nNextTab++;
1897cdf0e10cSrcweir             pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0;
1898cdf0e10cSrcweir         } while( pNextTab && pNextTab->IsDynamic() );
1899cdf0e10cSrcweir 
1900cdf0e10cSrcweir         if( !pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos) )
1901cdf0e10cSrcweir         {
1902cdf0e10cSrcweir             if((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(pEntry) > 0)
1903cdf0e10cSrcweir             {
1904cdf0e10cSrcweir                 Point aPos( GetTabPos(pEntry,pFirstDynamicTab), nLine );
1905cdf0e10cSrcweir                 aPos.X() += pImp->nNodeBmpTabDistance;
1906cdf0e10cSrcweir 
1907cdf0e10cSrcweir                 const Image* pImg = 0;
1908cdf0e10cSrcweir                 BmpColorMode eBitmapMode = BMP_COLOR_NORMAL;
1909cdf0e10cSrcweir                 if ( GetSettings().GetStyleSettings().GetHighContrastMode() )
1910cdf0e10cSrcweir                     eBitmapMode = BMP_COLOR_HIGHCONTRAST;
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir                 if( IsExpanded(pEntry) )
1913cdf0e10cSrcweir                     pImg = &pImp->GetExpandedNodeBmp( eBitmapMode );
1914cdf0e10cSrcweir                 else
1915cdf0e10cSrcweir                 {
1916cdf0e10cSrcweir                     if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() &&
1917cdf0e10cSrcweir                         (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1918cdf0e10cSrcweir                         pImp->GetDontKnowNodeBmp().GetSizePixel().Width() )
1919cdf0e10cSrcweir                         pImg = &pImp->GetDontKnowNodeBmp( eBitmapMode );
1920cdf0e10cSrcweir                     else
1921cdf0e10cSrcweir                         pImg = &pImp->GetCollapsedNodeBmp( eBitmapMode );
1922cdf0e10cSrcweir                 }
1923cdf0e10cSrcweir                 aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2;
1924cdf0e10cSrcweir 
1925cdf0e10cSrcweir                 sal_uInt16 nStyle = 0;
1926cdf0e10cSrcweir                 if ( !IsEnabled() )
1927cdf0e10cSrcweir                     nStyle |= IMAGE_DRAW_DISABLE;
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir                 //native
1930cdf0e10cSrcweir                 sal_Bool bNativeOK = sal_False;
1931cdf0e10cSrcweir                 if ( IsNativeControlSupported( CTRL_LISTNODE, PART_ENTIRE_CONTROL) )
1932cdf0e10cSrcweir                 {
1933cdf0e10cSrcweir                     ImplControlValue    aControlValue;
1934cdf0e10cSrcweir                     Rectangle           aCtrlRegion( aPos,  pImg->GetSizePixel() );
1935cdf0e10cSrcweir                     ControlState        nState = 0;
1936cdf0e10cSrcweir 
1937cdf0e10cSrcweir                     if ( IsEnabled() )  nState |= CTRL_STATE_ENABLED;
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir                     if ( IsExpanded(pEntry) )
1940cdf0e10cSrcweir                         aControlValue.setTristateVal( BUTTONVALUE_ON );//expanded node
1941cdf0e10cSrcweir                     else
1942cdf0e10cSrcweir                     {
1943cdf0e10cSrcweir                         if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() &&
1944cdf0e10cSrcweir                             (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1945cdf0e10cSrcweir                             pImp->GetDontKnowNodeBmp().GetSizePixel().Width() )
1946cdf0e10cSrcweir                             aControlValue.setTristateVal( BUTTONVALUE_DONTKNOW );//dont know
1947cdf0e10cSrcweir                         else
1948cdf0e10cSrcweir                             aControlValue.setTristateVal( BUTTONVALUE_OFF );//collapsed node
1949cdf0e10cSrcweir                     }
1950cdf0e10cSrcweir 
1951cdf0e10cSrcweir                     bNativeOK = DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL,
1952cdf0e10cSrcweir                                             aCtrlRegion, nState, aControlValue, rtl::OUString() );
1953cdf0e10cSrcweir                 }
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir                 if( !bNativeOK) {
1956cdf0e10cSrcweir                 //non native
1957cdf0e10cSrcweir                     DrawImage( aPos, *pImg ,nStyle);
1958cdf0e10cSrcweir                 }
1959cdf0e10cSrcweir             }
1960cdf0e10cSrcweir         }
1961cdf0e10cSrcweir     }
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir     if( bHasClipRegion && bResetClipRegion )
1965cdf0e10cSrcweir         SetClipRegion();
1966cdf0e10cSrcweir     return 0; // nRowLen;
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
PreparePaint(SvLBoxEntry *)1969cdf0e10cSrcweir void SvTreeListBox::PreparePaint( SvLBoxEntry* )
1970cdf0e10cSrcweir {
1971cdf0e10cSrcweir }
1972cdf0e10cSrcweir 
GetFocusRect(SvLBoxEntry * pEntry,long nLine)1973cdf0e10cSrcweir Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
1976cdf0e10cSrcweir     Size aSize;
1977cdf0e10cSrcweir     Rectangle aRect;
1978cdf0e10cSrcweir     aRect.Top() = nLine;
1979cdf0e10cSrcweir     aSize.Height() = GetEntryHeight();
1980cdf0e10cSrcweir 
1981cdf0e10cSrcweir     long nRealWidth = pImp->GetOutputSize().Width();
1982cdf0e10cSrcweir     nRealWidth -= GetMapMode().GetOrigin().X();
1983cdf0e10cSrcweir 
1984cdf0e10cSrcweir     sal_uInt16 nCurTab;
1985cdf0e10cSrcweir     SvLBoxTab* pTab = GetFirstTab( SV_LBOXTAB_SHOW_SELECTION, nCurTab );
1986cdf0e10cSrcweir     long nTabPos = 0;
1987cdf0e10cSrcweir     if( pTab )
1988cdf0e10cSrcweir         nTabPos = GetTabPos( pEntry, pTab );
1989cdf0e10cSrcweir     long nNextTabPos;
1990cdf0e10cSrcweir     if( pTab && nCurTab < aTabs.Count() - 1 )
1991cdf0e10cSrcweir     {
1992cdf0e10cSrcweir         SvLBoxTab* pNextTab = (SvLBoxTab*)aTabs.GetObject( nCurTab + 1 );
1993cdf0e10cSrcweir         nNextTabPos = GetTabPos( pEntry, pNextTab );
1994cdf0e10cSrcweir     }
1995cdf0e10cSrcweir     else
1996cdf0e10cSrcweir     {
1997cdf0e10cSrcweir         nNextTabPos = nRealWidth;
1998cdf0e10cSrcweir         if( nTabPos > nRealWidth )
1999cdf0e10cSrcweir             nNextTabPos += 50;
2000cdf0e10cSrcweir     }
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir     sal_Bool bUserSelection = (sal_Bool)( nTreeFlags & TREEFLAG_USESEL ) != 0;
2003cdf0e10cSrcweir     if( !bUserSelection )
2004cdf0e10cSrcweir     {
2005cdf0e10cSrcweir         if( pTab && nCurTab < pEntry->ItemCount() )
2006cdf0e10cSrcweir         {
2007cdf0e10cSrcweir             SvLBoxItem* pItem = pEntry->GetItem( nCurTab );
2008cdf0e10cSrcweir             aSize.Width() = pItem->GetSize( this, pEntry ).Width();
2009cdf0e10cSrcweir             if( !aSize.Width() )
2010cdf0e10cSrcweir                 aSize.Width() = 15;
2011cdf0e10cSrcweir             long nX = nTabPos; //GetTabPos( pEntry, pTab );
2012cdf0e10cSrcweir             // Ausrichtung
2013cdf0e10cSrcweir             nX += pTab->CalcOffset( aSize.Width(), nNextTabPos - nTabPos );
2014cdf0e10cSrcweir             aRect.Left() = nX;
2015cdf0e10cSrcweir             // damit erster & letzter Buchstabe nicht angeknabbert werden
2016cdf0e10cSrcweir             aRect.SetSize( aSize );
2017cdf0e10cSrcweir             if( aRect.Left() > 0 )
2018cdf0e10cSrcweir                 aRect.Left()--;
2019cdf0e10cSrcweir             aRect.Right()++;
2020cdf0e10cSrcweir         }
2021cdf0e10cSrcweir     }
2022cdf0e10cSrcweir     else
2023cdf0e10cSrcweir     {
2024cdf0e10cSrcweir         // wenn erster SelTab != 0, dann muessen wir auch rechnen
2025cdf0e10cSrcweir         if( nFocusWidth == -1 || nFirstSelTab )
2026cdf0e10cSrcweir         {
2027cdf0e10cSrcweir             sal_uInt16 nLastTab;
2028cdf0e10cSrcweir             SvLBoxTab* pLastTab = GetLastTab(SV_LBOXTAB_SHOW_SELECTION,nLastTab);
2029cdf0e10cSrcweir             nLastTab++;
2030cdf0e10cSrcweir             if( nLastTab < aTabs.Count() ) // gibts noch einen ?
2031cdf0e10cSrcweir                 pLastTab = (SvLBoxTab*)aTabs.GetObject( nLastTab );
2032cdf0e10cSrcweir             else
2033cdf0e10cSrcweir                 pLastTab = 0;  // ueber gesamte Breite selektieren
2034cdf0e10cSrcweir             aSize.Width() = pLastTab ? pLastTab->GetPos() : 0x0fffffff;
2035cdf0e10cSrcweir             nFocusWidth = (short)aSize.Width();
2036cdf0e10cSrcweir             if( pTab )
2037cdf0e10cSrcweir                 nFocusWidth = nFocusWidth - (short)nTabPos; //pTab->GetPos();
2038cdf0e10cSrcweir         }
2039cdf0e10cSrcweir         else
2040cdf0e10cSrcweir         {
2041cdf0e10cSrcweir             aSize.Width() = nFocusWidth;
2042cdf0e10cSrcweir             if( pTab )
2043cdf0e10cSrcweir             {
2044cdf0e10cSrcweir                 if( nCurTab )
2045cdf0e10cSrcweir                     aSize.Width() += nTabPos;
2046cdf0e10cSrcweir                 else
2047cdf0e10cSrcweir                     aSize.Width() += pTab->GetPos(); // Tab0 immer ab ganz links
2048cdf0e10cSrcweir             }
2049cdf0e10cSrcweir         }
2050cdf0e10cSrcweir         // wenn Sel. beim nullten Tab anfaengt, dann ab Spalte 0 sel. zeichnen
2051cdf0e10cSrcweir         if( nCurTab != 0 )
2052cdf0e10cSrcweir         {
2053cdf0e10cSrcweir             aRect.Left() = nTabPos;
2054cdf0e10cSrcweir             aSize.Width() -= nTabPos;
2055cdf0e10cSrcweir         }
2056cdf0e10cSrcweir         aRect.SetSize( aSize );
2057cdf0e10cSrcweir     }
2058cdf0e10cSrcweir     // rechten Rand anpassen wg. Clipping
2059cdf0e10cSrcweir     if( aRect.Right() >= nRealWidth )
2060cdf0e10cSrcweir     {
2061cdf0e10cSrcweir         aRect.Right() = nRealWidth-1;
2062cdf0e10cSrcweir         nFocusWidth = (short)aRect.GetWidth();
2063cdf0e10cSrcweir     }
2064cdf0e10cSrcweir     return aRect;
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir 
GetTabPos(SvLBoxEntry * pEntry,SvLBoxTab * pTab)2068cdf0e10cSrcweir long SvTreeListBox::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
2069cdf0e10cSrcweir {
2070cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2071cdf0e10cSrcweir     DBG_ASSERT(pTab,"No Tab");
2072cdf0e10cSrcweir     long nPos = pTab->GetPos();
2073cdf0e10cSrcweir     if( pTab->IsDynamic() )
2074cdf0e10cSrcweir     {
2075cdf0e10cSrcweir         sal_uInt16 nDepth = pModel->GetDepth( pEntry );
2076cdf0e10cSrcweir         nDepth = nDepth * (sal_uInt16)nIndent;
2077cdf0e10cSrcweir         nPos += (long)nDepth;
2078cdf0e10cSrcweir     }
2079cdf0e10cSrcweir     return nPos;
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir 
GetItem_Impl(SvLBoxEntry * pEntry,long nX,SvLBoxTab ** ppTab,sal_uInt16 nEmptyWidth)2082cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX,
2083cdf0e10cSrcweir     SvLBoxTab** ppTab, sal_uInt16 nEmptyWidth )
2084cdf0e10cSrcweir {
2085cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2086cdf0e10cSrcweir     SvLBoxItem* pItemClicked = 0;
2087cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
2088cdf0e10cSrcweir     sal_uInt16 nItemCount = pEntry->ItemCount();
2089cdf0e10cSrcweir     SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
2090cdf0e10cSrcweir     SvLBoxItem* pItem = pEntry->GetItem(0);
2091cdf0e10cSrcweir     sal_uInt16 nNextItem = 1;
2092cdf0e10cSrcweir     nX -= GetMapMode().GetOrigin().X();
2093cdf0e10cSrcweir     long nRealWidth = pImp->GetOutputSize().Width();
2094cdf0e10cSrcweir     nRealWidth -= GetMapMode().GetOrigin().X();
2095cdf0e10cSrcweir 
2096cdf0e10cSrcweir     while( 1 )
2097cdf0e10cSrcweir     {
2098cdf0e10cSrcweir         SvLBoxTab* pNextTab=nNextItem<nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextItem) : 0;
2099cdf0e10cSrcweir         long nStart = GetTabPos( pEntry, pTab );
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir         long nNextTabPos;
2102cdf0e10cSrcweir         if( pNextTab )
2103cdf0e10cSrcweir             nNextTabPos = GetTabPos( pEntry, pNextTab );
2104cdf0e10cSrcweir         else
2105cdf0e10cSrcweir         {
2106cdf0e10cSrcweir             nNextTabPos = nRealWidth;
2107cdf0e10cSrcweir             if( nStart > nRealWidth )
2108cdf0e10cSrcweir                 nNextTabPos += 50;
2109cdf0e10cSrcweir         }
2110cdf0e10cSrcweir 
2111cdf0e10cSrcweir         Size aItemSize( pItem->GetSize(this, pEntry));
2112cdf0e10cSrcweir         nStart += pTab->CalcOffset( aItemSize.Width(), nNextTabPos - nStart );
2113cdf0e10cSrcweir         long nLen = aItemSize.Width();
2114cdf0e10cSrcweir         if( pNextTab )
2115cdf0e10cSrcweir         {
2116cdf0e10cSrcweir             long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart;
2117cdf0e10cSrcweir             if( nTabWidth < nLen )
2118cdf0e10cSrcweir                 nLen = nTabWidth;
2119cdf0e10cSrcweir         }
2120cdf0e10cSrcweir 
2121cdf0e10cSrcweir         if( !nLen )
2122cdf0e10cSrcweir             nLen = nEmptyWidth;
2123cdf0e10cSrcweir 
2124cdf0e10cSrcweir         if( nX >= nStart && nX < (nStart+nLen ) )
2125cdf0e10cSrcweir         {
2126cdf0e10cSrcweir             pItemClicked = pItem;
2127cdf0e10cSrcweir             if( ppTab )
2128cdf0e10cSrcweir             {
2129cdf0e10cSrcweir                 *ppTab = pTab;
2130cdf0e10cSrcweir                 break;
2131cdf0e10cSrcweir             }
2132cdf0e10cSrcweir         }
2133cdf0e10cSrcweir         if( nNextItem >= nItemCount || nNextItem >= nTabCount)
2134cdf0e10cSrcweir             break;
2135cdf0e10cSrcweir         pTab = (SvLBoxTab*)aTabs.GetObject( nNextItem );
2136cdf0e10cSrcweir         pItem = pEntry->GetItem( nNextItem );
2137cdf0e10cSrcweir         nNextItem++;
2138cdf0e10cSrcweir     }
2139cdf0e10cSrcweir     return pItemClicked;
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir 
GetItem(SvLBoxEntry * pEntry,long nX,SvLBoxTab ** ppTab)2142cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX,SvLBoxTab** ppTab)
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir     return GetItem_Impl( pEntry, nX, ppTab, 0 );
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
GetItem(SvLBoxEntry * pEntry,long nX)2147cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX )
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2150cdf0e10cSrcweir     SvLBoxTab* pDummyTab;
2151cdf0e10cSrcweir     return GetItem_Impl( pEntry, nX, &pDummyTab, 0 );
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir 
GetFirstDynamicItem(SvLBoxEntry * pEntry)2154cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetFirstDynamicItem( SvLBoxEntry* pEntry )
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir     SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
2159cdf0e10cSrcweir     SvLBoxItem* pItem = pEntry->GetItem(0);
2160cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir     sal_uInt16 nNext = 1;
2163cdf0e10cSrcweir     while ( !pTab->IsDynamic() && nNext < nTabCount )
2164cdf0e10cSrcweir     {
2165cdf0e10cSrcweir         pItem = pEntry->GetItem( nNext );
2166cdf0e10cSrcweir         pTab = (SvLBoxTab*)aTabs.GetObject( nNext );
2167cdf0e10cSrcweir         nNext++;
2168cdf0e10cSrcweir     }
2169cdf0e10cSrcweir     return pItem;
2170cdf0e10cSrcweir }
2171cdf0e10cSrcweir 
AddTab(long nTabPos,sal_uInt16 nFlags,void * pUserData)2172cdf0e10cSrcweir void SvTreeListBox::AddTab(long nTabPos,sal_uInt16 nFlags,void* pUserData )
2173cdf0e10cSrcweir {
2174cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2175cdf0e10cSrcweir     nFocusWidth = -1;
2176cdf0e10cSrcweir     SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags );
2177cdf0e10cSrcweir     pTab->SetUserData( pUserData );
2178cdf0e10cSrcweir     aTabs.Insert( pTab, aTabs.Count() );
2179cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_USESEL )
2180cdf0e10cSrcweir     {
2181cdf0e10cSrcweir         sal_uInt16 nPos = aTabs.Count() - 1;
2182cdf0e10cSrcweir         if( nPos >= nFirstSelTab && nPos <= nLastSelTab )
2183cdf0e10cSrcweir             pTab->nFlags |= SV_LBOXTAB_SHOW_SELECTION;
2184cdf0e10cSrcweir         else
2185cdf0e10cSrcweir             // String-Items werden normalerweise immer selektiert
2186cdf0e10cSrcweir             // deshalb explizit ausschalten
2187cdf0e10cSrcweir             pTab->nFlags &= ~SV_LBOXTAB_SHOW_SELECTION;
2188cdf0e10cSrcweir     }
2189cdf0e10cSrcweir }
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir 
2192cdf0e10cSrcweir 
GetFirstDynamicTab(sal_uInt16 & rPos) const2193cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( sal_uInt16& rPos ) const
2194cdf0e10cSrcweir {
2195cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2196cdf0e10cSrcweir     sal_uInt16 nCurTab = 0;
2197cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
2198cdf0e10cSrcweir     while( nCurTab < nTabCount )
2199cdf0e10cSrcweir     {
2200cdf0e10cSrcweir         SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(nCurTab);
2201cdf0e10cSrcweir         if( pTab->nFlags & SV_LBOXTAB_DYNAMIC )
2202cdf0e10cSrcweir         {
2203cdf0e10cSrcweir             rPos = nCurTab;
2204cdf0e10cSrcweir             return pTab;
2205cdf0e10cSrcweir         }
2206cdf0e10cSrcweir         nCurTab++;
2207cdf0e10cSrcweir     }
2208cdf0e10cSrcweir     return 0;
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir 
GetFirstDynamicTab() const2211cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstDynamicTab() const
2212cdf0e10cSrcweir {
2213cdf0e10cSrcweir     sal_uInt16 nDummy;
2214cdf0e10cSrcweir     return GetFirstDynamicTab( nDummy );
2215cdf0e10cSrcweir }
2216cdf0e10cSrcweir 
GetTab(SvLBoxEntry * pEntry,SvLBoxItem * pItem) const2217cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetTab( SvLBoxEntry* pEntry, SvLBoxItem* pItem) const
2218cdf0e10cSrcweir {
2219cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2220cdf0e10cSrcweir     sal_uInt16 nPos = pEntry->GetPos( pItem );
2221cdf0e10cSrcweir     return (SvLBoxTab*)aTabs.GetObject( nPos );
2222cdf0e10cSrcweir }
2223cdf0e10cSrcweir 
ClearTabList()2224cdf0e10cSrcweir void SvTreeListBox::ClearTabList()
2225cdf0e10cSrcweir {
2226cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2227cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
2228cdf0e10cSrcweir     while( nTabCount )
2229cdf0e10cSrcweir     {
2230cdf0e10cSrcweir         nTabCount--;
2231cdf0e10cSrcweir         SvLBoxTab* pDelTab = (SvLBoxTab*)aTabs.GetObject( nTabCount );
2232cdf0e10cSrcweir         delete pDelTab;
2233cdf0e10cSrcweir     }
2234cdf0e10cSrcweir     aTabs.Remove(0,aTabs.Count());
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir 
GetOutputSizePixel() const2238cdf0e10cSrcweir Size SvTreeListBox::GetOutputSizePixel() const
2239cdf0e10cSrcweir {
2240cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2241cdf0e10cSrcweir     Size aSize = pImp->GetOutputSize();
2242cdf0e10cSrcweir     return aSize;
2243cdf0e10cSrcweir }
2244cdf0e10cSrcweir 
NotifyBeginScroll()2245cdf0e10cSrcweir void SvTreeListBox::NotifyBeginScroll()
2246cdf0e10cSrcweir {
2247cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2248cdf0e10cSrcweir }
2249cdf0e10cSrcweir 
NotifyEndScroll()2250cdf0e10cSrcweir void SvTreeListBox::NotifyEndScroll()
2251cdf0e10cSrcweir {
2252cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2253cdf0e10cSrcweir }
2254cdf0e10cSrcweir 
NotifyScrolling(long)2255cdf0e10cSrcweir void SvTreeListBox::NotifyScrolling( long )
2256cdf0e10cSrcweir {
2257cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
NotifyScrolled()2260cdf0e10cSrcweir void SvTreeListBox::NotifyScrolled()
2261cdf0e10cSrcweir {
2262cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2263cdf0e10cSrcweir     aScrolledHdl.Call( this );
2264cdf0e10cSrcweir }
2265cdf0e10cSrcweir 
NotifyInvalidating()2266cdf0e10cSrcweir void SvTreeListBox::NotifyInvalidating()
2267cdf0e10cSrcweir {
2268cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2269cdf0e10cSrcweir }
2270cdf0e10cSrcweir 
Invalidate(sal_uInt16 nInvalidateFlags)2271cdf0e10cSrcweir void SvTreeListBox::Invalidate( sal_uInt16 nInvalidateFlags )
2272cdf0e10cSrcweir {
2273cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2274cdf0e10cSrcweir     if( nFocusWidth == -1 )
2275cdf0e10cSrcweir         // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt
2276cdf0e10cSrcweir         pImp->RecalcFocusRect();
2277cdf0e10cSrcweir     NotifyInvalidating();
2278cdf0e10cSrcweir     SvLBox::Invalidate( nInvalidateFlags );
2279cdf0e10cSrcweir     pImp->Invalidate();
2280cdf0e10cSrcweir }
2281cdf0e10cSrcweir 
Invalidate(const Rectangle & rRect,sal_uInt16 nInvalidateFlags)2282cdf0e10cSrcweir void SvTreeListBox::Invalidate( const Rectangle& rRect, sal_uInt16 nInvalidateFlags )
2283cdf0e10cSrcweir {
2284cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2285cdf0e10cSrcweir     if( nFocusWidth == -1 )
2286cdf0e10cSrcweir         // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt
2287cdf0e10cSrcweir         pImp->RecalcFocusRect();
2288cdf0e10cSrcweir     NotifyInvalidating();
2289cdf0e10cSrcweir     SvLBox::Invalidate( rRect, nInvalidateFlags );
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir 
2292cdf0e10cSrcweir 
SetHighlightRange(sal_uInt16 nStart,sal_uInt16 nEnd)2293cdf0e10cSrcweir void SvTreeListBox::SetHighlightRange( sal_uInt16 nStart, sal_uInt16 nEnd)
2294cdf0e10cSrcweir {
2295cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2296cdf0e10cSrcweir 
2297cdf0e10cSrcweir     sal_uInt16 nTemp;
2298cdf0e10cSrcweir     nTreeFlags |= TREEFLAG_USESEL;
2299cdf0e10cSrcweir     if( nStart > nEnd )
2300cdf0e10cSrcweir     {
2301cdf0e10cSrcweir         nTemp = nStart;
2302cdf0e10cSrcweir         nStart = nEnd;
2303cdf0e10cSrcweir         nEnd = nTemp;
2304cdf0e10cSrcweir     }
2305cdf0e10cSrcweir     // alle Tabs markieren, die im Bereich liegen
2306cdf0e10cSrcweir     nTreeFlags |= TREEFLAG_RECALCTABS;
2307cdf0e10cSrcweir     nFirstSelTab = nStart;
2308cdf0e10cSrcweir     nLastSelTab = nEnd;
2309cdf0e10cSrcweir     pImp->RecalcFocusRect();
2310cdf0e10cSrcweir }
2311cdf0e10cSrcweir 
RemoveHighlightRange()2312cdf0e10cSrcweir void SvTreeListBox::RemoveHighlightRange()
2313cdf0e10cSrcweir {
2314cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2315cdf0e10cSrcweir     nTreeFlags &= (~TREEFLAG_USESEL);
2316cdf0e10cSrcweir     if( IsUpdateMode() )
2317cdf0e10cSrcweir         Invalidate();
2318cdf0e10cSrcweir }
2319cdf0e10cSrcweir 
GetAscInsertionPos(SvLBoxEntry *,SvLBoxEntry *)2320cdf0e10cSrcweir sal_uLong SvTreeListBox::GetAscInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2321cdf0e10cSrcweir {
2322cdf0e10cSrcweir     return LIST_APPEND;
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir 
GetDescInsertionPos(SvLBoxEntry *,SvLBoxEntry *)2325cdf0e10cSrcweir sal_uLong SvTreeListBox::GetDescInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2326cdf0e10cSrcweir {
2327cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2328cdf0e10cSrcweir     return LIST_APPEND;
2329cdf0e10cSrcweir }
2330cdf0e10cSrcweir 
GetDragRegion() const2331cdf0e10cSrcweir Region SvTreeListBox::GetDragRegion() const
2332cdf0e10cSrcweir {
2333cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2334cdf0e10cSrcweir     Rectangle aRect;
2335cdf0e10cSrcweir     SvLBoxEntry* pEntry = GetCurEntry();
2336cdf0e10cSrcweir     if( pEntry )
2337cdf0e10cSrcweir     {
2338cdf0e10cSrcweir         Point aPos = GetEntryPosition( pEntry );
2339cdf0e10cSrcweir         aRect = ((SvTreeListBox*)this)->GetFocusRect( pEntry, aPos.Y() );
2340cdf0e10cSrcweir     }
2341cdf0e10cSrcweir     Region aRegion( aRect );
2342cdf0e10cSrcweir     return aRegion;
2343cdf0e10cSrcweir }
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)2346cdf0e10cSrcweir void SvTreeListBox::Command( const CommandEvent& rCEvt )
2347cdf0e10cSrcweir {
2348cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2349cdf0e10cSrcweir     // FIXME gnumake2 resync to DEV300_m84
2350cdf0e10cSrcweir     pImp->Command( rCEvt );
2351cdf0e10cSrcweir }
2352cdf0e10cSrcweir 
2353cdf0e10cSrcweir 
RemoveParentKeepChilds(SvLBoxEntry * pParent)2354cdf0e10cSrcweir void SvTreeListBox::RemoveParentKeepChilds( SvLBoxEntry* pParent )
2355cdf0e10cSrcweir {
2356cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2357cdf0e10cSrcweir     DBG_ASSERT(pParent,"RemoveParentKeepChilds:No Parent");
2358cdf0e10cSrcweir     SvLBoxEntry* pNewParent = GetParent( pParent );
2359cdf0e10cSrcweir     if( pParent->HasChilds())
2360cdf0e10cSrcweir     {
2361cdf0e10cSrcweir         SvLBoxEntry* pChild = FirstChild( pParent );
2362cdf0e10cSrcweir         while( pChild )
2363cdf0e10cSrcweir         {
2364cdf0e10cSrcweir             pModel->Move( pChild, pNewParent, LIST_APPEND );
2365cdf0e10cSrcweir             pChild = FirstChild( pParent );
2366cdf0e10cSrcweir         }
2367cdf0e10cSrcweir     }
2368cdf0e10cSrcweir     pModel->Remove( pParent );
2369cdf0e10cSrcweir }
2370cdf0e10cSrcweir 
GetFirstTab(sal_uInt16 nFlagMask,sal_uInt16 & rPos)2371cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rPos )
2372cdf0e10cSrcweir {
2373cdf0e10cSrcweir     sal_uInt16 nTabCount = aTabs.Count();
2374cdf0e10cSrcweir     for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ )
2375cdf0e10cSrcweir     {
2376cdf0e10cSrcweir         SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nPos );
2377cdf0e10cSrcweir         if( (pTab->nFlags & nFlagMask) )
2378cdf0e10cSrcweir         {
2379cdf0e10cSrcweir             rPos = nPos;
2380cdf0e10cSrcweir             return pTab;
2381cdf0e10cSrcweir         }
2382cdf0e10cSrcweir     }
2383cdf0e10cSrcweir     rPos = 0xffff;
2384cdf0e10cSrcweir     return 0;
2385cdf0e10cSrcweir }
2386cdf0e10cSrcweir 
GetLastTab(sal_uInt16 nFlagMask,sal_uInt16 & rTabPos)2387cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos )
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir     short nTabCount = (short)aTabs.Count();
2390cdf0e10cSrcweir     if( nTabCount )
2391cdf0e10cSrcweir     {
2392cdf0e10cSrcweir         for( short nPos = nTabCount-1; nPos >= 0; nPos-- )
2393cdf0e10cSrcweir         {
2394cdf0e10cSrcweir             SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( (sal_uInt16)nPos );
2395cdf0e10cSrcweir             if( (pTab->nFlags & nFlagMask) )
2396cdf0e10cSrcweir             {
2397cdf0e10cSrcweir                 rTabPos = (sal_uInt16)nPos;
2398cdf0e10cSrcweir                 return pTab;
2399cdf0e10cSrcweir             }
2400cdf0e10cSrcweir         }
2401cdf0e10cSrcweir     }
2402cdf0e10cSrcweir     rTabPos = 0xffff;
2403cdf0e10cSrcweir     return 0;
2404cdf0e10cSrcweir }
2405cdf0e10cSrcweir 
SetAddMode(sal_Bool bAdd)2406cdf0e10cSrcweir void SvTreeListBox::SetAddMode( sal_Bool bAdd )
2407cdf0e10cSrcweir {
2408cdf0e10cSrcweir     pImp->SetAddMode( bAdd );
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir 
IsAddMode() const2411cdf0e10cSrcweir sal_Bool SvTreeListBox::IsAddMode() const
2412cdf0e10cSrcweir {
2413cdf0e10cSrcweir     return pImp->IsAddMode();
2414cdf0e10cSrcweir }
2415cdf0e10cSrcweir 
RequestHelp(const HelpEvent & rHEvt)2416cdf0e10cSrcweir void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2417cdf0e10cSrcweir {
2418cdf0e10cSrcweir     if( !pImp->RequestHelp( rHEvt ) )
2419cdf0e10cSrcweir         SvLBox::RequestHelp( rHEvt );
2420cdf0e10cSrcweir }
2421cdf0e10cSrcweir 
CursorMoved(SvLBoxEntry *)2422cdf0e10cSrcweir void SvTreeListBox::CursorMoved( SvLBoxEntry* )
2423cdf0e10cSrcweir {
2424cdf0e10cSrcweir }
2425cdf0e10cSrcweir 
IMPL_LINK(SvTreeListBox,DefaultCompare,SvSortData *,pData)2426cdf0e10cSrcweir IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData )
2427cdf0e10cSrcweir {
2428cdf0e10cSrcweir     SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft );
2429cdf0e10cSrcweir     SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
2430cdf0e10cSrcweir     String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2431cdf0e10cSrcweir     String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2432cdf0e10cSrcweir     // #102891# ----------------
2433cdf0e10cSrcweir     pImp->UpdateIntlWrapper();
2434cdf0e10cSrcweir     return pImp->pIntlWrapper->getCaseCollator()->compareString( aLeft, aRight );
2435cdf0e10cSrcweir }
2436cdf0e10cSrcweir 
ModelNotification(sal_uInt16 nActionId,SvListEntry * pEntry1,SvListEntry * pEntry2,sal_uLong nPos)2437cdf0e10cSrcweir void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
2438cdf0e10cSrcweir                         SvListEntry* pEntry2, sal_uLong nPos )
2439cdf0e10cSrcweir {
2440cdf0e10cSrcweir     if( nActionId == LISTACTION_CLEARING )
2441cdf0e10cSrcweir         CancelTextEditing();
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir     SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
2444cdf0e10cSrcweir     switch( nActionId )
2445cdf0e10cSrcweir     {
2446cdf0e10cSrcweir         case LISTACTION_INSERTED:
2447cdf0e10cSrcweir         {
2448cdf0e10cSrcweir             SvLBoxEntry* pEntry( dynamic_cast< SvLBoxEntry* >( pEntry1 ) );
2449cdf0e10cSrcweir             ENSURE_OR_BREAK( pEntry, "SvTreeListBox::ModelNotification: invalid entry!" );
2450cdf0e10cSrcweir             SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
2451cdf0e10cSrcweir             if ( !pBmpItem )
2452cdf0e10cSrcweir                 break;
2453cdf0e10cSrcweir             const Image& rBitmap1( pBmpItem->GetBitmap1() );
2454cdf0e10cSrcweir             const Image& rBitmap2( pBmpItem->GetBitmap2() );
2455cdf0e10cSrcweir             short nMaxWidth = short( Max( rBitmap1.GetSizePixel().Width(), rBitmap2.GetSizePixel().Width() ) );
2456cdf0e10cSrcweir             nMaxWidth = pImp->UpdateContextBmpWidthVector( pEntry, nMaxWidth );
2457cdf0e10cSrcweir             if( nMaxWidth > nContextBmpWidthMax )
2458cdf0e10cSrcweir             {
2459cdf0e10cSrcweir                 nContextBmpWidthMax = nMaxWidth;
2460cdf0e10cSrcweir                 SetTabs();
2461cdf0e10cSrcweir             }
2462cdf0e10cSrcweir         }
2463cdf0e10cSrcweir         break;
2464cdf0e10cSrcweir 
2465cdf0e10cSrcweir         case LISTACTION_RESORTING:
2466cdf0e10cSrcweir             SetUpdateMode( sal_False );
2467cdf0e10cSrcweir             break;
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir         case LISTACTION_RESORTED:
2470cdf0e10cSrcweir             // nach Sortierung den ersten Eintrag anzeigen, dabei die
2471cdf0e10cSrcweir             // Selektion erhalten.
2472cdf0e10cSrcweir             MakeVisible( (SvLBoxEntry*)pModel->First(), sal_True );
2473cdf0e10cSrcweir             SetUpdateMode( sal_True );
2474cdf0e10cSrcweir             break;
2475cdf0e10cSrcweir 
2476cdf0e10cSrcweir         case LISTACTION_CLEARED:
2477cdf0e10cSrcweir             if( IsUpdateMode() )
2478cdf0e10cSrcweir                 Update();
2479cdf0e10cSrcweir             break;
2480cdf0e10cSrcweir     }
2481cdf0e10cSrcweir }
2482cdf0e10cSrcweir 
2483cdf0e10cSrcweir // bei Aenderungen SetTabs beruecksichtigen
GetTextOffset() const2484cdf0e10cSrcweir long SvTreeListBox::GetTextOffset() const
2485cdf0e10cSrcweir {
2486cdf0e10cSrcweir     DBG_CHKTHIS(SvTreeListBox,0);
2487cdf0e10cSrcweir     const WinBits nWindowStyle = GetStyle();
2488cdf0e10cSrcweir     sal_Bool bHasButtons = (nWindowStyle & WB_HASBUTTONS)!=0;
2489cdf0e10cSrcweir     sal_Bool bHasButtonsAtRoot = (nWindowStyle & (WB_HASLINESATROOT |
2490cdf0e10cSrcweir                                               WB_HASBUTTONSATROOT))!=0;
2491cdf0e10cSrcweir     long nStartPos = TAB_STARTPOS;
2492cdf0e10cSrcweir     long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir     long nCheckWidth = 0;
2495cdf0e10cSrcweir     if( nTreeFlags & TREEFLAG_CHKBTN )
2496cdf0e10cSrcweir         nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width();
2497cdf0e10cSrcweir     long nCheckWidthDIV2 = nCheckWidth / 2;
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir     long nContextWidth = nContextBmpWidthMax;
2500cdf0e10cSrcweir     long nContextWidthDIV2 = nContextWidth / 2;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir     int nCase = NO_BUTTONS;
2503cdf0e10cSrcweir     if( !(nTreeFlags & TREEFLAG_CHKBTN) )
2504cdf0e10cSrcweir     {
2505cdf0e10cSrcweir         if( bHasButtons )
2506cdf0e10cSrcweir             nCase = NODE_BUTTONS;
2507cdf0e10cSrcweir     }
2508cdf0e10cSrcweir     else
2509cdf0e10cSrcweir     {
2510cdf0e10cSrcweir         if( bHasButtons )
2511cdf0e10cSrcweir             nCase = NODE_AND_CHECK_BUTTONS;
2512cdf0e10cSrcweir          else
2513cdf0e10cSrcweir             nCase = CHECK_BUTTONS;
2514cdf0e10cSrcweir     }
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir     switch( nCase )
2517cdf0e10cSrcweir     {
2518cdf0e10cSrcweir         case NO_BUTTONS :
2519cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // wg. Zentrierung
2520cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
2521cdf0e10cSrcweir             if( nContextBmpWidthMax )
2522cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
2523cdf0e10cSrcweir             break;
2524cdf0e10cSrcweir 
2525cdf0e10cSrcweir         case NODE_BUTTONS :
2526cdf0e10cSrcweir             if( bHasButtonsAtRoot )
2527cdf0e10cSrcweir                 nStartPos += ( nIndent + (nNodeWidthPixel/2) );
2528cdf0e10cSrcweir             else
2529cdf0e10cSrcweir                 nStartPos += nContextWidthDIV2;
2530cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
2531cdf0e10cSrcweir             if( nContextBmpWidthMax )
2532cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
2533cdf0e10cSrcweir             break;
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir         case NODE_AND_CHECK_BUTTONS :
2536cdf0e10cSrcweir             if( bHasButtonsAtRoot )
2537cdf0e10cSrcweir                 nStartPos += ( nIndent + nNodeWidthPixel );
2538cdf0e10cSrcweir             else
2539cdf0e10cSrcweir                 nStartPos += nCheckWidthDIV2;
2540cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;  // rechter Rand des CheckButtons
2541cdf0e10cSrcweir             nStartPos += 3;  // Abstand CheckButton Context-Bmp
2542cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // Mitte der Context-Bmp
2543cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
2544cdf0e10cSrcweir             // Abstand setzen nur wenn Bitmaps da
2545cdf0e10cSrcweir             if( nContextBmpWidthMax )
2546cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
2547cdf0e10cSrcweir             break;
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir         case CHECK_BUTTONS :
2550cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;
2551cdf0e10cSrcweir             nStartPos += nCheckWidthDIV2;  // rechter Rand CheckButton
2552cdf0e10cSrcweir             nStartPos += 3;  // Abstand CheckButton Context-Bmp
2553cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // Mitte der Context-Bmp
2554cdf0e10cSrcweir             nStartPos += nContextWidthDIV2;  // rechter Rand der Context-Bmp
2555cdf0e10cSrcweir             if( nContextBmpWidthMax )
2556cdf0e10cSrcweir                 nStartPos += 5; // Abstand Context-Bmp - Text
2557cdf0e10cSrcweir             break;
2558cdf0e10cSrcweir     }
2559cdf0e10cSrcweir     return nStartPos;
2560cdf0e10cSrcweir }
2561cdf0e10cSrcweir 
EndSelection()2562cdf0e10cSrcweir void SvTreeListBox::EndSelection()
2563cdf0e10cSrcweir {
2564cdf0e10cSrcweir     pImp->EndSelection();
2565cdf0e10cSrcweir }
2566cdf0e10cSrcweir 
IsNodeButton(const Point & rPos) const2567cdf0e10cSrcweir sal_Bool SvTreeListBox::IsNodeButton( const Point& rPos ) const
2568cdf0e10cSrcweir {
2569cdf0e10cSrcweir     SvLBoxEntry* pEntry = GetEntry( rPos );
2570cdf0e10cSrcweir     if( pEntry )
2571cdf0e10cSrcweir         return pImp->IsNodeButton( rPos, pEntry );
2572cdf0e10cSrcweir     return sal_False;
2573cdf0e10cSrcweir }
2574cdf0e10cSrcweir 
RepaintScrollBars() const2575cdf0e10cSrcweir void SvTreeListBox::RepaintScrollBars() const
2576cdf0e10cSrcweir {
2577cdf0e10cSrcweir     ((SvTreeListBox*)this)->pImp->RepaintScrollBars();
2578cdf0e10cSrcweir }
2579cdf0e10cSrcweir 
GetVScroll()2580cdf0e10cSrcweir ScrollBar *SvTreeListBox::GetVScroll()
2581cdf0e10cSrcweir {
2582cdf0e10cSrcweir     return &((SvTreeListBox*)this)->pImp->aVerSBar;
2583cdf0e10cSrcweir }
2584cdf0e10cSrcweir 
GetHScroll()2585cdf0e10cSrcweir ScrollBar *SvTreeListBox::GetHScroll()
2586cdf0e10cSrcweir {
2587cdf0e10cSrcweir     return &((SvTreeListBox*)this)->pImp->aHorSBar;
2588cdf0e10cSrcweir }
2589cdf0e10cSrcweir 
EnableAsyncDrag(sal_Bool b)2590cdf0e10cSrcweir void SvTreeListBox::EnableAsyncDrag( sal_Bool b )
2591cdf0e10cSrcweir {
2592cdf0e10cSrcweir     pImp->EnableAsyncDrag( b );
2593cdf0e10cSrcweir }
2594cdf0e10cSrcweir 
GetFirstEntryInView() const2595cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetFirstEntryInView() const
2596cdf0e10cSrcweir {
2597cdf0e10cSrcweir     Point aPos;
2598cdf0e10cSrcweir     return GetEntry( aPos );
2599cdf0e10cSrcweir }
2600cdf0e10cSrcweir 
GetNextEntryInView(SvLBoxEntry * pEntry) const2601cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetNextEntryInView(SvLBoxEntry* pEntry ) const
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir     SvLBoxEntry* pNext = (SvLBoxEntry*)NextVisible( pEntry );
2604cdf0e10cSrcweir     if( pNext )
2605cdf0e10cSrcweir     {
2606cdf0e10cSrcweir         Point aPos( GetEntryPosition(pNext) );
2607cdf0e10cSrcweir         const Size& rSize = pImp->GetOutputSize();
2608cdf0e10cSrcweir         if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() )
2609cdf0e10cSrcweir             return 0;
2610cdf0e10cSrcweir     }
2611cdf0e10cSrcweir     return pNext;
2612cdf0e10cSrcweir }
2613cdf0e10cSrcweir 
ShowFocusRect(const SvLBoxEntry * pEntry)2614cdf0e10cSrcweir void SvTreeListBox::ShowFocusRect( const SvLBoxEntry* pEntry )
2615cdf0e10cSrcweir {
2616cdf0e10cSrcweir     pImp->ShowFocusRect( pEntry );
2617cdf0e10cSrcweir }
2618cdf0e10cSrcweir 
SetTabBar(TabBar * pTabBar)2619cdf0e10cSrcweir void SvTreeListBox::SetTabBar( TabBar* pTabBar )
2620cdf0e10cSrcweir {
2621cdf0e10cSrcweir     pImp->SetTabBar( pTabBar );
2622cdf0e10cSrcweir }
2623cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)2624cdf0e10cSrcweir void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt )
2625cdf0e10cSrcweir {
2626cdf0e10cSrcweir     if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
2627cdf0e10cSrcweir     {
2628cdf0e10cSrcweir         nEntryHeight = 0;   // _together_ with sal_True of 1. par (bFont) of InitSettings() a zero-height
2629cdf0e10cSrcweir                             //  forces complete recalc of heights!
2630cdf0e10cSrcweir         InitSettings( sal_True, sal_True, sal_True );
2631cdf0e10cSrcweir         Invalidate();
2632cdf0e10cSrcweir     }
2633cdf0e10cSrcweir     else
2634cdf0e10cSrcweir         Control::DataChanged( rDCEvt );
2635cdf0e10cSrcweir }
2636cdf0e10cSrcweir 
StateChanged(StateChangedType i_nStateChange)2637cdf0e10cSrcweir void SvTreeListBox::StateChanged( StateChangedType i_nStateChange )
2638cdf0e10cSrcweir {
2639cdf0e10cSrcweir     SvLBox::StateChanged( i_nStateChange );
2640cdf0e10cSrcweir     if ( i_nStateChange == STATE_CHANGE_STYLE )
2641cdf0e10cSrcweir         ImplInitStyle();
2642cdf0e10cSrcweir }
2643cdf0e10cSrcweir 
InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)2644cdf0e10cSrcweir void SvTreeListBox::InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)
2645cdf0e10cSrcweir {
2646cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2647cdf0e10cSrcweir     if( bFont )
2648cdf0e10cSrcweir     {
2649cdf0e10cSrcweir         Font aFont;
2650cdf0e10cSrcweir         aFont = rStyleSettings.GetFieldFont();
2651cdf0e10cSrcweir         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
2652cdf0e10cSrcweir         SetPointFont( aFont );
2653cdf0e10cSrcweir         AdjustEntryHeight( aFont );
2654cdf0e10cSrcweir         RecalcViewData();
2655cdf0e10cSrcweir     }
2656cdf0e10cSrcweir 
2657cdf0e10cSrcweir     if( bForeground || bFont )
2658cdf0e10cSrcweir     {
2659cdf0e10cSrcweir         SetTextColor( rStyleSettings.GetFieldTextColor() );
2660cdf0e10cSrcweir         SetTextFillColor();
2661cdf0e10cSrcweir     }
2662cdf0e10cSrcweir 
2663cdf0e10cSrcweir     if( bBackground )
2664cdf0e10cSrcweir         SetBackground( rStyleSettings.GetFieldColor() );
2665cdf0e10cSrcweir 
2666cdf0e10cSrcweir     // always try to re-create default-SvLBoxButtonData
2667cdf0e10cSrcweir     if( pCheckButtonData && pCheckButtonData->HasDefaultImages() )
2668cdf0e10cSrcweir         pCheckButtonData->SetDefaultImages( this );
2669cdf0e10cSrcweir }
2670cdf0e10cSrcweir 
IsCellFocusEnabled() const2671cdf0e10cSrcweir sal_Bool SvTreeListBox::IsCellFocusEnabled() const
2672cdf0e10cSrcweir {
2673cdf0e10cSrcweir     return pImp->IsCellFocusEnabled();
2674cdf0e10cSrcweir }
2675cdf0e10cSrcweir 
SetCurrentTabPos(sal_uInt16 _nNewPos)2676cdf0e10cSrcweir bool SvTreeListBox::SetCurrentTabPos( sal_uInt16 _nNewPos )
2677cdf0e10cSrcweir {
2678cdf0e10cSrcweir     return pImp->SetCurrentTabPos( _nNewPos );
2679cdf0e10cSrcweir }
2680cdf0e10cSrcweir 
GetCurrentTabPos() const2681cdf0e10cSrcweir sal_uInt16 SvTreeListBox::GetCurrentTabPos() const
2682cdf0e10cSrcweir {
2683cdf0e10cSrcweir     return pImp->GetCurrentTabPos();
2684cdf0e10cSrcweir }
2685cdf0e10cSrcweir 
InitStartEntry()2686cdf0e10cSrcweir void SvTreeListBox::InitStartEntry()
2687cdf0e10cSrcweir {
2688cdf0e10cSrcweir     if( !pImp->pStartEntry )
2689cdf0e10cSrcweir         pImp->pStartEntry = GetModel()->First();
2690cdf0e10cSrcweir }
2691cdf0e10cSrcweir 
CancelPendingEdit()2692cdf0e10cSrcweir void SvTreeListBox::CancelPendingEdit()
2693cdf0e10cSrcweir {
2694cdf0e10cSrcweir     if( pImp )
2695cdf0e10cSrcweir         pImp->CancelPendingEdit();
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir 
CreateContextMenu(void)2698cdf0e10cSrcweir PopupMenu* SvTreeListBox::CreateContextMenu( void )
2699cdf0e10cSrcweir {
2700cdf0e10cSrcweir     return NULL;
2701cdf0e10cSrcweir }
2702cdf0e10cSrcweir 
ExcecuteContextMenuAction(sal_uInt16)2703cdf0e10cSrcweir void SvTreeListBox::ExcecuteContextMenuAction( sal_uInt16 )
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir     DBG_WARNING( "SvTreeListBox::ExcecuteContextMenuAction(): now there's happening nothing!" );
2706cdf0e10cSrcweir }
2707cdf0e10cSrcweir 
EnableContextMenuHandling(void)2708cdf0e10cSrcweir void SvTreeListBox::EnableContextMenuHandling( void )
2709cdf0e10cSrcweir {
2710cdf0e10cSrcweir     DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2711cdf0e10cSrcweir 
2712cdf0e10cSrcweir     pImp->bContextMenuHandling = sal_True;
2713cdf0e10cSrcweir }
2714cdf0e10cSrcweir 
EnableContextMenuHandling(sal_Bool b)2715cdf0e10cSrcweir void SvTreeListBox::EnableContextMenuHandling( sal_Bool b )
2716cdf0e10cSrcweir {
2717cdf0e10cSrcweir     DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2718cdf0e10cSrcweir 
2719cdf0e10cSrcweir     pImp->bContextMenuHandling = b;
2720cdf0e10cSrcweir }
2721cdf0e10cSrcweir 
IsContextMenuHandlingEnabled(void) const2722cdf0e10cSrcweir sal_Bool SvTreeListBox::IsContextMenuHandlingEnabled( void ) const
2723cdf0e10cSrcweir {
2724cdf0e10cSrcweir     DBG_ASSERT( pImp, "-SvTreeListBox::IsContextMenuHandlingEnabled(): No implementation!" );
2725cdf0e10cSrcweir 
2726cdf0e10cSrcweir     return pImp->bContextMenuHandling;
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir 
EnableList(bool _bEnable)2729cdf0e10cSrcweir void SvTreeListBox::EnableList( bool _bEnable )
2730cdf0e10cSrcweir {
2731cdf0e10cSrcweir     // call base class method
2732cdf0e10cSrcweir     Window::Enable( _bEnable != false );
2733cdf0e10cSrcweir     // then paint immediately
2734cdf0e10cSrcweir     Paint( Rectangle( Point(), GetSizePixel() ) );
2735cdf0e10cSrcweir }
2736cdf0e10cSrcweir 
CreateAccessible()2737cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible()
2738cdf0e10cSrcweir {
2739cdf0e10cSrcweir     Window* pParent = GetAccessibleParentWindow();
2740cdf0e10cSrcweir     DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" );
2741cdf0e10cSrcweir 
2742cdf0e10cSrcweir     ::com::sun::star::uno::Reference< XAccessible > xAccessible;
2743cdf0e10cSrcweir     if ( pParent )
2744cdf0e10cSrcweir     {
2745cdf0e10cSrcweir         ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
2746cdf0e10cSrcweir         if ( xAccParent.is() )
2747cdf0e10cSrcweir         {
2748*0cb2ec91SJohn Bampton             // need to be done here to get the vclxwindow later on in the accessible
2749cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xTemp(GetComponentInterface());
2750cdf0e10cSrcweir             xAccessible = pImp->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent );
2751cdf0e10cSrcweir         }
2752cdf0e10cSrcweir     }
2753cdf0e10cSrcweir     return xAccessible;
2754cdf0e10cSrcweir }
2755cdf0e10cSrcweir 
FillAccessibleEntryStateSet(SvLBoxEntry * pEntry,::utl::AccessibleStateSetHelper & rStateSet) const2756cdf0e10cSrcweir void SvTreeListBox::FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const
2757cdf0e10cSrcweir {
2758cdf0e10cSrcweir     DBG_ASSERT( pEntry, "SvTreeListBox::FillAccessibleEntryStateSet: invalid entry" );
2759cdf0e10cSrcweir 
2760d84f099fSTsutomu Uchino     if ( pEntry )
2761d84f099fSTsutomu Uchino     {
2762cdf0e10cSrcweir         if ( pEntry->HasChildsOnDemand() || pEntry->HasChilds() )
2763cdf0e10cSrcweir         {
2764cdf0e10cSrcweir             rStateSet.AddState( AccessibleStateType::EXPANDABLE );
2765cdf0e10cSrcweir             if ( IsExpanded( pEntry ) )
2766cdf0e10cSrcweir                 rStateSet.AddState( (sal_Int16)AccessibleStateType::EXPANDED );
2767cdf0e10cSrcweir         }
2768cdf0e10cSrcweir 
2769cdf0e10cSrcweir         if ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
2770cdf0e10cSrcweir             rStateSet.AddState( AccessibleStateType::CHECKED );
2771cdf0e10cSrcweir         if ( IsEntryVisible( pEntry ) )
2772cdf0e10cSrcweir             rStateSet.AddState( AccessibleStateType::VISIBLE );
2773cdf0e10cSrcweir         if ( IsSelected( pEntry ) )
2774cdf0e10cSrcweir             rStateSet.AddState( AccessibleStateType::SELECTED );
27752bfcd321SSteve Yin         if ( IsEnabled() )
27762bfcd321SSteve Yin         {
27772bfcd321SSteve Yin             rStateSet.AddState( AccessibleStateType::ENABLED );
27782bfcd321SSteve Yin             rStateSet.AddState( AccessibleStateType::FOCUSABLE );
27792bfcd321SSteve Yin             rStateSet.AddState( AccessibleStateType::SELECTABLE );
27802bfcd321SSteve Yin             SvViewDataEntry* pViewDataNewCur = 0;
27812bfcd321SSteve Yin             pViewDataNewCur = GetViewDataEntry(pEntry);
2782d84f099fSTsutomu Uchino             if( pViewDataNewCur && pViewDataNewCur->HasFocus() )
27832bfcd321SSteve Yin                 rStateSet.AddState( AccessibleStateType::FOCUSED );
27842bfcd321SSteve Yin         }
27852bfcd321SSteve Yin     }
2786cdf0e10cSrcweir }
2787cdf0e10cSrcweir 
GetBoundingRect(SvLBoxEntry * pEntry)2788cdf0e10cSrcweir Rectangle SvTreeListBox::GetBoundingRect( SvLBoxEntry* pEntry )
2789cdf0e10cSrcweir {
2790cdf0e10cSrcweir     Point aPos = GetEntryPosition( pEntry );
2791cdf0e10cSrcweir     Rectangle aRect = GetFocusRect( pEntry, aPos.Y() );
2792cdf0e10cSrcweir     return aRect;
2793cdf0e10cSrcweir }
2794cdf0e10cSrcweir 
EnableCellFocus()2795cdf0e10cSrcweir void SvTreeListBox::EnableCellFocus()
2796cdf0e10cSrcweir {
2797cdf0e10cSrcweir     pImp->EnableCellFocus();
2798cdf0e10cSrcweir }
2799cdf0e10cSrcweir 
CallImplEventListeners(sal_uLong nEvent,void * pData)2800cdf0e10cSrcweir void SvTreeListBox::CallImplEventListeners(sal_uLong nEvent, void* pData)
2801cdf0e10cSrcweir {
2802cdf0e10cSrcweir     CallEventListeners(nEvent, pData);
2803cdf0e10cSrcweir }
2804cdf0e10cSrcweir 
FillAccessibleStateSet(::utl::AccessibleStateSetHelper & rStateSet) const2805cdf0e10cSrcweir void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const
2806cdf0e10cSrcweir {
2807cdf0e10cSrcweir       SvLBox::FillAccessibleStateSet( rStateSet );
2808cdf0e10cSrcweir }
2809