Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svtools/tabbar.hxx>
31 : : #include <tools/time.hxx>
32 : : #include <tools/debug.hxx>
33 : : #include <tools/poly.hxx>
34 : : #include <vcl/svapp.hxx>
35 : : #include <vcl/help.hxx>
36 : : #include <vcl/decoview.hxx>
37 : : #include <vcl/button.hxx>
38 : : #include <vcl/edit.hxx>
39 : : #include <vcl/image.hxx>
40 : : #include "svtaccessiblefactory.hxx"
41 : : #include <filectrl.hrc>
42 : : #include <svtools/svtresid.hxx>
43 : : #include <svtools/svtools.hrc>
44 : : #include <limits>
45 : :
46 : : // =======================================================================
47 : :
48 : : #define TABBAR_OFFSET_X 7
49 : : #define TABBAR_OFFSET_X2 2
50 : : #define TABBAR_DRAG_SCROLLOFF 5
51 : : #define TABBAR_MINSIZE 5
52 : :
53 : : const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
54 : :
55 : : // =======================================================================
56 : :
57 [ + - ]: 1790 : struct ImplTabBarItem
58 : : {
59 : : sal_uInt16 mnId;
60 : : TabBarPageBits mnBits;
61 : : XubString maText;
62 : : XubString maHelpText;
63 : : Rectangle maRect;
64 : : long mnWidth;
65 : : rtl::OString maHelpId;
66 : : sal_Bool mbShort;
67 : : sal_Bool mbSelect;
68 : : sal_Bool mbEnable;
69 : : Color maTabBgColor;
70 : : Color maTabTextColor;
71 : :
72 : 1802 : ImplTabBarItem( sal_uInt16 nItemId, const XubString& rText,
73 : : TabBarPageBits nPageBits ) :
74 [ + - ][ + - ]: 1802 : maText( rText )
75 : : {
76 : 1802 : mnId = nItemId;
77 : 1802 : mnBits = nPageBits;
78 : 1802 : mnWidth = 0;
79 : 1802 : mbShort = sal_False;
80 : 1802 : mbSelect = sal_False;
81 : 1802 : mbEnable = sal_True;
82 : 1802 : maTabBgColor = Color( COL_AUTO );
83 : 1802 : maTabTextColor = Color( COL_AUTO );
84 : 1802 : }
85 : :
86 : 892 : bool IsDefaultTabBgColor() const
87 : : {
88 : 892 : return maTabBgColor == Color(COL_AUTO);
89 : : }
90 : :
91 : : bool IsDefaultTabTextColor() const
92 : : {
93 : : return maTabTextColor == Color(COL_AUTO);
94 : : }
95 : :
96 : 892 : bool IsSelected(ImplTabBarItem* pCurItem) const
97 : : {
98 [ + + ][ + + ]: 892 : return mbSelect || (pCurItem == this);
99 : : }
100 : : };
101 : :
102 : : // =======================================================================
103 : :
104 : : // -----------------
105 : : // - ImplTabButton -
106 : : // -----------------
107 : :
108 [ - + ]: 3672 : class ImplTabButton : public PushButton
109 : : {
110 : : public:
111 : 1852 : ImplTabButton( TabBar* pParent, WinBits nWinStyle = 0 ) :
112 : 1852 : PushButton( pParent, nWinStyle | WB_RECTSTYLE | WB_SMALLSTYLE | WB_NOLIGHTBORDER | WB_NOPOINTERFOCUS ) {}
113 : :
114 : 0 : TabBar* GetParent() const { return (TabBar*)Window::GetParent(); }
115 : :
116 : : virtual long PreNotify( NotifyEvent& rNEvt );
117 : : };
118 : :
119 : : // =======================================================================
120 : :
121 : 0 : long ImplTabButton::PreNotify( NotifyEvent& rNEvt )
122 : : {
123 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
124 : : {
125 [ # # ]: 0 : if ( GetParent()->IsInEditMode() )
126 : : {
127 : 0 : GetParent()->EndEditMode();
128 : 0 : return sal_True;
129 : : }
130 : : }
131 : :
132 : 0 : return PushButton::PreNotify( rNEvt );
133 : : }
134 : :
135 : : // =======================================================================
136 : :
137 : : // ----------------
138 : : // - ImplTabSizer -
139 : : // ----------------
140 : :
141 [ - + ]: 918 : class ImplTabSizer : public Window
142 : : {
143 : : public:
144 : : ImplTabSizer( TabBar* pParent, WinBits nWinStyle = 0 );
145 : :
146 : 0 : TabBar* GetParent() const { return (TabBar*)Window::GetParent(); }
147 : :
148 : : private:
149 : : void ImplTrack( const Point& rScreenPos );
150 : :
151 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
152 : : virtual void Tracking( const TrackingEvent& rTEvt );
153 : : virtual void Paint( const Rectangle& rRect );
154 : :
155 : : Point maStartPos;
156 : : long mnStartWidth;
157 : : };
158 : :
159 : : // -----------------------------------------------------------------------
160 : :
161 : 463 : ImplTabSizer::ImplTabSizer( TabBar* pParent, WinBits nWinStyle )
162 : : : Window( pParent, nWinStyle & WB_3DLOOK )
163 : 463 : , mnStartWidth(0)
164 : : {
165 [ + - ]: 463 : SetPointer( Pointer( POINTER_HSIZEBAR ) );
166 [ + - ]: 463 : SetSizePixel( Size( 7, 0 ) );
167 : 463 : }
168 : :
169 : : // -----------------------------------------------------------------------
170 : :
171 : 0 : void ImplTabSizer::ImplTrack( const Point& rScreenPos )
172 : : {
173 : 0 : TabBar* pParent = GetParent();
174 : 0 : long nDiff = rScreenPos.X() - maStartPos.X();
175 [ # # ]: 0 : pParent->mnSplitSize = mnStartWidth + (pParent->IsMirrored() ? -nDiff : nDiff);
176 [ # # ]: 0 : if ( pParent->mnSplitSize < TABBAR_MINSIZE )
177 : 0 : pParent->mnSplitSize = TABBAR_MINSIZE;
178 : 0 : pParent->Split();
179 : 0 : pParent->Update();
180 : 0 : }
181 : :
182 : : // -----------------------------------------------------------------------
183 : :
184 : 0 : void ImplTabSizer::MouseButtonDown( const MouseEvent& rMEvt )
185 : : {
186 [ # # ]: 0 : if ( GetParent()->IsInEditMode() )
187 : : {
188 : 0 : GetParent()->EndEditMode();
189 : 0 : return;
190 : : }
191 : :
192 [ # # ]: 0 : if ( rMEvt.IsLeft() )
193 : : {
194 : 0 : maStartPos = OutputToScreenPixel( rMEvt.GetPosPixel() );
195 : 0 : mnStartWidth = GetParent()->GetSizePixel().Width();
196 : 0 : StartTracking();
197 : : }
198 : : }
199 : :
200 : : // -----------------------------------------------------------------------
201 : :
202 : 0 : void ImplTabSizer::Tracking( const TrackingEvent& rTEvt )
203 : : {
204 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
205 : : {
206 [ # # ]: 0 : if ( rTEvt.IsTrackingCanceled() )
207 : 0 : ImplTrack( maStartPos );
208 : 0 : GetParent()->mnSplitSize = 0;
209 : : }
210 : : else
211 [ # # ]: 0 : ImplTrack( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
212 : 0 : }
213 : :
214 : : // -----------------------------------------------------------------------
215 : :
216 : 390 : void ImplTabSizer::Paint( const Rectangle& )
217 : : {
218 : 390 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
219 : 390 : DecorationView aDecoView( this );
220 : 390 : long nOffX = 0;
221 : 390 : Size aOutputSize = GetOutputSizePixel();
222 : :
223 [ + - ]: 390 : if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
224 : : {
225 [ + - ]: 390 : SetLineColor( rStyleSettings.GetDarkShadowColor() );
226 [ + - ]: 390 : DrawLine( Point( 0, 0 ), Point( 0, aOutputSize.Height()-1 ) );
227 : 390 : nOffX++;
228 : 390 : aOutputSize.Width()--;
229 : : }
230 [ + - ][ + - ]: 390 : aDecoView.DrawButton( Rectangle( Point( nOffX, 0 ), aOutputSize ), BUTTON_DRAW_NOLIGHTBORDER );
231 : 390 : }
232 : :
233 : : // =======================================================================
234 : :
235 : : // Heisst nicht Impl, da evtl. mal von aussen benutz- und ueberladbar
236 : :
237 : : // --------------
238 : : // - TabBarEdit -
239 : : // --------------
240 : :
241 [ # # ][ # # ]: 0 : class TabBarEdit : public Edit
242 : : {
243 : : private:
244 : : Timer maLoseFocusTimer;
245 : : sal_Bool mbPostEvt;
246 : :
247 : : DECL_LINK( ImplEndEditHdl, void* );
248 : : DECL_LINK( ImplEndTimerHdl, void* );
249 : :
250 : : public:
251 : : TabBarEdit( TabBar* pParent, WinBits nWinStyle = 0 );
252 : :
253 : 0 : TabBar* GetParent() const { return (TabBar*)Window::GetParent(); }
254 : :
255 : 0 : void SetPostEvent() { mbPostEvt = sal_True; }
256 : 0 : void ResetPostEvent() { mbPostEvt = sal_False; }
257 : :
258 : : virtual long PreNotify( NotifyEvent& rNEvt );
259 : : virtual void LoseFocus();
260 : : };
261 : :
262 : : // -----------------------------------------------------------------------
263 : :
264 : 0 : TabBarEdit::TabBarEdit( TabBar* pParent, WinBits nWinStyle ) :
265 [ # # ]: 0 : Edit( pParent, nWinStyle )
266 : : {
267 : 0 : mbPostEvt = sal_False;
268 : 0 : }
269 : :
270 : : // -----------------------------------------------------------------------
271 : :
272 : 0 : long TabBarEdit::PreNotify( NotifyEvent& rNEvt )
273 : : {
274 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
275 : : {
276 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
277 [ # # ]: 0 : if ( !pKEvt->GetKeyCode().GetModifier() )
278 : : {
279 [ # # ]: 0 : if ( pKEvt->GetKeyCode().GetCode() == KEY_RETURN )
280 : : {
281 [ # # ]: 0 : if ( !mbPostEvt )
282 : : {
283 [ # # ][ # # ]: 0 : if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), (void*)sal_False ) )
284 : 0 : mbPostEvt = sal_True;
285 : : }
286 : 0 : return sal_True;
287 : : }
288 [ # # ]: 0 : else if ( pKEvt->GetKeyCode().GetCode() == KEY_ESCAPE )
289 : : {
290 [ # # ]: 0 : if ( !mbPostEvt )
291 : : {
292 [ # # ][ # # ]: 0 : if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), (void*)sal_True ) )
293 : 0 : mbPostEvt = sal_True;
294 : : }
295 : 0 : return sal_True;
296 : : }
297 : : }
298 : : }
299 : :
300 : 0 : return Edit::PreNotify( rNEvt );
301 : : }
302 : :
303 : : // -----------------------------------------------------------------------
304 : :
305 : 0 : void TabBarEdit::LoseFocus()
306 : : {
307 [ # # ]: 0 : if ( !mbPostEvt )
308 : : {
309 [ # # ][ # # ]: 0 : if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), (void*)sal_False ) )
310 : 0 : mbPostEvt = sal_True;
311 : : }
312 : :
313 : 0 : Edit::LoseFocus();
314 : 0 : }
315 : :
316 : : // -----------------------------------------------------------------------
317 : :
318 : 0 : IMPL_LINK( TabBarEdit, ImplEndEditHdl, void*, pCancel )
319 : : {
320 : 0 : ResetPostEvent();
321 : 0 : maLoseFocusTimer.Stop();
322 : :
323 : : // We need this query, because the edit get a losefous event,
324 : : // when it shows the context menu or the insert symbol dialog
325 [ # # ][ # # ]: 0 : if ( !HasFocus() && HasChildPathFocus( sal_True ) )
[ # # ]
326 : : {
327 : 0 : maLoseFocusTimer.SetTimeout( 30 );
328 : 0 : maLoseFocusTimer.SetTimeoutHdl( LINK( this, TabBarEdit, ImplEndTimerHdl ) );
329 : 0 : maLoseFocusTimer.Start();
330 : : }
331 : : else
332 : 0 : GetParent()->EndEditMode( pCancel != 0 );
333 : :
334 : 0 : return 0;
335 : : }
336 : :
337 : : // -----------------------------------------------------------------------
338 : :
339 : 0 : IMPL_LINK_NOARG(TabBarEdit, ImplEndTimerHdl)
340 : : {
341 [ # # ]: 0 : if ( HasFocus() )
342 : 0 : return 0;
343 : :
344 : : // We need this query, because the edit get a losefous event,
345 : : // when it shows the context menu or the insert symbol dialog
346 [ # # ]: 0 : if ( HasChildPathFocus( sal_True ) )
347 : 0 : maLoseFocusTimer.Start();
348 : : else
349 : 0 : GetParent()->EndEditMode( sal_True );
350 : :
351 : 0 : return 0;
352 : : }
353 : :
354 : : // =======================================================================
355 : : struct TabBar_Impl
356 : : {
357 : : ImplTabSizer* mpSizer;
358 : : ::svt::AccessibleFactoryAccess maAccessibleFactory;
359 : :
360 : 463 : TabBar_Impl()
361 : 463 : :mpSizer( NULL )
362 : : {
363 : 463 : }
364 : 459 : ~TabBar_Impl()
365 : 459 : {
366 [ + - ][ + - ]: 459 : delete mpSizer;
367 : 459 : }
368 : : };
369 : :
370 : : // =======================================================================
371 : :
372 : : const sal_uInt16 TabBar::APPEND = ::std::numeric_limits<sal_uInt16>::max();
373 : : const sal_uInt16 TabBar::PAGE_NOT_FOUND = ::std::numeric_limits<sal_uInt16>::max();
374 : : const sal_uInt16 TabBar::INSERT_TAB_POS = ::std::numeric_limits<sal_uInt16>::max() - 1;
375 : :
376 : 463 : void TabBar::ImplInit( WinBits nWinStyle )
377 : : {
378 [ + - ]: 463 : mpItemList = new ImplTabBarList;
379 : 463 : mpFirstBtn = NULL;
380 : 463 : mpPrevBtn = NULL;
381 : 463 : mpNextBtn = NULL;
382 : 463 : mpLastBtn = NULL;
383 [ + - ]: 463 : mpImpl = new TabBar_Impl;
384 : 463 : mpEdit = NULL;
385 : 463 : mnMaxPageWidth = 0;
386 : 463 : mnCurMaxWidth = 0;
387 : 463 : mnOffX = 0;
388 : 463 : mnOffY = 0;
389 : 463 : mnLastOffX = 0;
390 : 463 : mnSplitSize = 0;
391 : 463 : mnSwitchTime = 0;
392 : 463 : mnWinStyle = nWinStyle;
393 : 463 : mnCurPageId = 0;
394 : 463 : mnFirstPos = 0;
395 : 463 : mnDropPos = 0;
396 : 463 : mnSwitchId = 0;
397 : 463 : mnEditId = 0;
398 : 463 : mbFormat = sal_True;
399 : 463 : mbFirstFormat = sal_True;
400 : 463 : mbSizeFormat = sal_True;
401 : 463 : mbAutoMaxWidth = sal_True;
402 : 463 : mbInSwitching = sal_False;
403 : 463 : mbAutoEditMode = sal_False;
404 : 463 : mbEditCanceled = sal_False;
405 : 463 : mbDropPos = sal_False;
406 : 463 : mbInSelect = sal_False;
407 : 463 : mbSelColor = sal_False;
408 : 463 : mbSelTextColor = sal_False;
409 : 463 : mbMirrored = sal_False;
410 : :
411 [ - + ]: 463 : if ( nWinStyle & WB_3DTAB )
412 : 0 : mnOffY++;
413 : :
414 : 463 : ImplInitControls();
415 : :
416 [ + - ]: 463 : if(mpFirstBtn)
417 [ + - ][ + - ]: 463 : mpFirstBtn->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_MOVET0HOME));
[ + - ][ + - ]
418 [ + - ]: 463 : if(mpPrevBtn)
419 [ + - ][ + - ]: 463 : mpPrevBtn->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_MOVELEFT));
[ + - ][ + - ]
420 [ + - ]: 463 : if(mpNextBtn)
421 [ + - ][ + - ]: 463 : mpNextBtn->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_MOVERIGHT));
[ + - ][ + - ]
422 [ + - ]: 463 : if(mpLastBtn)
423 [ + - ][ + - ]: 463 : mpLastBtn->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_MOVETOEND));
[ + - ][ + - ]
424 : :
425 [ + - ]: 463 : SetSizePixel( Size( 100, CalcWindowSizePixel().Height() ) );
426 : 463 : ImplInitSettings( sal_True, sal_True );
427 : 463 : }
428 : :
429 : : // -----------------------------------------------------------------------
430 : :
431 : 463 : TabBar::TabBar( Window* pParent, WinBits nWinStyle ) :
432 [ + - ][ + - ]: 463 : Window( pParent, (nWinStyle & WB_3DLOOK) | WB_CLIPCHILDREN )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
433 : : {
434 [ + - ]: 463 : ImplInit( nWinStyle );
435 : 463 : maCurrentItemList = 0;
436 : 463 : }
437 : :
438 : : // -----------------------------------------------------------------------
439 : :
440 [ + - ]: 459 : TabBar::~TabBar()
441 : : {
442 [ + - ]: 459 : EndEditMode( sal_True );
443 : :
444 : : // Controls loeschen
445 [ + - ]: 459 : if ( mpPrevBtn )
446 [ + - ][ + - ]: 459 : delete mpPrevBtn;
447 [ + - ]: 459 : if ( mpNextBtn )
448 [ + - ][ + - ]: 459 : delete mpNextBtn;
449 [ + - ]: 459 : if ( mpFirstBtn )
450 [ + - ][ + - ]: 459 : delete mpFirstBtn;
451 [ + - ]: 459 : if ( mpLastBtn )
452 [ + - ][ + - ]: 459 : delete mpLastBtn;
453 [ + - ][ + - ]: 459 : delete mpImpl;
454 : :
455 [ + + ]: 1208 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
456 [ + - ][ + - ]: 749 : delete (*mpItemList)[ i ];
457 : : }
458 [ + - ]: 459 : delete mpItemList;
459 [ - + ]: 459 : }
460 : :
461 : : // -----------------------------------------------------------------------
462 : 890 : ImplTabBarItem* TabBar::seek( size_t i )
463 : : {
464 [ + - ]: 890 : if ( i < mpItemList->size() )
465 : : {
466 : 890 : maCurrentItemList = i;
467 : 890 : return (*mpItemList)[ maCurrentItemList ];
468 : : }
469 : 890 : return NULL;
470 : : }
471 : :
472 : 892 : ImplTabBarItem* TabBar::prev()
473 : : {
474 [ + + ]: 892 : if ( maCurrentItemList > 0 ) {
475 : 447 : return (*mpItemList)[ --maCurrentItemList ];
476 : : }
477 : 892 : return NULL;
478 : : }
479 : :
480 : 652 : ImplTabBarItem* TabBar::next()
481 : : {
482 [ + + ]: 652 : if ( maCurrentItemList+1 < mpItemList->size() ) {
483 : 207 : return (*mpItemList)[ ++maCurrentItemList ];
484 : : }
485 : 652 : return NULL;
486 : : }
487 : :
488 : : // -----------------------------------------------------------------------
489 : :
490 : 1407 : void TabBar::ImplInitSettings( sal_Bool bFont, sal_Bool bBackground )
491 : : {
492 : 1407 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
493 : :
494 [ + - ]: 1407 : if ( bFont )
495 : : {
496 [ + - ]: 1407 : Font aToolFont;
497 [ + - ]: 1407 : aToolFont = rStyleSettings.GetToolFont();
498 [ + - ][ - + ]: 1407 : if ( IsControlFont() )
499 [ # # ][ # # ]: 0 : aToolFont.Merge( GetControlFont() );
[ # # ]
500 [ + - ]: 1407 : aToolFont.SetWeight( WEIGHT_BOLD );
501 [ + - ]: 1407 : SetZoomedPointFont( aToolFont );
502 : :
503 : : // Font in der groesse Anpassen, wenn Fenster zu klein?
504 [ + - ][ + + ]: 3722 : while ( GetTextHeight() > (GetOutputSizePixel().Height()-1) )
505 : : {
506 [ + - ]: 2778 : Font aFont = GetFont();
507 [ + - ][ + + ]: 2778 : if ( aFont.GetHeight() <= 6 )
508 : : break;
509 [ + - ][ + - ]: 2315 : aFont.SetHeight( aFont.GetHeight()-1 );
510 [ + - ][ + + ]: 5093 : SetFont( aFont );
511 [ + - ][ + - ]: 4185 : }
512 : : }
513 : :
514 [ + + ]: 1407 : if ( bBackground )
515 : : {
516 : 463 : Color aColor;
517 [ - + ][ + - ]: 463 : if ( IsControlBackground() )
518 [ # # ]: 0 : aColor = GetControlBackground();
519 : : else
520 : 463 : aColor = rStyleSettings.GetFaceColor();
521 [ + - ][ + - ]: 463 : SetBackground( aColor );
[ + - ]
522 : : }
523 : 1407 : }
524 : :
525 : : // -----------------------------------------------------------------------
526 : :
527 : 445 : void TabBar::ImplGetColors( Color& rFaceColor, Color& rFaceTextColor,
528 : : Color& rSelectColor, Color& rSelectTextColor )
529 : : {
530 : 445 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
531 : :
532 [ - + ]: 445 : if ( IsControlBackground() )
533 : 0 : rFaceColor = GetControlBackground();
534 : : else
535 : 445 : rFaceColor = rStyleSettings.GetInactiveTabColor();
536 [ - + ]: 445 : if ( IsControlForeground() )
537 : 0 : rFaceTextColor = GetControlForeground();
538 : : else
539 : 445 : rFaceTextColor = rStyleSettings.GetButtonTextColor();
540 [ - + ]: 445 : if ( mbSelColor )
541 : 0 : rSelectColor = maSelColor;
542 : : else
543 : 445 : rSelectColor = rStyleSettings.GetActiveTabColor();
544 [ - + ]: 445 : if ( mbSelTextColor )
545 : 0 : rSelectTextColor = maSelTextColor;
546 : : else
547 : 445 : rSelectTextColor = rStyleSettings.GetWindowTextColor();
548 : :
549 : : // Bei 3D-Tabs wird Selektions- und Face-Farbe umgedreht, da die
550 : : // selektierten Tabs in 3D erscheinen sollen
551 [ - + ]: 445 : if ( mnWinStyle & WB_3DTAB )
552 : : {
553 : 0 : Color aTempColor = rFaceColor;
554 : 0 : rFaceColor = rSelectColor;
555 : 0 : rSelectColor = aTempColor;
556 : 0 : aTempColor = rFaceTextColor;
557 : 0 : rFaceTextColor = rSelectTextColor;
558 : 0 : rSelectTextColor = rFaceTextColor;
559 : : }
560 : 445 : }
561 : :
562 : : // -----------------------------------------------------------------------
563 : :
564 : 1235 : sal_Bool TabBar::ImplCalcWidth()
565 : : {
566 : : // Groessen muessen nur ermittelt werden, wenn sich Text aendert oder
567 : : // wenn der Font geaendert wurde
568 [ + + ]: 1235 : if ( !mbSizeFormat )
569 : 287 : return sal_False;
570 : :
571 : : // Breiten der Tabs mit dem fetten Font ermitteln
572 [ + - ]: 948 : Font aFont = GetFont();
573 [ + - ][ - + ]: 948 : if ( aFont.GetWeight() != WEIGHT_BOLD )
574 : : {
575 [ # # ]: 0 : aFont.SetWeight( WEIGHT_BOLD );
576 [ # # ]: 0 : SetFont( aFont );
577 : : }
578 : :
579 [ + + ]: 948 : if ( mnMaxPageWidth )
580 : 330 : mnCurMaxWidth = mnMaxPageWidth;
581 [ + - ]: 618 : else if ( mbAutoMaxWidth )
582 : : {
583 : : mnCurMaxWidth = mnLastOffX-mnOffX-
584 : : TABBAR_OFFSET_X-TABBAR_OFFSET_X-
585 : 618 : TABBAR_OFFSET_X2-TABBAR_OFFSET_X2-TABBAR_OFFSET_X2;
586 [ - + ]: 618 : if ( mnCurMaxWidth < 1 )
587 : 0 : mnCurMaxWidth = 1;
588 : : }
589 : : else
590 : 0 : mnCurMaxWidth = 0;
591 : :
592 : 948 : sal_Bool bChanged = sal_False;
593 [ + + ]: 2569 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
594 : : {
595 : 1621 : ImplTabBarItem* pItem = (*mpItemList)[ i ];
596 [ + - ]: 1621 : long nNewWidth = GetTextWidth( pItem->maText );
597 [ + - ][ + + ]: 1621 : if ( mnCurMaxWidth && (nNewWidth > mnCurMaxWidth) )
598 : : {
599 : 2 : pItem->mbShort = sal_True;
600 : 2 : nNewWidth = mnCurMaxWidth;
601 : : }
602 : : else
603 : 1619 : pItem->mbShort = sal_False;
604 : 1621 : nNewWidth += TABBAR_OFFSET_X+TABBAR_OFFSET_X2;
605 [ + + ]: 1621 : if ( pItem->mnWidth != nNewWidth )
606 : : {
607 : 1321 : pItem->mnWidth = nNewWidth;
608 [ + - ][ + + ]: 1321 : if ( !pItem->maRect.IsEmpty() )
609 : 185 : bChanged = sal_True;
610 : : }
611 : : }
612 : 948 : mbSizeFormat = sal_False;
613 : 948 : mbFormat = sal_True;
614 [ + - ]: 1235 : return bChanged;
615 : : }
616 : :
617 : : // -----------------------------------------------------------------------
618 : :
619 : 1087 : void TabBar::ImplFormat()
620 : : {
621 : 1087 : ImplCalcWidth();
622 : :
623 [ + + ]: 1087 : if ( !mbFormat )
624 : 1087 : return;
625 : :
626 : 967 : sal_uInt16 n = 0;
627 : 967 : long x = mnOffX;
628 [ + + ]: 2630 : for ( size_t i = 0, nL = mpItemList->size(); i < nL; ++i )
629 : : {
630 : 1663 : ImplTabBarItem* pItem = (*mpItemList)[ i ];
631 : : // Bei allen nicht sichtbaren Tabs, wird ein leeres Rechteck
632 : : // gesetzt
633 [ + + ][ + - ]: 1663 : if ( (n+1 < mnFirstPos) || (x > mnLastOffX) )
634 : 434 : pItem->maRect.SetEmpty();
635 : : else
636 : : {
637 : : // Etwas von der Tab vor der ersten sichtbaren Page
638 : : // muss auch zu sehen sein
639 [ - + ]: 1229 : if ( n+1 == mnFirstPos )
640 : 0 : pItem->maRect.Left() = x-pItem->mnWidth;
641 : : else
642 : : {
643 : 1229 : pItem->maRect.Left() = x;
644 : 1229 : x += pItem->mnWidth;
645 : : }
646 : 1229 : pItem->maRect.Right() = x+TABBAR_OFFSET_X+TABBAR_OFFSET_X2;
647 : 1229 : pItem->maRect.Bottom() = maWinSize.Height()-1;
648 : :
649 [ + + ]: 1229 : if( mbMirrored )
650 : : {
651 : 2 : long nTmp = mnOffX + mnLastOffX - pItem->maRect.Right();
652 : 2 : pItem->maRect.Right() = mnOffX + mnLastOffX - pItem->maRect.Left();
653 : 2 : pItem->maRect.Left() = nTmp;
654 : : }
655 : : }
656 : :
657 : 1663 : n++;
658 : : }
659 : :
660 : 967 : mbFormat = sal_False;
661 : :
662 : : // Button enablen/disablen
663 : 967 : ImplEnableControls();
664 : : }
665 : :
666 : : // -----------------------------------------------------------------------
667 : :
668 : 1117 : sal_uInt16 TabBar::ImplGetLastFirstPos()
669 : : {
670 : 1117 : sal_uInt16 nCount = (sal_uInt16)(mpItemList->size());
671 [ + - ][ - + ]: 1117 : if ( !nCount || mbSizeFormat || mbFormat )
[ + - ]
672 : 0 : return 0;
673 : :
674 : 1117 : sal_uInt16 nLastFirstPos = nCount-1;
675 : 1117 : long nWinWidth = mnLastOffX-mnOffX-TABBAR_OFFSET_X-ADDNEWPAGE_AREAWIDTH;
676 : 1117 : long nWidth = (*mpItemList)[ nLastFirstPos ]->mnWidth;
677 [ + + ][ + + ]: 1726 : while ( nLastFirstPos && (nWidth < nWinWidth) )
[ + + ]
678 : : {
679 : 609 : nLastFirstPos--;
680 : 609 : nWidth += (*mpItemList)[ nLastFirstPos ]->mnWidth;
681 : : }
682 [ + + ][ + + ]: 1117 : if ( (nLastFirstPos != (sal_uInt16)(mpItemList->size()-1)) &&
[ + + ]
683 : : (nWidth > nWinWidth) )
684 : 31 : nLastFirstPos++;
685 : 1117 : return nLastFirstPos;
686 : : }
687 : :
688 : : // -----------------------------------------------------------------------
689 : :
690 : 1228 : void TabBar::ImplInitControls()
691 : : {
692 [ + - ]: 1228 : if ( mnWinStyle & WB_SIZEABLE )
693 : : {
694 [ + + ]: 1228 : if ( !mpImpl->mpSizer )
695 [ + - ][ + - ]: 463 : mpImpl->mpSizer = new ImplTabSizer( this, mnWinStyle & (WB_DRAG | WB_3DLOOK) );
696 [ + - ]: 1228 : mpImpl->mpSizer->Show();
697 : : }
698 : : else
699 : : {
700 [ # # ][ # # ]: 0 : DELETEZ( mpImpl->mpSizer );
701 : : }
702 : :
703 [ + - ]: 1228 : Link aLink = LINK( this, TabBar, ImplClickHdl );
704 : :
705 [ + - ]: 1228 : if ( mnWinStyle & (WB_MINSCROLL | WB_SCROLL) )
706 : : {
707 [ + + ]: 1228 : if ( !mpPrevBtn )
708 : : {
709 [ + - ][ + - ]: 463 : mpPrevBtn = new ImplTabButton( this, WB_REPEAT );
710 : 463 : mpPrevBtn->SetClickHdl( aLink );
711 : : }
712 [ + + ][ + - ]: 1228 : mpPrevBtn->SetSymbol( mbMirrored ? SYMBOL_NEXT : SYMBOL_PREV );
713 [ + - ]: 1228 : mpPrevBtn->Show();
714 : :
715 [ + + ]: 1228 : if ( !mpNextBtn )
716 : : {
717 [ + - ][ + - ]: 463 : mpNextBtn = new ImplTabButton( this, WB_REPEAT );
718 : 463 : mpNextBtn->SetClickHdl( aLink );
719 : : }
720 [ + + ][ + - ]: 1228 : mpNextBtn->SetSymbol( mbMirrored ? SYMBOL_PREV : SYMBOL_NEXT );
721 [ + - ]: 1228 : mpNextBtn->Show();
722 : : }
723 : : else
724 : : {
725 [ # # ][ # # ]: 0 : DELETEZ( mpPrevBtn );
726 [ # # ][ # # ]: 0 : DELETEZ( mpNextBtn );
727 : : }
728 : :
729 [ + - ]: 1228 : if ( mnWinStyle & WB_SCROLL )
730 : : {
731 [ + + ]: 1228 : if ( !mpFirstBtn )
732 : : {
733 [ + - ][ + - ]: 463 : mpFirstBtn = new ImplTabButton( this );
734 : 463 : mpFirstBtn->SetClickHdl( aLink );
735 : : }
736 [ + + ][ + - ]: 1228 : mpFirstBtn->SetSymbol( mbMirrored ? SYMBOL_LAST : SYMBOL_FIRST );
737 [ + - ]: 1228 : mpFirstBtn->Show();
738 : :
739 [ + + ]: 1228 : if ( !mpLastBtn )
740 : : {
741 [ + - ][ + - ]: 463 : mpLastBtn = new ImplTabButton( this );
742 : 463 : mpLastBtn->SetClickHdl( aLink );
743 : : }
744 [ + + ][ + - ]: 1228 : mpLastBtn->SetSymbol( mbMirrored ? SYMBOL_FIRST : SYMBOL_LAST );
745 [ + - ]: 1228 : mpLastBtn->Show();
746 : : }
747 : : else
748 : : {
749 [ # # ][ # # ]: 0 : DELETEZ( mpFirstBtn );
750 [ # # ][ # # ]: 0 : DELETEZ( mpLastBtn );
751 : : }
752 : :
753 : 1228 : mbHasInsertTab = (mnWinStyle & WB_INSERTTAB);
754 : 1228 : }
755 : :
756 : : // -----------------------------------------------------------------------
757 : :
758 : 1911 : void TabBar::ImplEnableControls()
759 : : {
760 [ + + ][ - + ]: 1911 : if ( mbSizeFormat || mbFormat )
761 : 1911 : return;
762 : :
763 : : // Buttons enablen/disblen
764 : 1115 : sal_Bool bEnableBtn = mnFirstPos > 0;
765 [ + - ]: 1115 : if ( mpFirstBtn )
766 : 1115 : mpFirstBtn->Enable( bEnableBtn );
767 [ + - ]: 1115 : if ( mpPrevBtn )
768 : 1115 : mpPrevBtn->Enable( bEnableBtn );
769 : :
770 : 1115 : bEnableBtn = mnFirstPos < ImplGetLastFirstPos();
771 [ + - ]: 1115 : if ( mpNextBtn )
772 : 1115 : mpNextBtn->Enable( bEnableBtn );
773 [ + - ]: 1115 : if ( mpLastBtn )
774 : 1115 : mpLastBtn->Enable( bEnableBtn );
775 : : }
776 : :
777 : : // -----------------------------------------------------------------------
778 : :
779 : 0 : void TabBar::ImplShowPage( sal_uInt16 nPos )
780 : : {
781 : : // Breite berechnen
782 : 0 : long nWidth = GetOutputSizePixel().Width();
783 [ # # ]: 0 : if ( nWidth >= TABBAR_OFFSET_X )
784 : 0 : nWidth -= TABBAR_OFFSET_X;
785 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
786 [ # # ]: 0 : if ( nPos < mnFirstPos )
787 : 0 : SetFirstPageId( pItem->mnId );
788 [ # # ]: 0 : else if ( pItem->maRect.Right() > nWidth )
789 : : {
790 [ # # ]: 0 : while ( pItem->maRect.Right() > nWidth )
791 : : {
792 : 0 : sal_uInt16 nNewPos = mnFirstPos+1;
793 : 0 : SetFirstPageId( GetPageId( nNewPos ) );
794 : 0 : ImplFormat();
795 [ # # ]: 0 : if ( nNewPos != mnFirstPos )
796 : 0 : break;
797 : : }
798 : : }
799 : 0 : }
800 : :
801 : : // -----------------------------------------------------------------------
802 : :
803 : 0 : IMPL_LINK( TabBar, ImplClickHdl, ImplTabButton*, pBtn )
804 : : {
805 : 0 : EndEditMode();
806 : :
807 : 0 : sal_uInt16 nNewPos = mnFirstPos;
808 : :
809 [ # # ]: 0 : if ( pBtn == mpFirstBtn )
810 : 0 : nNewPos = 0;
811 [ # # ]: 0 : else if ( pBtn == mpPrevBtn )
812 : : {
813 [ # # ]: 0 : if ( mnFirstPos )
814 : 0 : nNewPos = mnFirstPos-1;
815 : : }
816 [ # # ]: 0 : else if ( pBtn == mpNextBtn )
817 : : {
818 : 0 : sal_uInt16 nCount = GetPageCount();
819 [ # # ]: 0 : if ( mnFirstPos < nCount )
820 : 0 : nNewPos = mnFirstPos+1;
821 : : }
822 : : else
823 : : {
824 : 0 : sal_uInt16 nCount = GetPageCount();
825 [ # # ]: 0 : if ( nCount )
826 : 0 : nNewPos = nCount-1;
827 : : }
828 : :
829 [ # # ]: 0 : if ( nNewPos != mnFirstPos )
830 : 0 : SetFirstPageId( GetPageId( nNewPos ) );
831 : 0 : return 0;
832 : : }
833 : :
834 : : // -----------------------------------------------------------------------
835 : :
836 : 0 : void TabBar::MouseMove( const MouseEvent& rMEvt )
837 : : {
838 [ # # ]: 0 : if ( rMEvt.IsLeaveWindow() )
839 : 0 : mbInSelect = sal_False;
840 : :
841 : 0 : Window::MouseMove( rMEvt );
842 : 0 : }
843 : :
844 : : // -----------------------------------------------------------------------
845 : :
846 : 0 : void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
847 : : {
848 : : // Bei Klick in unser Fenster EditModus nur beenden und Klick nicht
849 : : // ausfuehren
850 [ # # ]: 0 : if ( IsInEditMode() )
851 : : {
852 : 0 : EndEditMode();
853 : 0 : return;
854 : : }
855 : :
856 : : ImplTabBarItem* pItem;
857 : 0 : sal_uInt16 nSelId = GetPageId( rMEvt.GetPosPixel() );
858 : :
859 [ # # ]: 0 : if ( !rMEvt.IsLeft() )
860 : : {
861 : 0 : Window::MouseButtonDown( rMEvt );
862 [ # # ][ # # ]: 0 : if ( (nSelId > 0) && (nSelId != mnCurPageId) )
863 : : {
864 : 0 : sal_uInt16 nPos = GetPagePos( nSelId );
865 : 0 : pItem = (*mpItemList)[ nPos ];
866 : :
867 [ # # ]: 0 : if ( pItem->mbEnable )
868 : : {
869 [ # # ]: 0 : if ( ImplDeactivatePage() )
870 : : {
871 : 0 : SetCurPageId( nSelId );
872 : 0 : Update();
873 : 0 : ImplActivatePage();
874 : 0 : ImplSelect();
875 : : }
876 : 0 : mbInSelect = sal_True;
877 : : }
878 : : }
879 : 0 : return;
880 : : }
881 : :
882 [ # # ][ # # ]: 0 : if ( rMEvt.IsMod2() && mbAutoEditMode && nSelId )
[ # # ][ # # ]
883 : : {
884 [ # # ]: 0 : if ( StartEditMode( nSelId ) )
885 : 0 : return;
886 : : }
887 : :
888 [ # # ][ # # ]: 0 : if ( (rMEvt.GetMode() & (MOUSE_MULTISELECT | MOUSE_RANGESELECT)) && (rMEvt.GetClicks() == 1) )
[ # # ]
889 : : {
890 [ # # ]: 0 : if ( nSelId )
891 : : {
892 : 0 : sal_uInt16 nPos = GetPagePos( nSelId );
893 : 0 : sal_Bool bSelectTab = sal_False;
894 : 0 : pItem = (*mpItemList)[ nPos ];
895 : :
896 [ # # ]: 0 : if ( pItem->mbEnable )
897 : : {
898 [ # # ][ # # ]: 0 : if ( (rMEvt.GetMode() & MOUSE_MULTISELECT) && (mnWinStyle & WB_MULTISELECT) )
[ # # ]
899 : : {
900 [ # # ]: 0 : if ( nSelId != mnCurPageId )
901 : : {
902 : 0 : SelectPage( nSelId, !IsPageSelected( nSelId ) );
903 : 0 : bSelectTab = sal_True;
904 : : }
905 : : }
906 [ # # ]: 0 : else if ( mnWinStyle & (WB_MULTISELECT | WB_RANGESELECT) )
907 : : {
908 : 0 : bSelectTab = sal_True;
909 : : sal_uInt16 n;
910 : : sal_Bool bSelect;
911 : 0 : sal_uInt16 nCurPos = GetPagePos( mnCurPageId );
912 [ # # ]: 0 : if ( nPos <= nCurPos )
913 : : {
914 : : // Alle Tabs bis zur angeklickten Tab deselektieren
915 : : // und alle Tabs von der angeklickten Tab bis
916 : : // zur aktuellen Position selektieren
917 : 0 : n = 0;
918 [ # # ]: 0 : while ( n < nCurPos )
919 : : {
920 : 0 : pItem = (*mpItemList)[ n ];
921 [ # # ]: 0 : if ( n < nPos )
922 : 0 : bSelect = sal_False;
923 : : else
924 : 0 : bSelect = sal_True;
925 : :
926 [ # # ]: 0 : if ( pItem->mbSelect != bSelect )
927 : : {
928 : 0 : pItem->mbSelect = bSelect;
929 [ # # ]: 0 : if ( !pItem->maRect.IsEmpty() )
930 : 0 : Invalidate( pItem->maRect );
931 : : }
932 : :
933 : 0 : n++;
934 : : }
935 : : }
936 : :
937 [ # # ]: 0 : if ( nPos >= nCurPos )
938 : : {
939 : : // Alle Tabs von der aktuellen bis zur angeklickten
940 : : // Tab selektieren und alle Tabs von der angeklickten
941 : : // Tab bis zur letzten Tab deselektieren
942 : 0 : sal_uInt16 nCount = (sal_uInt16)mpItemList->size();
943 : 0 : n = nCurPos;
944 [ # # ]: 0 : while ( n < nCount )
945 : : {
946 : 0 : pItem = (*mpItemList)[ n ];
947 : :
948 [ # # ]: 0 : if ( n <= nPos )
949 : 0 : bSelect = sal_True;
950 : : else
951 : 0 : bSelect = sal_False;
952 : :
953 [ # # ]: 0 : if ( pItem->mbSelect != bSelect )
954 : : {
955 : 0 : pItem->mbSelect = bSelect;
956 [ # # ]: 0 : if ( !pItem->maRect.IsEmpty() )
957 : 0 : Invalidate( pItem->maRect );
958 : : }
959 : :
960 : 0 : n++;
961 : : }
962 : : }
963 : : }
964 : :
965 : : // Gegebenenfalls muss die selektierte Tab gescrollt werden
966 [ # # ]: 0 : if ( bSelectTab )
967 : : {
968 : 0 : ImplShowPage( nPos );
969 : 0 : Update();
970 : 0 : ImplSelect();
971 : : }
972 : : }
973 : : else
974 : 0 : ImplShowPage( nPos );
975 : 0 : mbInSelect = sal_True;
976 : :
977 : 0 : return;
978 : : }
979 : : }
980 [ # # ]: 0 : else if ( rMEvt.GetClicks() == 2 )
981 : : {
982 : : // Gegebenenfalls den Double-Click-Handler rufen
983 [ # # ][ # # ]: 0 : if ( !rMEvt.GetModifier() && (!nSelId || (nSelId == mnCurPageId)) )
[ # # ][ # # ]
984 : : {
985 : 0 : sal_uInt16 nOldCurId = mnCurPageId;
986 : 0 : mnCurPageId = nSelId;
987 : 0 : DoubleClick();
988 : : // Abfrage, da im DoubleClick-Handler die aktuelle Seite
989 : : // umgeschaltet werden konnte
990 [ # # ]: 0 : if ( mnCurPageId == nSelId )
991 : 0 : mnCurPageId = nOldCurId;
992 : : }
993 : :
994 : 0 : return;
995 : : }
996 : : else
997 : : {
998 [ # # ]: 0 : if ( nSelId )
999 : : {
1000 : : // Nur Select ausfuehren, wenn noch nicht aktuelle Page
1001 [ # # ]: 0 : if ( nSelId != mnCurPageId )
1002 : : {
1003 : 0 : sal_uInt16 nPos = GetPagePos( nSelId );
1004 : 0 : pItem = (*mpItemList)[ nPos ];
1005 : :
1006 [ # # ]: 0 : if ( pItem->mbEnable )
1007 : : {
1008 [ # # ]: 0 : if ( !pItem->mbSelect )
1009 : : {
1010 : : // Muss invalidiert werden
1011 : 0 : sal_Bool bUpdate = sal_False;
1012 [ # # ][ # # ]: 0 : if ( IsReallyVisible() && IsUpdateMode() )
[ # # ]
1013 : 0 : bUpdate = sal_True;
1014 : :
1015 : : // Alle selektierten Items deselektieren
1016 [ # # ]: 0 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
1017 : : {
1018 : 0 : pItem = (*mpItemList)[ i ];
1019 [ # # ][ # # ]: 0 : if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) )
1020 : : {
1021 : 0 : pItem->mbSelect = sal_False;
1022 [ # # ]: 0 : if ( bUpdate )
1023 : 0 : Invalidate( pItem->maRect );
1024 : : }
1025 : : }
1026 : : }
1027 : :
1028 [ # # ]: 0 : if ( ImplDeactivatePage() )
1029 : : {
1030 : 0 : SetCurPageId( nSelId );
1031 : 0 : Update();
1032 : 0 : ImplActivatePage();
1033 : 0 : ImplSelect();
1034 : : }
1035 : : }
1036 : : else
1037 : 0 : ImplShowPage( nPos );
1038 : 0 : mbInSelect = sal_True;
1039 : : }
1040 : :
1041 : 0 : return;
1042 : : }
1043 : : }
1044 : :
1045 : 0 : Window::MouseButtonDown( rMEvt );
1046 : : }
1047 : :
1048 : : // -----------------------------------------------------------------------
1049 : :
1050 : 0 : void TabBar::MouseButtonUp( const MouseEvent& rMEvt )
1051 : : {
1052 : 0 : mbInSelect = sal_False;
1053 : 0 : Window::MouseButtonUp( rMEvt );
1054 : 0 : }
1055 : :
1056 : :
1057 : : // -----------------------------------------------------------------------
1058 : :
1059 : : namespace {
1060 : :
1061 : : class TabBarPaintGuard
1062 : : {
1063 : : public:
1064 : 445 : explicit TabBarPaintGuard(TabBar& rParent) :
1065 : : mrParent(rParent),
1066 : 445 : maFont(rParent.GetFont())
1067 : : {
1068 : : // #i36013# exclude push buttons from painting area
1069 [ + - ][ + - ]: 445 : mrParent.SetClipRegion( Region(mrParent.GetPageArea()) );
[ + - ][ + - ]
1070 : 445 : }
1071 : :
1072 : 445 : ~TabBarPaintGuard()
1073 : 445 : {
1074 : : // Restore original font.
1075 [ + - ]: 445 : mrParent.SetFont(maFont);
1076 : : // remove clip region
1077 [ + - ]: 445 : mrParent.SetClipRegion();
1078 : 445 : }
1079 : : private:
1080 : : TabBar& mrParent;
1081 : : Font maFont;
1082 : : };
1083 : :
1084 : 445 : class TabDrawer
1085 : : {
1086 : : public:
1087 : :
1088 : 445 : explicit TabDrawer(TabBar& rParent) :
1089 : : mrParent(rParent),
1090 : 445 : mpStyleSettings(&mrParent.GetSettings().GetStyleSettings()),
1091 : : maPoly(4),
1092 : : mbSelected(false),
1093 : : mbCustomColored(false),
1094 : : mbSpecialTab(false),
1095 : 445 : mbEnabled(false)
1096 : : {
1097 : 445 : }
1098 : :
1099 : 445 : void drawOutputAreaBorder()
1100 : : {
1101 : 445 : WinBits nWinStyle = mrParent.GetStyle();
1102 : :
1103 : : // Bei Border oben und unten einen Strich extra malen
1104 [ # # ][ - + ]: 445 : if ( (nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER) )
1105 : : {
1106 : 445 : Size aOutputSize = mrParent.GetOutputSizePixel();
1107 [ + - ]: 445 : Rectangle aOutRect = mrParent.GetPageArea();
1108 : :
1109 : : // Bei 3D-Tabs wird auch der Border in 3D gemalt
1110 [ - + ]: 445 : if ( nWinStyle & WB_3DTAB )
1111 : : {
1112 [ # # ]: 0 : mrParent.SetLineColor( mpStyleSettings->GetShadowColor() );
1113 [ # # ]: 0 : mrParent.DrawLine( Point( aOutRect.Left(), 0 ), Point( aOutputSize.Width(), 0 ) );
1114 : : }
1115 : :
1116 : : // Border malen (Strich oben und Strich unten)
1117 [ + - ]: 445 : mrParent.SetLineColor( mpStyleSettings->GetDarkShadowColor() );
1118 [ + - ]: 445 : mrParent.DrawLine( aOutRect.TopLeft(), Point( aOutputSize.Width()-1, aOutRect.Top() ) );
1119 : : }
1120 : 445 : }
1121 : :
1122 : 2304 : void drawOuterFrame()
1123 : : {
1124 : 2304 : mrParent.DrawPolygon(maPoly);
1125 : 2304 : }
1126 : :
1127 : 1152 : void drawLeftShadow()
1128 : : {
1129 [ + - ][ + - ]: 1152 : Point p1 = maPoly[0], p2 = maPoly[1];
1130 : 1152 : p1.X()++;
1131 : 1152 : p2.X()++;
1132 : 1152 : p2.Y()--;
1133 [ + - ]: 1152 : mrParent.DrawLine(p1, p2);
1134 : 1152 : }
1135 : :
1136 : 1152 : void drawRightShadow()
1137 : : {
1138 [ + - ]: 1152 : Point p1 = maPoly[2];
1139 [ + - ]: 1152 : Point p2 = maPoly[3];
1140 : 1152 : p1.X()--;
1141 : 1152 : p2.X()--;
1142 [ + - ]: 1152 : mrParent.DrawLine(p1, p2);
1143 : 1152 : }
1144 : :
1145 : 707 : void drawTopInnerShadow()
1146 : : {
1147 [ + - ][ + - ]: 707 : Point p1 = maPoly[0], p2 = maPoly[3];
1148 : 707 : p1.Y()++;
1149 : 707 : p2.Y()++;
1150 [ + - ]: 707 : mrParent.DrawLine(p1, p2);
1151 : 707 : }
1152 : :
1153 : 1152 : void drawBottomShadow(bool bColored)
1154 : : {
1155 [ + - ][ + - ]: 1152 : Point p1 = maPoly[1], p2 = maPoly[2];
1156 : 1152 : p1.X() += 1;
1157 : 1152 : p1.Y() -= 1;
1158 : 1152 : p2.X() -= 1;
1159 : 1152 : p2.Y() -= 1;
1160 [ + - ]: 1152 : mrParent.DrawLine(p1, p2);
1161 [ - + ]: 1152 : if (bColored)
1162 : : {
1163 : 0 : p1 += Point(-1, -1);
1164 : 0 : p2 += Point(1, -1);
1165 [ # # ]: 0 : mrParent.DrawLine(p1, p2);
1166 : : }
1167 : 1152 : }
1168 : :
1169 : 892 : void drawText(const String& aText)
1170 : : {
1171 : 892 : Rectangle aRect = maRect;
1172 [ + - ]: 892 : long nTextWidth = mrParent.GetTextWidth(aText);
1173 [ + - ]: 892 : long nTextHeight = mrParent.GetTextHeight();
1174 : 892 : Point aPos = aRect.TopLeft();
1175 : 892 : aPos.X() += (aRect.getWidth() - nTextWidth) / 2;
1176 : 892 : aPos.Y() += (aRect.getHeight() - nTextHeight) / 2;
1177 : :
1178 [ + - ]: 892 : if (mbEnabled)
1179 [ + - ]: 892 : mrParent.DrawText(aPos, aText);
1180 : : else
1181 : : mrParent.DrawCtrlText(
1182 [ # # ]: 0 : aPos, aText, 0, STRING_LEN, (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
1183 : 892 : }
1184 : :
1185 : 445 : void drawOverTopBorder(bool b3DTab)
1186 : : {
1187 [ + - ][ + - ]: 445 : Point p1 = maPoly[0], p2 = maPoly[3];
1188 : 445 : p1.X() += 1;
1189 : 445 : p2.X() -= 1;
1190 [ + - ]: 445 : Rectangle aDelRect(p1, p2);
1191 [ + - ]: 445 : mrParent.DrawRect(aDelRect);
1192 [ - + ]: 445 : if (b3DTab)
1193 : : {
1194 : 0 : aDelRect.Top()--;
1195 [ # # ]: 0 : mrParent.DrawRect(aDelRect);
1196 : : }
1197 : 445 : }
1198 : :
1199 : 1152 : void drawTab()
1200 : : {
1201 [ + - ]: 1152 : mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
1202 : :
1203 : : // Je nach Status die richtige FillInBrush setzen
1204 : : // Set the correct FillInBrush depending upon status
1205 [ + + ]: 1152 : if ( mbSelected )
1206 : : {
1207 : : // Currently selected Tab
1208 [ + - ]: 445 : mrParent.SetFillColor( maSelectedColor );
1209 : : }
1210 [ - + ]: 707 : else if ( mbCustomColored )
1211 : : {
1212 [ # # ]: 0 : mrParent.SetFillColor( maCustomColor );
1213 : : }
1214 : : else
1215 : : {
1216 [ + - ]: 707 : mrParent.SetFillColor( maUnselectedColor );
1217 : : }
1218 : :
1219 [ + - ]: 1152 : drawOuterFrame();
1220 : :
1221 : : // If this is the current tab, draw the left inner shadow the default color,
1222 : : // otherwise make it the same as the custom background color
1223 : 1152 : Color aColor = mpStyleSettings->GetLightColor();
1224 [ # # ][ - + ]: 1152 : if (mbCustomColored && !mbSelected)
1225 : 0 : aColor = maCustomColor;
1226 : :
1227 [ + - ]: 1152 : mrParent.SetLineColor(aColor);
1228 [ + - ]: 1152 : drawLeftShadow();
1229 : :
1230 [ + + ]: 1152 : if ( !mbSelected )
1231 [ + - ]: 707 : drawTopInnerShadow();
1232 : :
1233 [ + - ]: 1152 : mrParent.SetLineColor( mpStyleSettings->GetShadowColor() );
1234 [ + - ]: 1152 : drawRightShadow();
1235 [ - + ][ # # ]: 1152 : if ( mbCustomColored && mbSelected )
1236 : : {
1237 [ # # ]: 0 : mrParent.SetLineColor(maCustomColor);
1238 [ # # ]: 0 : drawBottomShadow(true);
1239 : : }
1240 : : else
1241 [ + - ]: 1152 : drawBottomShadow(false);
1242 : :
1243 : : // Draw the outer frame once more. In some environments, the outer frame
1244 : : // gets overpainted.
1245 [ + - ]: 1152 : mrParent.SetLineColor( mpStyleSettings->GetDarkShadowColor() );
1246 [ + - ]: 1152 : mrParent.SetFillColor();
1247 [ + - ]: 1152 : drawOuterFrame();
1248 : 1152 : }
1249 : :
1250 : 260 : void drawPlusImage()
1251 : : {
1252 [ + - ]: 260 : SvtResId id( BMP_LIST_ADD );
1253 [ + - ]: 260 : Image aPlusImg( id );
1254 : : // Center the image within the bounding rectangle.
1255 [ + - ]: 260 : Size aSize = aPlusImg.GetSizePixel();
1256 : 260 : Point pt = maRect.TopLeft();
1257 [ + - ]: 260 : long nXOffSet = (maRect.GetWidth() - aSize.Width()) / 2;
1258 [ + - ]: 260 : long nYOffset = (maRect.GetHeight() - aSize.Height()) / 2;
1259 : 260 : pt += Point(nXOffSet, nYOffset);
1260 : 260 : pt.X() += 1;
1261 [ + - ][ + - ]: 260 : mrParent.DrawImage(pt, aPlusImg);
1262 : 260 : }
1263 : :
1264 : 1152 : void setRect(const Rectangle& rRect)
1265 : : {
1266 : 1152 : maRect = rRect;
1267 : :
1268 : 1152 : long nOffY = mrParent.GetPageArea().getY();
1269 : :
1270 : : // Zuerst geben wir das Polygon gefuellt aus
1271 : 1152 : maPoly[0] = Point( rRect.Left(), nOffY );
1272 : 1152 : maPoly[1] = Point( rRect.Left()+TABBAR_OFFSET_X, rRect.Bottom() );
1273 : 1152 : maPoly[2] = Point( rRect.Right()-TABBAR_OFFSET_X, rRect.Bottom() );
1274 : 1152 : maPoly[3] = Point( rRect.Right(), nOffY );
1275 : 1152 : }
1276 : :
1277 : 892 : void setSelected(bool b)
1278 : : {
1279 : 892 : mbSelected = b;
1280 : 892 : }
1281 : :
1282 : 892 : void setCustomColored(bool b)
1283 : : {
1284 : 892 : mbCustomColored = b;
1285 : 892 : }
1286 : :
1287 : 892 : void setSpecialTab(bool b)
1288 : : {
1289 : 892 : mbSpecialTab = b;
1290 : 892 : }
1291 : :
1292 : 892 : void setEnabled(bool b)
1293 : : {
1294 : 892 : mbEnabled = b;
1295 : 892 : }
1296 : :
1297 : 445 : void setSelectedFillColor(const Color& rColor)
1298 : : {
1299 : 445 : maSelectedColor = rColor;
1300 : 445 : }
1301 : :
1302 : 445 : void setUnselectedFillColor(const Color& rColor)
1303 : : {
1304 : 445 : maUnselectedColor = rColor;
1305 : 445 : }
1306 : :
1307 : 892 : void setCustomColor(const Color& rColor)
1308 : : {
1309 : 892 : maCustomColor = rColor;
1310 : 892 : }
1311 : :
1312 : : private:
1313 : : TabBar& mrParent;
1314 : : const StyleSettings* mpStyleSettings;
1315 : :
1316 : : Rectangle maRect;
1317 : : Polygon maPoly;
1318 : :
1319 : : Color maSelectedColor;
1320 : : Color maCustomColor;
1321 : : Color maUnselectedColor;
1322 : :
1323 : : bool mbSelected:1;
1324 : : bool mbCustomColored:1;
1325 : : bool mbSpecialTab:1;
1326 : : bool mbEnabled:1;
1327 : : };
1328 : :
1329 : : }
1330 : :
1331 : 445 : void TabBar::Paint( const Rectangle& rect )
1332 : : {
1333 [ + - ][ - + ]: 445 : if(IsNativeControlSupported(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL))
1334 : : DrawNativeControl(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL,rect,
1335 [ # # ][ # # ]: 0 : CTRL_STATE_ENABLED,ImplControlValue(0),rtl::OUString());
1336 : :
1337 : : // Items berechnen und ausgeben
1338 : 445 : sal_uInt16 nItemCount = (sal_uInt16)mpItemList->size();
1339 [ + - ]: 445 : if (!nItemCount)
1340 : : return;
1341 : :
1342 [ + - ]: 445 : ImplPrePaint();
1343 : :
1344 : 445 : Color aFaceColor, aSelectColor, aFaceTextColor, aSelectTextColor;
1345 [ + - ]: 445 : ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor );
1346 : :
1347 : : // Font selektieren
1348 [ + - ]: 445 : Font aFont = GetFont();
1349 [ + - ]: 445 : Font aLightFont = aFont;
1350 [ + - ]: 445 : aLightFont.SetWeight( WEIGHT_NORMAL );
1351 : :
1352 [ + - ]: 445 : TabBarPaintGuard aGuard(*this);
1353 [ + - ]: 445 : TabDrawer aDrawer(*this);
1354 : 445 : aDrawer.setSelectedFillColor(aSelectColor);
1355 : 445 : aDrawer.setUnselectedFillColor(aFaceColor);
1356 [ + - ]: 445 : aDrawer.drawOutputAreaBorder();
1357 : :
1358 : : // Now, start drawing the tabs.
1359 : :
1360 [ + - ]: 445 : ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount);
1361 : :
1362 [ + - ][ + + ]: 445 : if (pItem && mbHasInsertTab)
1363 : : {
1364 : : // Draw the insert tab at the right end.
1365 [ + - ]: 260 : Rectangle aRect = ImplGetInsertTabRect(pItem);
1366 [ + - ]: 260 : aDrawer.setRect(aRect);
1367 [ + - ]: 260 : aDrawer.drawTab();
1368 [ + - ]: 260 : aDrawer.drawPlusImage();
1369 : : }
1370 : :
1371 : 445 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1372 : 445 : ImplTabBarItem* pCurItem = NULL;
1373 [ + - ]: 1337 : while ( pItem )
1374 : : {
1375 : : // CurrentItem als letztes ausgeben, da es alle anderen ueberdeckt
1376 [ + + ][ + + ]: 1337 : if ( !pCurItem && (pItem->mnId == mnCurPageId) )
1377 : : {
1378 : 445 : pCurItem = pItem;
1379 [ + - ]: 445 : pItem = prev();
1380 [ + + ]: 445 : if ( !pItem )
1381 : 428 : pItem = pCurItem;
1382 : 445 : continue;
1383 : : }
1384 : :
1385 : 892 : bool bCurrent = pItem == pCurItem;
1386 : :
1387 [ + - ][ + - ]: 892 : if ( !pItem->maRect.IsEmpty() )
1388 : : {
1389 : 892 : Rectangle aRect = pItem->maRect;
1390 : 892 : bool bSelected = pItem->IsSelected(pCurItem);
1391 : : // We disable custom background color in high contrast mode.
1392 [ # # ][ - + ]: 892 : bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode();
1393 : 892 : bool bSpecialTab = (pItem->mnBits & TPB_SPECIAL);
1394 : 892 : bool bEnabled = pItem->mbEnable;
1395 : : String aText = pItem->mbShort ?
1396 [ + + ][ + - ]: 892 : GetEllipsisString(pItem->maText, mnCurMaxWidth, TEXT_DRAW_ENDELLIPSIS) : pItem->maText;
[ + - ]
1397 : :
1398 [ + - ]: 892 : aDrawer.setRect(aRect);
1399 : 892 : aDrawer.setSelected(bSelected);
1400 : 892 : aDrawer.setCustomColored(bCustomBgColor);
1401 : 892 : aDrawer.setSpecialTab(bSpecialTab);
1402 : 892 : aDrawer.setEnabled(bEnabled);
1403 : 892 : aDrawer.setCustomColor(pItem->maTabBgColor);
1404 [ + - ]: 892 : aDrawer.drawTab();
1405 : :
1406 : : // Aktuelle Page wird mit einem fetten Font ausgegeben
1407 [ + + ]: 892 : if ( bCurrent )
1408 [ + - ]: 445 : SetFont( aFont );
1409 : : else
1410 [ + - ]: 447 : SetFont( aLightFont );
1411 : :
1412 : : // Je nach Status die richtige FillInBrush setzen
1413 : : // Set the correct FillInBrush depending upon status
1414 [ + + ]: 892 : if ( bSelected )
1415 [ + - ]: 445 : SetTextColor( aSelectTextColor );
1416 [ - + ]: 447 : else if ( bCustomBgColor )
1417 [ # # ]: 0 : SetTextColor( pItem->maTabTextColor );
1418 : : else
1419 [ + - ]: 447 : SetTextColor( aFaceTextColor );
1420 : :
1421 : : // This tab is "special", and a special tab needs a blue text.
1422 [ - + ]: 892 : if (bSpecialTab)
1423 [ # # ]: 0 : SetTextColor(Color(COL_LIGHTBLUE));
1424 : :
1425 [ + - ]: 892 : aDrawer.drawText(aText);
1426 : :
1427 [ + + ]: 892 : if ( bCurrent )
1428 : : {
1429 [ + - ]: 445 : SetLineColor();
1430 [ + - ]: 445 : SetFillColor(aSelectColor);
1431 [ + - ]: 445 : aDrawer.drawOverTopBorder(mnWinStyle & WB_3DTAB);
1432 : : return;
1433 : : }
1434 : :
1435 [ + - ][ + - ]: 892 : pItem = prev();
[ + + ]
1436 : : }
1437 : : else
1438 : : {
1439 [ # # ]: 0 : if ( bCurrent )
1440 : : return;
1441 : :
1442 : 0 : pItem = NULL;
1443 : : }
1444 : :
1445 [ + + ]: 447 : if ( !pItem )
1446 : 17 : pItem = pCurItem;
1447 [ + - ][ + - ]: 445 : }
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
1448 : : }
1449 : :
1450 : : // -----------------------------------------------------------------------
1451 : 944 : void TabBar::Resize()
1452 : : {
1453 : 944 : Size aNewSize = GetOutputSizePixel();
1454 : :
1455 : 944 : long nSizerWidth = 0;
1456 : 944 : long nButtonWidth = 0;
1457 : :
1458 : : // Sizer anordnen
1459 [ + - ]: 944 : if ( mpImpl->mpSizer )
1460 : : {
1461 [ + - ]: 944 : Size aSizerSize = mpImpl->mpSizer->GetSizePixel();
1462 [ + + ]: 944 : Point aNewSizerPos( mbMirrored ? 0 : (aNewSize.Width()-aSizerSize.Width()), 0 );
1463 : 944 : Size aNewSizerSize( aSizerSize.Width(), aNewSize.Height() );
1464 [ + - ]: 944 : mpImpl->mpSizer->SetPosSizePixel( aNewSizerPos, aNewSizerSize );
1465 : 944 : nSizerWidth = aSizerSize.Width();
1466 : : }
1467 : :
1468 : : // Scroll-Buttons anordnen
1469 : 944 : long nHeight = aNewSize.Height();
1470 : : // Font in der groesse Anpassen?
1471 [ + - ]: 944 : ImplInitSettings( sal_True, sal_False );
1472 : :
1473 [ + + ]: 944 : long nX = mbMirrored ? (aNewSize.Width()-nHeight) : 0;
1474 [ + + ]: 944 : long nXDiff = mbMirrored ? -nHeight : nHeight;
1475 : :
1476 : 944 : Size aBtnSize( nHeight, nHeight );
1477 [ + - ]: 944 : if ( mpFirstBtn )
1478 : : {
1479 [ + - ]: 944 : mpFirstBtn->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
1480 : 944 : nX += nXDiff;
1481 : 944 : nButtonWidth += nHeight;
1482 : : }
1483 [ + - ]: 944 : if ( mpPrevBtn )
1484 : : {
1485 [ + - ]: 944 : mpPrevBtn->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
1486 : 944 : nX += nXDiff;
1487 : 944 : nButtonWidth += nHeight;
1488 : : }
1489 [ + - ]: 944 : if ( mpNextBtn )
1490 : : {
1491 [ + - ]: 944 : mpNextBtn->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
1492 : 944 : nX += nXDiff;
1493 : 944 : nButtonWidth += nHeight;
1494 : : }
1495 [ + - ]: 944 : if ( mpLastBtn )
1496 : : {
1497 [ + - ]: 944 : mpLastBtn->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
1498 : 944 : nX += nXDiff;
1499 : 944 : nButtonWidth += nHeight;
1500 : : }
1501 : :
1502 : : // Groesse merken
1503 : 944 : maWinSize = aNewSize;
1504 : :
1505 [ + + ]: 944 : if( mbMirrored )
1506 : : {
1507 : 2 : mnOffX = nSizerWidth;
1508 : 2 : mnLastOffX = maWinSize.Width() - nButtonWidth - 1;
1509 : : }
1510 : : else
1511 : : {
1512 : 942 : mnOffX = nButtonWidth;
1513 : 942 : mnLastOffX = maWinSize.Width() - nSizerWidth - 1;
1514 : : }
1515 : :
1516 : : // Neu formatieren
1517 : 944 : mbSizeFormat = sal_True;
1518 [ + - ][ + + ]: 944 : if ( IsReallyVisible() )
1519 : : {
1520 [ + - ][ + + ]: 148 : if ( ImplCalcWidth() )
1521 [ + - ]: 5 : Invalidate();
1522 [ + - ]: 148 : ImplFormat();
1523 : : }
1524 : :
1525 : : // Button enablen/disablen
1526 [ + - ]: 944 : ImplEnableControls();
1527 : 944 : }
1528 : :
1529 : : // -----------------------------------------------------------------------
1530 : :
1531 : 0 : void TabBar::RequestHelp( const HelpEvent& rHEvt )
1532 : : {
1533 [ # # ]: 0 : sal_uInt16 nItemId = GetPageId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
1534 [ # # ]: 0 : if ( nItemId )
1535 : : {
1536 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
1537 : : {
1538 [ # # ]: 0 : XubString aStr = GetHelpText( nItemId );
1539 [ # # ]: 0 : if ( aStr.Len() )
1540 : : {
1541 [ # # ]: 0 : Rectangle aItemRect = GetPageRect( nItemId );
1542 [ # # ]: 0 : Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1543 : 0 : aItemRect.Left() = aPt.X();
1544 : 0 : aItemRect.Top() = aPt.Y();
1545 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1546 : 0 : aItemRect.Right() = aPt.X();
1547 : 0 : aItemRect.Bottom() = aPt.Y();
1548 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
1549 : : return;
1550 [ # # ][ # # ]: 0 : }
1551 : : }
1552 [ # # ]: 0 : else if ( rHEvt.GetMode() & HELPMODE_EXTENDED )
1553 : : {
1554 [ # # ][ # # ]: 0 : rtl::OUString aHelpId( rtl::OStringToOUString( GetHelpId( nItemId ), RTL_TEXTENCODING_UTF8 ) );
1555 [ # # ]: 0 : if ( !aHelpId.isEmpty() )
1556 : : {
1557 : : // Wenn eine Hilfe existiert, dann ausloesen
1558 [ # # ]: 0 : Help* pHelp = Application::GetHelp();
1559 [ # # ]: 0 : if ( pHelp )
1560 [ # # ][ # # ]: 0 : pHelp->Start( aHelpId, this );
[ # # ]
1561 : : return;
1562 [ # # ]: 0 : }
1563 : : }
1564 : :
1565 : : // Bei Quick- oder Ballloon-Help zeigen wir den Text an,
1566 : : // wenn dieser abgeschnitten oder nicht voll sichtbar ist
1567 [ # # ]: 0 : if ( rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON) )
1568 : : {
1569 : 0 : sal_uInt16 nPos = GetPagePos( nItemId );
1570 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
1571 [ # # ]: 0 : if ( pItem->mbShort ||
[ # # # # ]
1572 : 0 : (pItem->maRect.Right()-TABBAR_OFFSET_X-5 > mnLastOffX) )
1573 : : {
1574 [ # # ]: 0 : Rectangle aItemRect = GetPageRect( nItemId );
1575 [ # # ]: 0 : Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1576 : 0 : aItemRect.Left() = aPt.X();
1577 : 0 : aItemRect.Top() = aPt.Y();
1578 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1579 : 0 : aItemRect.Right() = aPt.X();
1580 : 0 : aItemRect.Bottom() = aPt.Y();
1581 [ # # ]: 0 : XubString aStr = (*mpItemList)[ nPos ]->maText;
1582 [ # # ]: 0 : if ( aStr.Len() )
1583 : : {
1584 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
1585 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
1586 : : else
1587 [ # # ]: 0 : Help::ShowQuickHelp( this, aItemRect, aStr );
1588 : : return;
1589 [ # # ][ # # ]: 0 : }
1590 : : }
1591 : : }
1592 : : }
1593 : :
1594 : 0 : Window::RequestHelp( rHEvt );
1595 : : }
1596 : :
1597 : : // -----------------------------------------------------------------------
1598 : :
1599 : 1321 : void TabBar::StateChanged( StateChangedType nType )
1600 : : {
1601 : 1321 : Window::StateChanged( nType );
1602 : :
1603 [ + + ]: 1321 : if ( nType == STATE_CHANGE_INITSHOW )
1604 : : {
1605 [ - + ][ # # ]: 459 : if ( (mbSizeFormat || mbFormat) && !mpItemList->empty() )
[ + + ][ + + ]
1606 : 455 : ImplFormat();
1607 : : }
1608 [ + - ][ - + ]: 862 : else if ( (nType == STATE_CHANGE_ZOOM) ||
1609 : : (nType == STATE_CHANGE_CONTROLFONT) )
1610 : : {
1611 : 0 : ImplInitSettings( sal_True, sal_False );
1612 : 0 : Invalidate();
1613 : : }
1614 [ - + ]: 862 : else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
1615 : 0 : Invalidate();
1616 [ - + ]: 862 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
1617 : : {
1618 : 0 : ImplInitSettings( sal_False, sal_True );
1619 : 0 : Invalidate();
1620 : : }
1621 [ + + ]: 862 : else if ( nType == STATE_CHANGE_MIRRORING )
1622 : : {
1623 : : // reacts on calls of EnableRTL, have to mirror all child controls
1624 [ + - ]: 229 : if( mpFirstBtn ) mpFirstBtn->EnableRTL( IsRTLEnabled() );
1625 [ + - ]: 229 : if( mpPrevBtn ) mpPrevBtn->EnableRTL( IsRTLEnabled() );
1626 [ + - ]: 229 : if( mpNextBtn ) mpNextBtn->EnableRTL( IsRTLEnabled() );
1627 [ + - ]: 229 : if( mpLastBtn ) mpLastBtn->EnableRTL( IsRTLEnabled() );
1628 [ + - ]: 229 : if( mpImpl->mpSizer ) mpImpl->mpSizer->EnableRTL( IsRTLEnabled() );
1629 [ - + ]: 229 : if( mpEdit ) mpEdit->EnableRTL( IsRTLEnabled() );
1630 : : }
1631 : 1321 : }
1632 : :
1633 : : // -----------------------------------------------------------------------
1634 : :
1635 : 0 : void TabBar::DataChanged( const DataChangedEvent& rDCEvt )
1636 : : {
1637 : 0 : Window::DataChanged( rDCEvt );
1638 : :
1639 [ # # ][ # # : 0 : if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
# # # # #
# ]
1640 : 0 : (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
1641 : 0 : ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1642 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
1643 : : {
1644 : 0 : ImplInitSettings( sal_True, sal_True );
1645 : 0 : Invalidate();
1646 : : }
1647 : 0 : }
1648 : :
1649 : : // -----------------------------------------------------------------------
1650 : :
1651 : 0 : void TabBar::ImplSelect()
1652 : : {
1653 : 0 : Select();
1654 : :
1655 : 0 : CallEventListeners( VCLEVENT_TABBAR_PAGESELECTED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)) );
1656 : 0 : }
1657 : :
1658 : : // -----------------------------------------------------------------------
1659 : :
1660 : 0 : void TabBar::Select()
1661 : : {
1662 : 0 : maSelectHdl.Call( this );
1663 : 0 : }
1664 : :
1665 : : // -----------------------------------------------------------------------
1666 : :
1667 : 0 : void TabBar::DoubleClick()
1668 : : {
1669 : 0 : maDoubleClickHdl.Call( this );
1670 : 0 : }
1671 : :
1672 : : // -----------------------------------------------------------------------
1673 : :
1674 : 0 : void TabBar::Split()
1675 : : {
1676 : 0 : maSplitHdl.Call( this );
1677 : 0 : }
1678 : :
1679 : : // -----------------------------------------------------------------------
1680 : :
1681 : 0 : void TabBar::ImplActivatePage()
1682 : : {
1683 : 0 : ActivatePage();
1684 : :
1685 : 0 : CallEventListeners( VCLEVENT_TABBAR_PAGEACTIVATED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)) );
1686 : 0 : }
1687 : :
1688 : : // -----------------------------------------------------------------------
1689 : :
1690 : 0 : void TabBar::ActivatePage()
1691 : : {
1692 : 0 : maActivatePageHdl.Call( this );
1693 : 0 : }
1694 : :
1695 : : // -----------------------------------------------------------------------
1696 : :
1697 : 0 : long TabBar::ImplDeactivatePage()
1698 : : {
1699 : 0 : long nRet = DeactivatePage();
1700 : :
1701 : 0 : CallEventListeners( VCLEVENT_TABBAR_PAGEDEACTIVATED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)) );
1702 : :
1703 : 0 : return nRet;
1704 : : }
1705 : :
1706 : 445 : void TabBar::ImplPrePaint()
1707 : : {
1708 : 445 : sal_uInt16 nItemCount = (sal_uInt16)mpItemList->size();
1709 [ - + ]: 445 : if (!nItemCount)
1710 : 445 : return;
1711 : :
1712 : : ImplTabBarItem* pItem;
1713 : :
1714 : : // TabBar muss formatiert sein
1715 : 445 : ImplFormat();
1716 : :
1717 : : // Beim ersten Format auch dafuer sorgen, das aktuelle TabPage
1718 : : // sichtbar wird
1719 [ + + ]: 445 : if ( mbFirstFormat )
1720 : : {
1721 : 303 : mbFirstFormat = sal_False;
1722 : :
1723 [ + - ][ + - ]: 303 : if ( mnCurPageId && (mnFirstPos == 0) && !mbDropPos )
[ + - ]
1724 : : {
1725 : 303 : pItem = (*mpItemList)[ GetPagePos( mnCurPageId ) ];
1726 [ - + ]: 303 : if ( pItem->maRect.IsEmpty() )
1727 : : {
1728 : : // mbDropPos setzen (bzw. misbrauchen) um Invalidate()
1729 : : // zu unterbinden
1730 : 0 : mbDropPos = sal_True;
1731 : 0 : SetFirstPageId( mnCurPageId );
1732 : 0 : mbDropPos = sal_False;
1733 [ # # ]: 0 : if ( mnFirstPos != 0 )
1734 : 0 : ImplFormat();
1735 : : }
1736 : : }
1737 : : }
1738 : : }
1739 : :
1740 : 445 : ImplTabBarItem* TabBar::ImplGetLastTabBarItem( sal_uInt16 nItemCount )
1741 : : {
1742 : : // letzten sichtbaren Eintrag suchen
1743 : 445 : sal_uInt16 n = mnFirstPos+1;
1744 [ + + ]: 445 : if ( n >= nItemCount )
1745 : 205 : n = nItemCount-1;
1746 : 445 : ImplTabBarItem* pItem = seek( n );
1747 [ + + ]: 1097 : while ( pItem )
1748 : : {
1749 [ + - ]: 652 : if ( !pItem->maRect.IsEmpty() )
1750 : : {
1751 : 652 : n++;
1752 : 652 : pItem = next();
1753 : : }
1754 : : else
1755 : 0 : break;
1756 : : }
1757 : :
1758 : : // Alle Tabs ausgeben (von hinten nach vorn und aktuellen zuletzt)
1759 [ - + ]: 445 : if ( pItem )
1760 : 0 : n--;
1761 [ + - ]: 445 : else if ( n >= nItemCount )
1762 : 445 : n = nItemCount-1;
1763 : 445 : pItem = seek( n );
1764 : 445 : return pItem;
1765 : : }
1766 : :
1767 : 260 : Rectangle TabBar::ImplGetInsertTabRect(ImplTabBarItem* pItem) const
1768 : : {
1769 [ + - ][ + - ]: 260 : if (mbHasInsertTab && pItem)
1770 : : {
1771 : 260 : Rectangle aInsTabRect = pItem->maRect;
1772 : : aInsTabRect.setX(
1773 : 260 : aInsTabRect.getX() + aInsTabRect.getWidth() - TABBAR_OFFSET_X - TABBAR_OFFSET_X2);
1774 : 260 : aInsTabRect.setWidth(32);
1775 : 260 : return aInsTabRect;
1776 : : }
1777 : 260 : return Rectangle();
1778 : : }
1779 : :
1780 : : // -----------------------------------------------------------------------
1781 : :
1782 : 0 : long TabBar::DeactivatePage()
1783 : : {
1784 [ # # ]: 0 : if ( maDeactivatePageHdl.IsSet() )
1785 : 0 : return maDeactivatePageHdl.Call( this );
1786 : : else
1787 : 0 : return sal_True;
1788 : : }
1789 : :
1790 : : // -----------------------------------------------------------------------
1791 : :
1792 : 0 : long TabBar::StartRenaming()
1793 : : {
1794 [ # # ]: 0 : if ( maStartRenamingHdl.IsSet() )
1795 : 0 : return maStartRenamingHdl.Call( this );
1796 : : else
1797 : 0 : return sal_True;
1798 : : }
1799 : :
1800 : : // -----------------------------------------------------------------------
1801 : :
1802 : 0 : long TabBar::AllowRenaming()
1803 : : {
1804 [ # # ]: 0 : if ( maAllowRenamingHdl.IsSet() )
1805 : 0 : return maAllowRenamingHdl.Call( this );
1806 : : else
1807 : 0 : return sal_True;
1808 : : }
1809 : :
1810 : : // -----------------------------------------------------------------------
1811 : :
1812 : 0 : void TabBar::EndRenaming()
1813 : : {
1814 : 0 : maEndRenamingHdl.Call( this );
1815 : 0 : }
1816 : :
1817 : : // -----------------------------------------------------------------------
1818 : :
1819 : 4 : void TabBar::Mirror()
1820 : : {
1821 : :
1822 : 4 : }
1823 : :
1824 : : // -----------------------------------------------------------------------
1825 : :
1826 : 1802 : void TabBar::InsertPage( sal_uInt16 nPageId, const XubString& rText,
1827 : : TabBarPageBits nBits, sal_uInt16 nPos )
1828 : : {
1829 : : DBG_ASSERT( nPageId, "TabBar::InsertPage(): PageId == 0" );
1830 : : DBG_ASSERT( GetPagePos( nPageId ) == PAGE_NOT_FOUND,
1831 : : "TabBar::InsertPage(): PageId already exists" );
1832 : : DBG_ASSERT( nBits <= TPB_SPECIAL, "TabBar::InsertPage(): nBits is wrong" );
1833 : :
1834 : : // PageItem anlegen und in die Item-Liste eintragen
1835 [ + - ][ + - ]: 1802 : ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );
1836 [ - + ]: 1802 : if ( nPos < mpItemList->size() ) {
1837 : 0 : ImplTabBarList::iterator it = mpItemList->begin();
1838 [ # # ]: 0 : ::std::advance( it, nPos );
1839 [ # # ]: 0 : mpItemList->insert( it, pItem );
1840 : : } else {
1841 [ + - ]: 1802 : mpItemList->push_back( pItem );
1842 : : }
1843 : 1802 : mbSizeFormat = sal_True;
1844 : :
1845 : : // CurPageId gegebenenfalls setzen
1846 [ + + ]: 1802 : if ( !mnCurPageId )
1847 : 1151 : mnCurPageId = nPageId;
1848 : :
1849 : : // Leiste neu ausgeben
1850 [ + - ][ + + ]: 1802 : if ( IsReallyVisible() && IsUpdateMode() )
[ + - ][ + - ]
[ + + ]
1851 [ + - ]: 163 : Invalidate();
1852 : :
1853 [ + - ]: 1802 : CallEventListeners( VCLEVENT_TABBAR_PAGEINSERTED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)) );
1854 : 1802 : }
1855 : :
1856 : : // -----------------------------------------------------------------------
1857 : :
1858 : 1027 : Color TabBar::GetTabBgColor( sal_uInt16 nPageId ) const
1859 : : {
1860 : 1027 : sal_uInt16 nPos = GetPagePos( nPageId );
1861 : :
1862 [ + + ]: 1027 : if ( nPos != PAGE_NOT_FOUND )
1863 : 1023 : return (*mpItemList)[ nPos ]->maTabBgColor;
1864 : : else
1865 : 1027 : return Color( COL_AUTO );
1866 : : }
1867 : :
1868 : 0 : void TabBar::SetTabBgColor( sal_uInt16 nPageId, const Color& aTabBgColor )
1869 : : {
1870 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
1871 : : ImplTabBarItem* pItem;
1872 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
1873 : : {
1874 : 0 : pItem = (*mpItemList)[ nPos ];
1875 [ # # ]: 0 : if ( aTabBgColor != Color( COL_AUTO ) )
1876 : : {
1877 : 0 : pItem->maTabBgColor = aTabBgColor;
1878 [ # # ]: 0 : if ( aTabBgColor.GetLuminance() <= 128 ) //Do not use aTabBgColor.IsDark(), because that threshold is way too low...
1879 : 0 : pItem->maTabTextColor = Color( COL_WHITE );
1880 : : else
1881 : 0 : pItem->maTabTextColor = Color( COL_BLACK );
1882 : : }
1883 : : else
1884 : : {
1885 : 0 : pItem->maTabBgColor = Color( COL_AUTO );
1886 : 0 : pItem->maTabTextColor = Color( COL_AUTO );
1887 : : }
1888 : : }
1889 : 0 : }
1890 : :
1891 : : // -----------------------------------------------------------------------
1892 : :
1893 : 0 : void TabBar::RemovePage( sal_uInt16 nPageId )
1894 : : {
1895 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
1896 : :
1897 : : // Existiert Item
1898 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
1899 : : {
1900 [ # # ]: 0 : if ( mnCurPageId == nPageId )
1901 : 0 : mnCurPageId = 0;
1902 : :
1903 : : // Testen, ob erste sichtbare Seite verschoben werden muss
1904 [ # # ]: 0 : if ( mnFirstPos > nPos )
1905 : 0 : mnFirstPos--;
1906 : :
1907 : : // Item-Daten loeschen
1908 : 0 : ImplTabBarList::iterator it = mpItemList->begin();
1909 [ # # ]: 0 : ::std::advance( it, nPos );
1910 [ # # ][ # # ]: 0 : delete *it;
1911 [ # # ]: 0 : mpItemList->erase( it );
1912 : :
1913 : : // Leiste neu ausgeben
1914 [ # # ][ # # ]: 0 : if ( IsReallyVisible() && IsUpdateMode() )
[ # # ][ # # ]
[ # # ]
1915 [ # # ]: 0 : Invalidate();
1916 : :
1917 [ # # ]: 0 : CallEventListeners( VCLEVENT_TABBAR_PAGEREMOVED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)) );
1918 : : }
1919 : 0 : }
1920 : :
1921 : : // -----------------------------------------------------------------------
1922 : :
1923 : 0 : void TabBar::MovePage( sal_uInt16 nPageId, sal_uInt16 nNewPos )
1924 : : {
1925 [ # # ]: 0 : sal_uInt16 nPos = GetPagePos( nPageId );
1926 : 0 : Pair aPair( nPos, nNewPos );
1927 : :
1928 [ # # ]: 0 : if ( nPos < nNewPos )
1929 : 0 : nNewPos--;
1930 : :
1931 [ # # ]: 0 : if ( nPos == nNewPos )
1932 : 0 : return;
1933 : :
1934 : : // Existiert Item
1935 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
1936 : : {
1937 : : // TabBar-Item in der Liste verschieben
1938 : 0 : ImplTabBarList::iterator it = mpItemList->begin();
1939 [ # # ]: 0 : ::std::advance( it, nPos );
1940 : 0 : ImplTabBarItem* pItem = *it;
1941 [ # # ]: 0 : mpItemList->erase( it );
1942 [ # # ]: 0 : if ( nNewPos < mpItemList->size() ) {
1943 : 0 : it = mpItemList->begin();
1944 [ # # ]: 0 : ::std::advance( it, nNewPos );
1945 [ # # ]: 0 : mpItemList->insert( it, pItem );
1946 : : } else {
1947 [ # # ]: 0 : mpItemList->push_back( pItem );
1948 : : }
1949 : :
1950 : : // Leiste neu ausgeben
1951 [ # # ][ # # ]: 0 : if ( IsReallyVisible() && IsUpdateMode() )
[ # # ][ # # ]
[ # # ]
1952 [ # # ]: 0 : Invalidate();
1953 : :
1954 [ # # ]: 0 : CallEventListeners( VCLEVENT_TABBAR_PAGEMOVED, (void*) &aPair );
1955 : : }
1956 : : }
1957 : :
1958 : : // -----------------------------------------------------------------------
1959 : :
1960 : 922 : void TabBar::Clear()
1961 : : {
1962 : : // Alle Items loeschen
1963 [ + + ]: 1963 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
1964 [ + - ]: 1041 : delete (*mpItemList)[ i ];
1965 : : }
1966 : 922 : mpItemList->clear();
1967 : :
1968 : : // Items aus der Liste loeschen
1969 : 922 : mbSizeFormat = sal_True;
1970 : 922 : mnCurPageId = 0;
1971 : 922 : mnFirstPos = 0;
1972 : 922 : maCurrentItemList = 0;
1973 : :
1974 : : // Leiste neu ausgeben
1975 [ + - ][ + + ]: 922 : if ( IsReallyVisible() && IsUpdateMode() )
[ + + ]
1976 : 80 : Invalidate();
1977 : :
1978 : 922 : CallEventListeners( VCLEVENT_TABBAR_PAGEREMOVED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(PAGE_NOT_FOUND)) );
1979 : 922 : }
1980 : :
1981 : : // -----------------------------------------------------------------------
1982 : :
1983 : 0 : sal_Bool TabBar::IsPageEnabled( sal_uInt16 nPageId ) const
1984 : : {
1985 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
1986 : :
1987 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
1988 : 0 : return (*mpItemList)[ nPos ]->mbEnable;
1989 : : else
1990 : 0 : return sal_False;
1991 : : }
1992 : :
1993 : : // -----------------------------------------------------------------------
1994 : :
1995 : 638 : void TabBar::SetPageBits( sal_uInt16 nPageId, TabBarPageBits nBits )
1996 : : {
1997 : 638 : sal_uInt16 nPos = GetPagePos( nPageId );
1998 : :
1999 [ + - ]: 638 : if ( nPos != PAGE_NOT_FOUND )
2000 : : {
2001 : 638 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
2002 : :
2003 [ - + ]: 638 : if ( pItem->mnBits != nBits )
2004 : : {
2005 : 0 : pItem->mnBits = nBits;
2006 : :
2007 : : // Leiste neu ausgeben
2008 [ # # ][ # # ]: 0 : if ( IsReallyVisible() && IsUpdateMode() )
[ # # ]
2009 : 0 : Invalidate( pItem->maRect );
2010 : : }
2011 : : }
2012 : 638 : }
2013 : :
2014 : : // -----------------------------------------------------------------------
2015 : :
2016 : 0 : TabBarPageBits TabBar::GetPageBits( sal_uInt16 nPageId ) const
2017 : : {
2018 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2019 : :
2020 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
2021 : 0 : return (*mpItemList)[ nPos ]->mnBits;
2022 : : else
2023 : 0 : return sal_False;
2024 : : }
2025 : :
2026 : : // -----------------------------------------------------------------------
2027 : :
2028 : 1054 : sal_uInt16 TabBar::GetPageCount() const
2029 : : {
2030 : 1054 : return (sal_uInt16)mpItemList->size();
2031 : : }
2032 : :
2033 : : // -----------------------------------------------------------------------
2034 : :
2035 : 842 : sal_uInt16 TabBar::GetPageId( sal_uInt16 nPos ) const
2036 : : {
2037 [ + - ]: 842 : return ( nPos < mpItemList->size() ) ? (*mpItemList)[ nPos ]->mnId : 0;
2038 : : }
2039 : :
2040 : : // -----------------------------------------------------------------------
2041 : :
2042 : 7721 : sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const
2043 : : {
2044 [ + + ]: 9502 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
2045 [ + + ]: 9476 : if ( (*mpItemList)[ i ]->mnId == nPageId ) {
2046 : 7695 : return sal_uInt16( i );
2047 : : }
2048 : : }
2049 : 7721 : return PAGE_NOT_FOUND;
2050 : : }
2051 : :
2052 : : // -----------------------------------------------------------------------
2053 : :
2054 : 0 : sal_uInt16 TabBar::GetPageId( const Point& rPos, bool bCheckInsTab ) const
2055 : : {
2056 [ # # ]: 0 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
2057 : : {
2058 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ i ];
2059 [ # # ]: 0 : if ( pItem->maRect.IsInside( rPos ) )
2060 : 0 : return pItem->mnId;
2061 : : }
2062 : :
2063 [ # # ][ # # ]: 0 : if (bCheckInsTab && mbHasInsertTab && !mpItemList->empty())
[ # # ][ # # ]
2064 : : {
2065 : 0 : ImplTabBarItem* pItem = mpItemList->back();
2066 [ # # ][ # # ]: 0 : if (ImplGetInsertTabRect(pItem).IsInside(rPos))
2067 : 0 : return INSERT_TAB_POS;
2068 : : }
2069 : :
2070 : 0 : return 0;
2071 : : }
2072 : :
2073 : : // -----------------------------------------------------------------------
2074 : :
2075 : 0 : Rectangle TabBar::GetPageRect( sal_uInt16 nPageId ) const
2076 : : {
2077 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2078 : :
2079 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
2080 : 0 : return (*mpItemList)[ nPos ]->maRect;
2081 : : else
2082 : 0 : return Rectangle();
2083 : : }
2084 : :
2085 : : // -----------------------------------------------------------------------
2086 : :
2087 : 2224 : void TabBar::SetCurPageId( sal_uInt16 nPageId )
2088 : : {
2089 : 2224 : sal_uInt16 nPos = GetPagePos( nPageId );
2090 : :
2091 : : // Wenn Item nicht existiert, dann nichts machen
2092 [ + - ]: 2224 : if ( nPos != PAGE_NOT_FOUND )
2093 : : {
2094 : : // Wenn sich aktuelle Page nicht geaendert hat, dann muessen wir
2095 : : // jetzt nichts mehr machen
2096 [ + + ]: 2224 : if ( nPageId == mnCurPageId )
2097 : 2224 : return;
2098 : :
2099 : : // Muss invalidiert werden
2100 : 67 : sal_Bool bUpdate = sal_False;
2101 [ + + ][ + - ]: 67 : if ( IsReallyVisible() && IsUpdateMode() )
[ + + ]
2102 : 59 : bUpdate = sal_True;
2103 : :
2104 : 67 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
2105 : : ImplTabBarItem* pOldItem;
2106 : :
2107 [ + - ]: 67 : if ( mnCurPageId )
2108 : 67 : pOldItem = (*mpItemList)[ GetPagePos( mnCurPageId ) ];
2109 : : else
2110 : 0 : pOldItem = NULL;
2111 : :
2112 : : // Wenn Page nicht selektiert, dann vorher selektierte Seite
2113 : : // deselktieren, wenn dies die einzige selektierte Seite ist
2114 [ + - ][ + - ]: 67 : if ( !pItem->mbSelect && pOldItem )
2115 : : {
2116 : 67 : sal_uInt16 nSelPageCount = GetSelectPageCount();
2117 [ + + ]: 67 : if ( nSelPageCount == 1 )
2118 : 28 : pOldItem->mbSelect = sal_False;
2119 : 67 : pItem->mbSelect = sal_True;
2120 : : }
2121 : :
2122 : 67 : mnCurPageId = nPageId;
2123 : 67 : mbFormat = sal_True;
2124 : :
2125 : : // Dafuer sorgen, das aktuelle Page sichtbar wird
2126 [ + + ]: 67 : if ( IsReallyVisible() )
2127 : : {
2128 [ - + ]: 59 : if ( nPos < mnFirstPos )
2129 : 0 : SetFirstPageId( nPageId );
2130 : : else
2131 : : {
2132 : : // sichtbare Breite berechnen
2133 : 59 : long nWidth = mnLastOffX;
2134 [ + - ]: 59 : if ( nWidth > TABBAR_OFFSET_X )
2135 : 59 : nWidth -= TABBAR_OFFSET_X;
2136 [ + - ]: 59 : if ( nWidth > ADDNEWPAGE_AREAWIDTH )
2137 : 59 : nWidth -= ADDNEWPAGE_AREAWIDTH;
2138 : :
2139 [ + + ]: 59 : if ( pItem->maRect.IsEmpty() )
2140 : 37 : ImplFormat();
2141 : :
2142 [ - + ][ # # ]: 118 : while ( (mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)) ||
[ + + - + ]
[ + + ]
2143 : 57 : pItem->maRect.IsEmpty() )
2144 : : {
2145 : 2 : sal_uInt16 nNewPos = mnFirstPos+1;
2146 : : // Dafuer sorgen, das min. die aktuelle TabPages als
2147 : : // erste TabPage sichtbar ist
2148 [ + - ]: 2 : if ( nNewPos >= nPos )
2149 : : {
2150 : 2 : SetFirstPageId( nPageId );
2151 : 2 : break;
2152 : : }
2153 : : else
2154 : 0 : SetFirstPageId( GetPageId( nNewPos ) );
2155 : 0 : ImplFormat();
2156 : : // Falls erste Seite nicht weitergeschaltet wird, dann
2157 : : // koennen wir abbrechen
2158 [ # # ]: 0 : if ( nNewPos != mnFirstPos )
2159 : 0 : break;
2160 : : }
2161 : : }
2162 : : }
2163 : :
2164 : : // Leiste neu ausgeben
2165 [ + + ]: 67 : if ( bUpdate )
2166 : : {
2167 : 59 : Invalidate( pItem->maRect );
2168 [ + - ]: 59 : if ( pOldItem )
2169 : 59 : Invalidate( pOldItem->maRect );
2170 : : }
2171 : : }
2172 : : }
2173 : :
2174 : : // -----------------------------------------------------------------------
2175 : :
2176 : 0 : void TabBar::MakeVisible( sal_uInt16 nPageId )
2177 : : {
2178 [ # # ]: 0 : if ( !IsReallyVisible() )
2179 : 0 : return;
2180 : :
2181 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2182 : :
2183 : : // Wenn Item nicht existiert, dann nichts machen
2184 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
2185 : : {
2186 [ # # ]: 0 : if ( nPos < mnFirstPos )
2187 : 0 : SetFirstPageId( nPageId );
2188 : : else
2189 : : {
2190 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
2191 : :
2192 : : // sichtbare Breite berechnen
2193 : 0 : long nWidth = mnLastOffX;
2194 [ # # ]: 0 : if ( nWidth > TABBAR_OFFSET_X )
2195 : 0 : nWidth -= TABBAR_OFFSET_X;
2196 : :
2197 [ # # ][ # # ]: 0 : if ( mbFormat || pItem->maRect.IsEmpty() )
[ # # ]
2198 : : {
2199 : 0 : mbFormat = sal_True;
2200 : 0 : ImplFormat();
2201 : : }
2202 : :
2203 [ # # # # ]: 0 : while ( (pItem->maRect.Right() > nWidth) ||
[ # # ]
2204 : 0 : pItem->maRect.IsEmpty() )
2205 : : {
2206 : 0 : sal_uInt16 nNewPos = mnFirstPos+1;
2207 : : // Dafuer sorgen, das min. die aktuelle TabPages als
2208 : : // erste TabPage sichtbar ist
2209 [ # # ]: 0 : if ( nNewPos >= nPos )
2210 : : {
2211 : 0 : SetFirstPageId( nPageId );
2212 : 0 : break;
2213 : : }
2214 : : else
2215 : 0 : SetFirstPageId( GetPageId( nNewPos ) );
2216 : 0 : ImplFormat();
2217 : : // Falls erste Seite nicht weitergeschaltet wird, dann
2218 : : // koennen wir abbrechen
2219 [ # # ]: 0 : if ( nNewPos != mnFirstPos )
2220 : 0 : break;
2221 : : }
2222 : : }
2223 : : }
2224 : : }
2225 : :
2226 : : // -----------------------------------------------------------------------
2227 : :
2228 : 2 : void TabBar::SetFirstPageId( sal_uInt16 nPageId )
2229 : : {
2230 : 2 : sal_uInt16 nPos = GetPagePos( nPageId );
2231 : :
2232 : : // Wenn Item nicht existiert, dann sal_False zurueckgeben
2233 [ + - ]: 2 : if ( nPos != PAGE_NOT_FOUND )
2234 : : {
2235 [ + - ]: 2 : if ( nPos != mnFirstPos )
2236 : : {
2237 : : // Dafuer sorgen, das nach Moeglichkteit soviele Pages wie
2238 : : // moeglich sichtbar sind
2239 : 2 : ImplFormat();
2240 : 2 : sal_uInt16 nLastFirstPos = ImplGetLastFirstPos();
2241 : : sal_uInt16 nNewPos;
2242 [ - + ]: 2 : if ( nPos > nLastFirstPos )
2243 : 0 : nNewPos = nLastFirstPos;
2244 : : else
2245 : 2 : nNewPos = nPos;
2246 : :
2247 [ + - ]: 2 : if ( nNewPos != mnFirstPos )
2248 : : {
2249 : 2 : mnFirstPos = nNewPos;
2250 : 2 : mbFormat = sal_True;
2251 : :
2252 : : // Leiste neu ausgeben (Achtung: mbDropPos beachten, da wenn
2253 : : // dieses Flag gesetzt ist, wird direkt gepaintet)
2254 [ + - ][ + - ]: 2 : if ( IsReallyVisible() && IsUpdateMode() && !mbDropPos )
[ + - ][ + - ]
2255 : 2 : Invalidate();
2256 : : }
2257 : : }
2258 : : }
2259 : 2 : }
2260 : :
2261 : : // -----------------------------------------------------------------------
2262 : :
2263 : 326 : void TabBar::SelectPage( sal_uInt16 nPageId, sal_Bool bSelect )
2264 : : {
2265 : 326 : sal_uInt16 nPos = GetPagePos( nPageId );
2266 : :
2267 [ + + ]: 326 : if ( nPos != PAGE_NOT_FOUND )
2268 : : {
2269 : 324 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
2270 : :
2271 [ + + ]: 324 : if ( pItem->mbSelect != bSelect )
2272 : : {
2273 : 260 : pItem->mbSelect = bSelect;
2274 : :
2275 : : // Leiste neu ausgeben
2276 [ + + ][ + - ]: 260 : if ( IsReallyVisible() && IsUpdateMode() )
[ + + ]
2277 : 63 : Invalidate( pItem->maRect );
2278 : : }
2279 : : }
2280 : 326 : }
2281 : :
2282 : : // -----------------------------------------------------------------------
2283 : :
2284 : 67 : sal_uInt16 TabBar::GetSelectPageCount() const
2285 : : {
2286 : 67 : sal_uInt16 nSelected = 0;
2287 [ + + ]: 213 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
2288 : : {
2289 : 146 : ImplTabBarItem* pItem = (*mpItemList)[ i ];
2290 [ + + ]: 146 : if ( pItem->mbSelect )
2291 : 28 : nSelected++;
2292 : : }
2293 : :
2294 : 67 : return nSelected;
2295 : : }
2296 : :
2297 : : // -----------------------------------------------------------------------
2298 : :
2299 : 1056 : sal_Bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const
2300 : : {
2301 : 1056 : sal_uInt16 nPos = GetPagePos( nPageId );
2302 [ + + ]: 1056 : if ( nPos != PAGE_NOT_FOUND )
2303 : 1052 : return (*mpItemList)[ nPos ]->mbSelect;
2304 : : else
2305 : 1056 : return sal_False;
2306 : : }
2307 : :
2308 : : // -----------------------------------------------------------------------
2309 : :
2310 : 0 : sal_Bool TabBar::StartEditMode( sal_uInt16 nPageId )
2311 : : {
2312 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2313 [ # # ][ # # ]: 0 : if ( mpEdit || (nPos == PAGE_NOT_FOUND) || (mnLastOffX < 8) )
[ # # ]
2314 : 0 : return sal_False;
2315 : :
2316 : 0 : mnEditId = nPageId;
2317 [ # # ]: 0 : if ( StartRenaming() )
2318 : : {
2319 [ # # ]: 0 : ImplShowPage( nPos );
2320 [ # # ]: 0 : ImplFormat();
2321 [ # # ]: 0 : Update();
2322 : :
2323 [ # # ][ # # ]: 0 : mpEdit = new TabBarEdit( this, WB_CENTER );
2324 [ # # ]: 0 : Rectangle aRect = GetPageRect( mnEditId );
2325 : 0 : long nX = aRect.Left()+TABBAR_OFFSET_X+(TABBAR_OFFSET_X2/2);
2326 [ # # ]: 0 : long nWidth = aRect.GetWidth()-(TABBAR_OFFSET_X*2)-TABBAR_OFFSET_X2;
2327 [ # # ]: 0 : if ( mnEditId != GetCurPageId() )
2328 : 0 : nX += 1;
2329 [ # # ]: 0 : if ( nX+nWidth > mnLastOffX )
2330 : 0 : nWidth = mnLastOffX-nX;
2331 [ # # ]: 0 : if ( nWidth < 3 )
2332 : : {
2333 : 0 : nX = aRect.Left();
2334 [ # # ]: 0 : nWidth = aRect.GetWidth();
2335 : : }
2336 [ # # ][ # # ]: 0 : mpEdit->SetText( GetPageText( mnEditId ) );
[ # # ]
2337 [ # # ][ # # ]: 0 : mpEdit->SetPosSizePixel( nX, aRect.Top()+mnOffY+1, nWidth, aRect.GetHeight()-3 );
2338 [ # # ]: 0 : Font aFont = GetPointFont();
2339 : 0 : Color aForegroundColor;
2340 : 0 : Color aBackgroundColor;
2341 : 0 : Color aFaceColor;
2342 : 0 : Color aSelectColor;
2343 : 0 : Color aFaceTextColor;
2344 : 0 : Color aSelectTextColor;
2345 [ # # ]: 0 : ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor );
2346 [ # # ]: 0 : if ( mnEditId != GetCurPageId() )
2347 [ # # ]: 0 : aFont.SetWeight( WEIGHT_LIGHT );
2348 [ # # ][ # # ]: 0 : if ( IsPageSelected( mnEditId ) || (mnEditId == GetCurPageId()) )
[ # # ][ # # ]
2349 : : {
2350 : 0 : aForegroundColor = aSelectTextColor;
2351 : 0 : aBackgroundColor = aSelectColor;
2352 : : }
2353 : : else
2354 : : {
2355 : 0 : aForegroundColor = aFaceTextColor;
2356 : 0 : aBackgroundColor = aFaceColor;
2357 : : }
2358 [ # # ][ # # ]: 0 : if ( GetPageBits( mnEditId ) & TPB_SPECIAL )
2359 : 0 : aForegroundColor = Color( COL_LIGHTBLUE );
2360 [ # # ]: 0 : mpEdit->SetControlFont( aFont );
2361 [ # # ]: 0 : mpEdit->SetControlForeground( aForegroundColor );
2362 [ # # ]: 0 : mpEdit->SetControlBackground( aBackgroundColor );
2363 [ # # ]: 0 : mpEdit->GrabFocus();
2364 [ # # ][ # # ]: 0 : mpEdit->SetSelection( Selection( 0, mpEdit->GetText().Len() ) );
[ # # ]
2365 [ # # ]: 0 : mpEdit->Show();
2366 [ # # ]: 0 : return sal_True;
2367 : : }
2368 : : else
2369 : : {
2370 : 0 : mnEditId = 0;
2371 : 0 : return sal_False;
2372 : : }
2373 : : }
2374 : :
2375 : : // -----------------------------------------------------------------------
2376 : :
2377 : 849 : void TabBar::EndEditMode( sal_Bool bCancel )
2378 : : {
2379 [ - + ]: 849 : if ( mpEdit )
2380 : : {
2381 : : // call hdl
2382 : 0 : sal_Bool bEnd = sal_True;
2383 : 0 : mbEditCanceled = bCancel;
2384 [ # # ]: 0 : maEditText = mpEdit->GetText();
2385 : 0 : mpEdit->SetPostEvent();
2386 [ # # ]: 0 : if ( !bCancel )
2387 : : {
2388 : 0 : long nAllowRenaming = AllowRenaming();
2389 [ # # ]: 0 : if ( nAllowRenaming == TABBAR_RENAMING_YES )
2390 : 0 : SetPageText( mnEditId, maEditText );
2391 [ # # ]: 0 : else if ( nAllowRenaming == TABBAR_RENAMING_NO )
2392 : 0 : bEnd = sal_False;
2393 : : else // nAllowRenaming == TABBAR_RENAMING_CANCEL
2394 : 0 : mbEditCanceled = sal_True;
2395 : : }
2396 : :
2397 : : // renaming not allowed, than reset edit data
2398 [ # # ]: 0 : if ( !bEnd )
2399 : : {
2400 : 0 : mpEdit->ResetPostEvent();
2401 : 0 : mpEdit->GrabFocus();
2402 : : }
2403 : : else
2404 : : {
2405 : : // close edit and call end hdl
2406 [ # # ]: 0 : delete mpEdit;
2407 : 0 : mpEdit = NULL;
2408 : 0 : EndRenaming();
2409 : 0 : mnEditId = 0;
2410 : : }
2411 : :
2412 : : // reset
2413 : 0 : maEditText.Erase();
2414 : 0 : mbEditCanceled = sal_False;
2415 : : }
2416 : 849 : }
2417 : :
2418 : : // -----------------------------------------------------------------------
2419 : :
2420 : 682 : void TabBar::SetMirrored(bool bMirrored)
2421 : : {
2422 [ + + ]: 682 : if( mbMirrored != bMirrored )
2423 : : {
2424 : 4 : mbMirrored = bMirrored;
2425 : 4 : mbSizeFormat = true;
2426 : 4 : ImplInitControls(); // for button images
2427 : 4 : Resize(); // recalculates control positions
2428 : 4 : Mirror();
2429 : : }
2430 : 682 : }
2431 : :
2432 : 682 : void TabBar::SetEffectiveRTL( bool bRTL )
2433 : : {
2434 : 682 : SetMirrored( bRTL != Application::GetSettings().GetLayoutRTL() );
2435 : 682 : }
2436 : :
2437 : 0 : bool TabBar::IsEffectiveRTL() const
2438 : : {
2439 : 0 : return IsMirrored() != Application::GetSettings().GetLayoutRTL();
2440 : : }
2441 : :
2442 : : // -----------------------------------------------------------------------
2443 : :
2444 : 234 : void TabBar::SetMaxPageWidth( long nMaxWidth )
2445 : : {
2446 [ + - ]: 234 : if ( mnMaxPageWidth != nMaxWidth )
2447 : : {
2448 : 234 : mnMaxPageWidth = nMaxWidth;
2449 : 234 : mbSizeFormat = sal_True;
2450 : :
2451 : : // Leiste neu ausgeben
2452 [ - + ][ # # ]: 234 : if ( IsReallyVisible() && IsUpdateMode() )
[ - + ]
2453 : 0 : Invalidate();
2454 : : }
2455 : 234 : }
2456 : :
2457 : : // -----------------------------------------------------------------------
2458 : :
2459 : 5 : void TabBar::SetPageText( sal_uInt16 nPageId, const XubString& rText )
2460 : : {
2461 : 5 : sal_uInt16 nPos = GetPagePos( nPageId );
2462 [ + - ]: 5 : if ( nPos != PAGE_NOT_FOUND )
2463 : : {
2464 : 5 : (*mpItemList)[ nPos ]->maText = rText;
2465 : 5 : mbSizeFormat = sal_True;
2466 : :
2467 : : // Leiste neu ausgeben
2468 [ # # ][ - + ]: 5 : if ( IsReallyVisible() && IsUpdateMode() )
[ - + ]
2469 : 0 : Invalidate();
2470 : :
2471 : 5 : CallEventListeners( VCLEVENT_TABBAR_PAGETEXTCHANGED, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)) );
2472 : : }
2473 : 5 : }
2474 : :
2475 : : // -----------------------------------------------------------------------
2476 : :
2477 : 2073 : XubString TabBar::GetPageText( sal_uInt16 nPageId ) const
2478 : : {
2479 : 2073 : sal_uInt16 nPos = GetPagePos( nPageId );
2480 [ + + ]: 2073 : if ( nPos != PAGE_NOT_FOUND )
2481 : 2057 : return (*mpItemList)[ nPos ]->maText;
2482 : : else
2483 : 2073 : return XubString();
2484 : : }
2485 : :
2486 : : // -----------------------------------------------------------------------
2487 : :
2488 : 0 : XubString TabBar::GetHelpText( sal_uInt16 nPageId ) const
2489 : : {
2490 : 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2491 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
2492 : : {
2493 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ nPos ];
2494 [ # # ][ # # ]: 0 : if ( !pItem->maHelpText.Len() && !pItem->maHelpId.isEmpty() )
[ # # ]
2495 : : {
2496 : 0 : Help* pHelp = Application::GetHelp();
2497 [ # # ]: 0 : if ( pHelp )
2498 [ # # ][ # # ]: 0 : pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this );
[ # # ][ # # ]
[ # # ]
2499 : : }
2500 : :
2501 : 0 : return pItem->maHelpText;
2502 : : }
2503 : : else
2504 : 0 : return XubString();
2505 : : }
2506 : :
2507 : : // -----------------------------------------------------------------------
2508 : :
2509 : 0 : rtl::OString TabBar::GetHelpId( sal_uInt16 nPageId ) const
2510 : : {
2511 [ # # ]: 0 : sal_uInt16 nPos = GetPagePos( nPageId );
2512 : 0 : rtl::OString aRet;
2513 [ # # ]: 0 : if ( nPos != PAGE_NOT_FOUND )
2514 : 0 : return (*mpItemList)[ nPos ]->maHelpId;
2515 : 0 : return aRet;
2516 : : }
2517 : :
2518 : : // -----------------------------------------------------------------------
2519 : :
2520 : 0 : sal_Bool TabBar::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
2521 : : {
2522 [ # # ][ # # ]: 0 : if ( !(mnWinStyle & WB_DRAG) || (rCEvt.GetCommand() != COMMAND_STARTDRAG) )
[ # # ]
2523 : 0 : return sal_False;
2524 : :
2525 : : // Testen, ob angeklickte Seite selektiert ist. Falls dies nicht
2526 : : // der Fall ist, setzen wir ihn als aktuellen Eintrag. Falls Drag and
2527 : : // Drop auch mal ueber Tastatur ausgeloest werden kann, testen wir
2528 : : // dies nur bei einer Mausaktion.
2529 : : // Ausserdem machen wir das nur, wenn kein Select() ausgeloest wurde,
2530 : : // da der Select schon den Bereich gescrollt haben kann
2531 [ # # ][ # # ]: 0 : if ( rCEvt.IsMouseEvent() && !mbInSelect )
[ # # ]
2532 : : {
2533 [ # # ]: 0 : sal_uInt16 nSelId = GetPageId( rCEvt.GetMousePosPixel() );
2534 : :
2535 : : // Falls kein Eintrag angeklickt wurde, starten wir kein Dragging
2536 [ # # ]: 0 : if ( !nSelId )
2537 : 0 : return sal_False;
2538 : :
2539 : : // Testen, ob Seite selektiertiert ist. Falls nicht, als aktuelle
2540 : : // Seite setzen und Select rufen.
2541 [ # # ][ # # ]: 0 : if ( !IsPageSelected( nSelId ) )
2542 : : {
2543 [ # # ][ # # ]: 0 : if ( ImplDeactivatePage() )
2544 : : {
2545 [ # # ]: 0 : SetCurPageId( nSelId );
2546 [ # # ]: 0 : Update();
2547 [ # # ]: 0 : ImplActivatePage();
2548 [ # # ]: 0 : ImplSelect();
2549 : : }
2550 : : else
2551 : 0 : return sal_False;
2552 : : }
2553 : : }
2554 : 0 : mbInSelect = sal_False;
2555 : :
2556 [ # # ]: 0 : Region aRegion;
2557 : :
2558 : : // Region zuweisen
2559 [ # # ]: 0 : rRegion = aRegion;
2560 : :
2561 [ # # ]: 0 : return sal_True;
2562 : : }
2563 : :
2564 : : // -----------------------------------------------------------------------
2565 : :
2566 : 0 : sal_uInt16 TabBar::ShowDropPos( const Point& rPos )
2567 : : {
2568 : : ImplTabBarItem* pItem;
2569 : : sal_uInt16 nDropId;
2570 : : sal_uInt16 nNewDropPos;
2571 : 0 : sal_uInt16 nItemCount = (sal_uInt16)mpItemList->size();
2572 : 0 : short nScroll = 0;
2573 : :
2574 [ # # ]: 0 : if ( rPos.X() > mnLastOffX-TABBAR_DRAG_SCROLLOFF )
2575 : : {
2576 : 0 : pItem = (*mpItemList)[ mpItemList->size()-1 ];
2577 [ # # ][ # # ]: 0 : if ( !pItem->maRect.IsEmpty() && (rPos.X() > pItem->maRect.Right()) )
[ # # ][ # # ]
2578 : 0 : nNewDropPos = (sal_uInt16)mpItemList->size();
2579 : : else
2580 : : {
2581 : 0 : nNewDropPos = mnFirstPos+1;
2582 : 0 : nScroll = 1;
2583 : : }
2584 : : }
2585 [ # # ]: 0 : else if ( (rPos.X() <= mnOffX) ||
[ # # # # ]
[ # # ]
2586 : 0 : (!mnOffX && (rPos.X() <= TABBAR_DRAG_SCROLLOFF)) )
2587 : : {
2588 [ # # ]: 0 : if ( mnFirstPos )
2589 : : {
2590 : 0 : nNewDropPos = mnFirstPos;
2591 : 0 : nScroll = -1;
2592 : : }
2593 : : else
2594 : 0 : nNewDropPos = 0;
2595 : : }
2596 : : else
2597 : : {
2598 [ # # ]: 0 : nDropId = GetPageId( rPos );
2599 [ # # ]: 0 : if ( nDropId )
2600 : : {
2601 [ # # ]: 0 : nNewDropPos = GetPagePos( nDropId );
2602 [ # # ][ # # ]: 0 : if ( mnFirstPos && (nNewDropPos == mnFirstPos-1) )
2603 : 0 : nScroll = -1;
2604 : : }
2605 : : else
2606 : 0 : nNewDropPos = nItemCount;
2607 : : }
2608 : :
2609 [ # # ][ # # ]: 0 : if ( mbDropPos && (nNewDropPos == mnDropPos) && !nScroll )
[ # # ]
2610 : 0 : return mnDropPos;
2611 : :
2612 [ # # ]: 0 : if ( mbDropPos )
2613 [ # # ]: 0 : HideDropPos();
2614 : 0 : mbDropPos = sal_True;
2615 : 0 : mnDropPos = nNewDropPos;
2616 : :
2617 [ # # ]: 0 : if ( nScroll )
2618 : : {
2619 : 0 : sal_uInt16 nOldFirstPos = mnFirstPos;
2620 [ # # ][ # # ]: 0 : SetFirstPageId( GetPageId( mnFirstPos+nScroll ) );
2621 : :
2622 : : // Direkt ausgeben, da kein Paint bei Drag and Drop moeglich
2623 [ # # ]: 0 : if ( nOldFirstPos != mnFirstPos )
2624 : : {
2625 [ # # ]: 0 : Rectangle aRect( mnOffX, 0, mnLastOffX, maWinSize.Height() );
2626 [ # # ][ # # ]: 0 : SetFillColor( GetBackground().GetColor() );
2627 [ # # ]: 0 : DrawRect( aRect );
2628 [ # # ]: 0 : Paint( aRect );
2629 : : }
2630 : : }
2631 : :
2632 : : // Drop-Position-Pfeile ausgeben
2633 : 0 : Color aBlackColor( COL_BLACK );
2634 : : long nX;
2635 : 0 : long nY = (maWinSize.Height()/2)-1;
2636 [ # # ]: 0 : sal_uInt16 nCurPos = GetPagePos( mnCurPageId );
2637 : :
2638 [ # # ]: 0 : SetLineColor( aBlackColor );
2639 [ # # ]: 0 : if ( mnDropPos < nItemCount )
2640 : : {
2641 : 0 : pItem = (*mpItemList)[ mnDropPos ];
2642 : 0 : nX = pItem->maRect.Left()+TABBAR_OFFSET_X;
2643 [ # # ]: 0 : if ( mnDropPos == nCurPos )
2644 : 0 : nX--;
2645 : : else
2646 : 0 : nX++;
2647 [ # # ][ # # ]: 0 : if ( !pItem->IsDefaultTabBgColor() && !pItem->mbSelect)
[ # # ]
2648 [ # # ]: 0 : SetLineColor( pItem->maTabTextColor );
2649 [ # # ]: 0 : DrawLine( Point( nX, nY ), Point( nX, nY ) );
2650 [ # # ]: 0 : DrawLine( Point( nX+1, nY-1 ), Point( nX+1, nY+1 ) );
2651 [ # # ]: 0 : DrawLine( Point( nX+2, nY-2 ), Point( nX+2, nY+2 ) );
2652 [ # # ]: 0 : SetLineColor( aBlackColor );
2653 : : }
2654 [ # # ][ # # ]: 0 : if ( (mnDropPos > 0) && (mnDropPos < nItemCount+1) )
2655 : : {
2656 : 0 : pItem = (*mpItemList)[ mnDropPos-1 ];
2657 : 0 : nX = pItem->maRect.Right()-TABBAR_OFFSET_X;
2658 [ # # ]: 0 : if ( mnDropPos == nCurPos )
2659 : 0 : nX++;
2660 [ # # ][ # # ]: 0 : if ( !pItem->IsDefaultTabBgColor() && !pItem->mbSelect)
[ # # ]
2661 [ # # ]: 0 : SetLineColor( pItem->maTabTextColor );
2662 [ # # ]: 0 : DrawLine( Point( nX, nY ), Point( nX, nY ) );
2663 [ # # ]: 0 : DrawLine( Point( nX-1, nY-1 ), Point( nX-1, nY+1 ) );
2664 [ # # ]: 0 : DrawLine( Point( nX-2, nY-2 ), Point( nX-2, nY+2 ) );
2665 : : }
2666 : :
2667 : 0 : return mnDropPos;
2668 : : }
2669 : :
2670 : : // -----------------------------------------------------------------------
2671 : :
2672 : 0 : void TabBar::HideDropPos()
2673 : : {
2674 [ # # ]: 0 : if ( mbDropPos )
2675 : : {
2676 : : ImplTabBarItem* pItem;
2677 : : long nX;
2678 : 0 : long nY1 = (maWinSize.Height()/2)-3;
2679 : 0 : long nY2 = nY1 + 5;
2680 : 0 : sal_uInt16 nItemCount = (sal_uInt16)mpItemList->size();
2681 : :
2682 [ # # ]: 0 : if ( mnDropPos < nItemCount )
2683 : : {
2684 : 0 : pItem = (*mpItemList)[ mnDropPos ];
2685 : 0 : nX = pItem->maRect.Left()+TABBAR_OFFSET_X;
2686 : : // Paint direkt aufrufen, da bei Drag and Drop kein Paint
2687 : : // moeglich
2688 [ # # ]: 0 : Rectangle aRect( nX-1, nY1, nX+3, nY2 );
2689 [ # # ]: 0 : Region aRegion( aRect );
2690 [ # # ]: 0 : SetClipRegion( aRegion );
2691 [ # # ]: 0 : Paint( aRect );
2692 [ # # ][ # # ]: 0 : SetClipRegion();
2693 : : }
2694 [ # # ][ # # ]: 0 : if ( (mnDropPos > 0) && (mnDropPos < nItemCount+1) )
2695 : : {
2696 : 0 : pItem = (*mpItemList)[ mnDropPos-1 ];
2697 : 0 : nX = pItem->maRect.Right()-TABBAR_OFFSET_X;
2698 : : // Paint direkt aufrufen, da bei Drag and Drop kein Paint
2699 : : // moeglich
2700 [ # # ]: 0 : Rectangle aRect( nX-2, nY1, nX+1, nY2 );
2701 [ # # ]: 0 : Region aRegion( aRect );
2702 [ # # ]: 0 : SetClipRegion( aRegion );
2703 [ # # ]: 0 : Paint( aRect );
2704 [ # # ][ # # ]: 0 : SetClipRegion();
2705 : : }
2706 : :
2707 : 0 : mbDropPos = sal_False;
2708 : 0 : mnDropPos = 0;
2709 : : }
2710 : 0 : }
2711 : :
2712 : : // -----------------------------------------------------------------------
2713 : :
2714 : 0 : sal_Bool TabBar::SwitchPage( const Point& rPos )
2715 : : {
2716 : 0 : sal_Bool bSwitch = sal_False;
2717 : 0 : sal_uInt16 nSwitchId = GetPageId( rPos );
2718 [ # # ]: 0 : if ( !nSwitchId )
2719 : 0 : EndSwitchPage();
2720 : : else
2721 : : {
2722 [ # # ]: 0 : if ( nSwitchId != mnSwitchId )
2723 : : {
2724 : 0 : mnSwitchId = nSwitchId;
2725 : 0 : mnSwitchTime = Time::GetSystemTicks();
2726 : : }
2727 : : else
2728 : : {
2729 : : // Erst nach 500 ms umschalten
2730 [ # # ]: 0 : if ( mnSwitchId != GetCurPageId() )
2731 : : {
2732 [ # # ]: 0 : if ( Time::GetSystemTicks() > mnSwitchTime+500 )
2733 : : {
2734 : 0 : mbInSwitching = sal_True;
2735 [ # # ]: 0 : if ( ImplDeactivatePage() )
2736 : : {
2737 : 0 : SetCurPageId( mnSwitchId );
2738 : 0 : Update();
2739 : 0 : ImplActivatePage();
2740 : 0 : ImplSelect();
2741 : 0 : bSwitch = sal_True;
2742 : : }
2743 : 0 : mbInSwitching = sal_False;
2744 : : }
2745 : : }
2746 : : }
2747 : : }
2748 : :
2749 : 0 : return bSwitch;
2750 : : }
2751 : :
2752 : : // -----------------------------------------------------------------------
2753 : :
2754 : 0 : void TabBar::EndSwitchPage()
2755 : : {
2756 : 0 : mnSwitchTime = 0;
2757 : 0 : mnSwitchId = 0;
2758 : 0 : }
2759 : :
2760 : : // -----------------------------------------------------------------------
2761 : :
2762 : 761 : void TabBar::SetStyle( WinBits nStyle )
2763 : : {
2764 : 761 : mnWinStyle = nStyle;
2765 : 761 : ImplInitControls();
2766 : : // Evt. Controls neu anordnen
2767 [ + - ][ + + ]: 761 : if ( IsReallyVisible() && IsUpdateMode() )
[ + + ]
2768 : 138 : Resize();
2769 : 761 : }
2770 : :
2771 : : // -----------------------------------------------------------------------
2772 : :
2773 : 463 : Size TabBar::CalcWindowSizePixel() const
2774 : : {
2775 : 463 : long nWidth = 0;
2776 : :
2777 [ - + ]: 463 : if ( mpItemList->size() )
2778 : : {
2779 : 0 : ((TabBar*)this)->ImplCalcWidth();
2780 [ # # ]: 0 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
2781 : : {
2782 : 0 : ImplTabBarItem* pItem = (*mpItemList)[ i ];
2783 : 0 : nWidth += pItem->mnWidth;
2784 : : }
2785 : 0 : nWidth += TABBAR_OFFSET_X+TABBAR_OFFSET_X2;
2786 : : }
2787 : :
2788 : 463 : return Size( nWidth, GetSettings().GetStyleSettings().GetScrollBarSize() );
2789 : : }
2790 : : // -----------------------------------------------------------------------
2791 : :
2792 : 2042 : Rectangle TabBar::GetPageArea() const
2793 : : {
2794 [ + - ]: 2042 : return Rectangle( Point( mnOffX, mnOffY ), Size( mnLastOffX-mnOffX+1, GetSizePixel().Height()-mnOffY ) );
2795 : : }
2796 : :
2797 : : // -----------------------------------------------------------------------
2798 : :
2799 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > TabBar::CreateAccessible()
2800 : : {
2801 : 0 : return mpImpl->maAccessibleFactory.getFactory().createAccessibleTabBar( *this );
2802 : : }
2803 : :
2804 : : // -----------------------------------------------------------------------
2805 : :
2806 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|