LibreOffice Module svtools (master) 1
tabbar.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include <svtools/tabbar.hxx>
22#include <tools/time.hxx>
23#include <tools/poly.hxx>
24#include <utility>
26#include <vcl/bitmapex.hxx>
27#include <vcl/svapp.hxx>
28#include <vcl/help.hxx>
29#include <vcl/decoview.hxx>
30#include <vcl/event.hxx>
31#include <vcl/settings.hxx>
32#include <vcl/commandevent.hxx>
35#include <vcl/ptrstyle.hxx>
36#include <vcl/weldutils.hxx>
37#include <svtools/svtresid.hxx>
38#include <svtools/strings.hrc>
39#include <limits>
40#include <memory>
41#include <vector>
42#include <vcl/idle.hxx>
43#include <bitmaps.hlst>
44
45namespace
46{
47
48constexpr sal_uInt16 TABBAR_DRAG_SCROLLOFF = 5;
49constexpr sal_uInt16 TABBAR_MINSIZE = 5;
50
51constexpr sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
52
53class TabDrawer
54{
55private:
56 vcl::RenderContext& mrRenderContext;
57 const StyleSettings& mrStyleSettings;
58
59 tools::Rectangle maRect;
60 tools::Rectangle maLineRect;
61
62 Color maSelectedColor;
63 Color maCustomColor;
64
65public:
66 bool mbSelected:1;
67 bool mbCustomColored:1;
68 bool mbEnabled:1;
69 bool mbProtect:1;
70
71 explicit TabDrawer(vcl::RenderContext& rRenderContext)
72 : mrRenderContext(rRenderContext)
73 , mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings())
74 , mbSelected(false)
75 , mbCustomColored(false)
76 , mbEnabled(false)
77 , mbProtect(false)
78 {
79
80 }
81
82 void drawOuterFrame()
83 {
84 // set correct FillInBrush depending on status
85 if (mbSelected)
86 {
87 // Currently selected Tab
88 mrRenderContext.SetFillColor(maSelectedColor);
89 mrRenderContext.SetLineColor(maSelectedColor);
90 mrRenderContext.DrawRect(maRect);
91 mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
92 }
93 else if (mbCustomColored)
94 {
95 mrRenderContext.SetFillColor(maCustomColor);
96 mrRenderContext.SetLineColor(maCustomColor);
97 mrRenderContext.DrawRect(maRect);
98 mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
99 }
100 }
101
102 void drawText(const OUString& aText)
103 {
104 tools::Rectangle aRect = maRect;
105 tools::Long nTextWidth = mrRenderContext.GetTextWidth(aText);
106 tools::Long nTextHeight = mrRenderContext.GetTextHeight();
107 Point aPos = aRect.TopLeft();
108 aPos.AdjustX((aRect.getOpenWidth() - nTextWidth) / 2 );
109 aPos.AdjustY((aRect.getOpenHeight() - nTextHeight) / 2 );
110
111 if (mbEnabled)
112 mrRenderContext.DrawText(aPos, aText);
113 else
114 mrRenderContext.DrawCtrlText(aPos, aText, 0, aText.getLength(), (DrawTextFlags::Disable | DrawTextFlags::Mnemonic));
115 }
116
117 void drawOverTopBorder()
118 {
119 Point aTopLeft = maRect.TopLeft() + Point(1, 0);
120 Point aTopRight = maRect.TopRight() + Point(-1, 0);
121
122 tools::Rectangle aDelRect(aTopLeft, aTopRight);
123 mrRenderContext.DrawRect(aDelRect);
124 }
125
126 void drawColorLine()
127 {
128 if (!mbSelected)
129 return;
130
131 // tdf#141396: the color must be different from the rest of the selected tab
132 Color aLineColor = (mbCustomColored && maCustomColor != maSelectedColor)
133 ? maCustomColor
134 : mrStyleSettings.GetDarkShadowColor();
135 mrRenderContext.SetFillColor(aLineColor);
136 mrRenderContext.SetLineColor(aLineColor);
137 mrRenderContext.DrawRect(maLineRect);
138 }
139
140 void drawSeparator()
141 {
142 const tools::Long cMargin = 5;
143 const tools::Long aRight( maRect.Right() - 1 );
144 mrRenderContext.SetLineColor(mrStyleSettings.GetShadowColor());
145 mrRenderContext.DrawLine(Point(aRight, maRect.Top() + cMargin),
146 Point(aRight, maRect.Bottom() - cMargin));
147 }
148
149 void drawTab()
150 {
151 drawOuterFrame();
152 drawColorLine();
153 if (!mbSelected && !mbCustomColored)
154 drawSeparator();
155 if (mbProtect)
156 {
157 BitmapEx aBitmap(BMP_TAB_LOCK);
158 Point aPosition = maRect.TopLeft();
159 aPosition.AdjustX(2);
160 aPosition.AdjustY((maRect.getOpenHeight() - aBitmap.GetSizePixel().Height()) / 2);
161 mrRenderContext.DrawBitmapEx(aPosition, aBitmap);
162 }
163 }
164
165 void setRect(const tools::Rectangle& rRect)
166 {
167 maLineRect = tools::Rectangle(rRect.BottomLeft(), rRect.BottomRight());
168 maLineRect.AdjustTop(-2);
169 maRect = rRect;
170 }
171
172 void setSelected(bool bSelected)
173 {
174 mbSelected = bSelected;
175 }
176
177 void setCustomColored(bool bCustomColored)
178 {
179 mbCustomColored = bCustomColored;
180 }
181
182 void setEnabled(bool bEnabled)
183 {
184 mbEnabled = bEnabled;
185 }
186
187 void setSelectedFillColor(const Color& rColor)
188 {
189 maSelectedColor = rColor;
190 }
191
192 void setCustomColor(const Color& rColor)
193 {
194 maCustomColor = rColor;
195 }
196};
197
198} // anonymous namespace
199
201{
202 sal_uInt16 mnId;
204 OUString maText;
205 OUString maHelpText;
206 OUString maAuxiliaryText; // used in LayerTabBar for real layer name
209 OString maHelpId;
210 bool mbShort : 1;
211 bool mbSelect : 1;
212 bool mbProtect : 1;
215
216 ImplTabBarItem(sal_uInt16 nItemId, OUString aText, TabBarPageBits nPageBits)
217 : mnId(nItemId)
218 , mnBits(nPageBits)
219 , maText(std::move(aText))
220 , mnWidth(0)
221 , mbShort(false)
222 , mbSelect(false)
223 , mbProtect(false)
226 {
227 }
228
230 {
231 return maTabBgColor == COL_AUTO;
232 }
233
234 bool IsSelected(ImplTabBarItem const * pCurItem) const
235 {
236 return mbSelect || (pCurItem == this);
237 }
238
239 OUString const & GetRenderText() const
240 {
241 return maText;
242 }
243};
244
246{
247public:
248 ImplTabSizer( TabBar* pParent, WinBits nWinStyle );
249
250 TabBar* GetParent() const { return static_cast<TabBar*>(Window::GetParent()); }
251
252private:
253 void ImplTrack( const Point& rScreenPos );
254
255 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
256 virtual void Tracking( const TrackingEvent& rTEvt ) override;
257 virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override;
258
261};
262
264 : Window( pParent, nWinStyle & WB_3DLOOK )
265 , mnStartWidth(0)
266{
267 SetPointer(PointerStyle::HSizeBar);
269}
270
271void ImplTabSizer::ImplTrack( const Point& rScreenPos )
272{
273 TabBar* pParent = GetParent();
274 tools::Long nDiff = rScreenPos.X() - maStartPos.X();
275 pParent->mnSplitSize = mnStartWidth + (pParent->IsMirrored() ? -nDiff : nDiff);
276 if ( pParent->mnSplitSize < TABBAR_MINSIZE )
277 pParent->mnSplitSize = TABBAR_MINSIZE;
278 pParent->Split();
279 pParent->PaintImmediately();
280}
281
283{
284 if ( GetParent()->IsInEditMode() )
285 {
287 return;
288 }
289
290 if ( rMEvt.IsLeft() )
291 {
295 }
296}
297
299{
300 if ( rTEvt.IsTrackingEnded() )
301 {
302 if ( rTEvt.IsTrackingCanceled() )
304 GetParent()->mnSplitSize = 0;
305 }
306 else
308}
309
311{
312 DecorationView aDecoView(&rRenderContext);
313 tools::Rectangle aOutputRect(Point(0, 0), GetOutputSizePixel());
314 aDecoView.DrawHandle(aOutputRect);
315}
316
317namespace {
318
319// Is not named Impl. as it may be both instantiated and derived from
320class TabBarEdit final : public InterimItemWindow
321{
322private:
323 std::unique_ptr<weld::Entry> m_xEntry;
324 Idle maLoseFocusIdle;
325 bool mbPostEvt;
326
327 DECL_LINK( ImplEndEditHdl, void*, void );
328 DECL_LINK( ImplEndTimerHdl, Timer*, void );
329 DECL_LINK( ActivatedHdl, weld::Entry&, bool );
330 DECL_LINK( KeyInputHdl, const KeyEvent&, bool );
331 DECL_LINK( FocusOutHdl, weld::Widget&, void );
332
333public:
334 TabBarEdit(TabBar* pParent);
335 virtual void dispose() override;
336
337 TabBar* GetParent() const { return static_cast<TabBar*>(Window::GetParent()); }
338
339 weld::Entry& get_widget() { return *m_xEntry; }
340
341 void SetPostEvent() { mbPostEvt = true; }
342 void ResetPostEvent() { mbPostEvt = false; }
343};
344
345}
346
347TabBarEdit::TabBarEdit(TabBar* pParent)
348 : InterimItemWindow(pParent, "svt/ui/tabbaredit.ui", "TabBarEdit")
349 , m_xEntry(m_xBuilder->weld_entry("entry"))
350 , maLoseFocusIdle( "svtools::TabBarEdit maLoseFocusIdle" )
351{
352 InitControlBase(m_xEntry.get());
353
354 mbPostEvt = false;
355 maLoseFocusIdle.SetPriority( TaskPriority::REPAINT );
356 maLoseFocusIdle.SetInvokeHandler( LINK( this, TabBarEdit, ImplEndTimerHdl ) );
357
358 m_xEntry->connect_activate(LINK(this, TabBarEdit, ActivatedHdl));
359 m_xEntry->connect_key_press(LINK(this, TabBarEdit, KeyInputHdl));
360 m_xEntry->connect_focus_out(LINK(this, TabBarEdit, FocusOutHdl));
361}
362
363void TabBarEdit::dispose()
364{
365 m_xEntry.reset();
367}
368
369IMPL_LINK_NOARG(TabBarEdit, ActivatedHdl, weld::Entry&, bool)
370{
371 if ( !mbPostEvt )
372 {
373 if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), reinterpret_cast<void*>(false), true ) )
374 mbPostEvt = true;
375 }
376 return true;
377}
378
379IMPL_LINK(TabBarEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
380{
381 if (!rKEvt.GetKeyCode().GetModifier() && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
382 {
383 if ( !mbPostEvt )
384 {
385 if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), reinterpret_cast<void*>(true), true ) )
386 mbPostEvt = true;
387 }
388 return true;
389 }
390 return false;
391}
392
393IMPL_LINK_NOARG(TabBarEdit, FocusOutHdl, weld::Widget&, void)
394{
395 if ( !mbPostEvt )
396 {
397 if ( PostUserEvent( LINK( this, TabBarEdit, ImplEndEditHdl ), reinterpret_cast<void*>(false), true ) )
398 mbPostEvt = true;
399 }
400}
401
402IMPL_LINK( TabBarEdit, ImplEndEditHdl, void*, pCancel, void )
403{
404 ResetPostEvent();
405 maLoseFocusIdle.Stop();
406
407 // We need this query, because the edit gets a losefocus event,
408 // when it shows the context menu or the insert symbol dialog
409 if (!m_xEntry->has_focus() && m_xEntry->has_child_focus())
410 maLoseFocusIdle.Start();
411 else
412 GetParent()->EndEditMode( pCancel != nullptr );
413}
414
415IMPL_LINK_NOARG(TabBarEdit, ImplEndTimerHdl, Timer *, void)
416{
417 if (m_xEntry->has_focus())
418 return;
419
420 // We need this query, because the edit gets a losefocus event,
421 // when it shows the context menu or the insert symbol dialog
422 if (m_xEntry->has_child_focus())
423 maLoseFocusIdle.Start();
424 else
425 GetParent()->EndEditMode( true );
426}
427
428namespace {
429
430class TabButtons final : public InterimItemWindow
431{
432public:
433 std::unique_ptr<weld::Button> m_xFirstButton;
434 std::unique_ptr<weld::Button> m_xPrevButton;
435 std::unique_ptr<weld::Button> m_xNextButton;
436 std::unique_ptr<weld::Button> m_xLastButton;
437 std::unique_ptr<weld::Button> m_xAddButton;
438 std::shared_ptr<weld::ButtonPressRepeater> m_xAddRepeater;
439 std::shared_ptr<weld::ButtonPressRepeater> m_xPrevRepeater;
440 std::shared_ptr<weld::ButtonPressRepeater> m_xNextRepeater;
441
442 TabButtons(TabBar* pParent, bool bSheets)
443 : InterimItemWindow(pParent,
444 pParent->IsMirrored() ? OUString("svt/ui/tabbuttonsmirrored.ui")
445 : OUString("svt/ui/tabbuttons.ui"),
446 "TabButtons")
447 , m_xFirstButton(m_xBuilder->weld_button("first"))
448 , m_xPrevButton(m_xBuilder->weld_button("prev"))
449 , m_xNextButton(m_xBuilder->weld_button("next"))
450 , m_xLastButton(m_xBuilder->weld_button("last"))
451 , m_xAddButton(m_xBuilder->weld_button("add"))
452 {
453 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
454 SetPaintTransparent(false);
455 SetBackground(rStyleSettings.GetFaceColor());
456
457 m_xFirstButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVET0HOME));
458 m_xPrevButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVELEFT));
459 m_xNextButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVERIGHT));
460 m_xLastButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVETOEND));
461 m_xAddButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_ADDTAB));
462
463 if (bSheets)
464 {
465 m_xFirstButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVETOHOME_SHEETS));
466 m_xPrevButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVELEFT_SHEETS));
467 m_xNextButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVERIGHT_SHEETS));
468 m_xLastButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVETOEND_SHEETS));
469 m_xAddButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_ADDTAB_SHEETS));
470 }
471 }
472
473 void AdaptToHeight(int nHeight)
474 {
475 if (m_xFirstButton->get_preferred_size() == Size(nHeight, nHeight))
476 return;
477 m_xFirstButton->set_size_request(nHeight, nHeight);
478 m_xPrevButton->set_size_request(nHeight, nHeight);
479 m_xNextButton->set_size_request(nHeight, nHeight);
480 m_xLastButton->set_size_request(nHeight, nHeight);
481 m_xAddButton->set_size_request(nHeight, nHeight);
483 }
484
485 virtual void dispose() override
486 {
487 m_xNextRepeater.reset();
488 m_xPrevRepeater.reset();
489 m_xAddRepeater.reset();
490 m_xAddButton.reset();
491 m_xLastButton.reset();
492 m_xNextButton.reset();
493 m_xPrevButton.reset();
494 m_xFirstButton.reset();
496 }
497};
498
499}
500
502{
506 std::vector<ImplTabBarItem> maItemList;
507
508 vcl::AccessibleFactoryAccess maAccessibleFactory;
509
510 sal_uInt16 getItemSize() const
511 {
512 return static_cast<sal_uInt16>(maItemList.size());
513 }
514};
515
516TabBar::TabBar( vcl::Window* pParent, WinBits nWinStyle, bool bSheets ) :
517 Window( pParent, (nWinStyle & WB_3DLOOK) | WB_CLIPCHILDREN )
518{
519 ImplInit( nWinStyle, bSheets );
521}
522
524{
525 disposeOnce();
526}
527
529{
530 EndEditMode( true );
531 mpImpl.reset();
532 Window::dispose();
533}
534
535const sal_uInt16 TabBar::APPEND = ::std::numeric_limits<sal_uInt16>::max();
536const sal_uInt16 TabBar::PAGE_NOT_FOUND = ::std::numeric_limits<sal_uInt16>::max();
537
538void TabBar::ImplInit( WinBits nWinStyle, bool bSheets )
539{
540 mpImpl.reset(new TabBar_Impl);
541
542 mnMaxPageWidth = 0;
543 mnCurMaxWidth = 0;
544 mnOffX = 0;
545 mnOffY = 0;
546 mnLastOffX = 0;
547 mnSplitSize = 0;
548 mnSwitchTime = 0;
549 mnWinStyle = nWinStyle;
550 mnCurPageId = 0;
551 mnFirstPos = 0;
552 mnDropPos = 0;
553 mnSwitchId = 0;
554 mnEditId = 0;
555 mbFormat = true;
556 mbFirstFormat = true;
557 mbSizeFormat = true;
558 mbAutoEditMode = false;
559 mbEditCanceled = false;
560 mbDropPos = false;
561 mbInSelect = false;
562 mbMirrored = false;
563 mbScrollAlwaysEnabled = false;
564 mbSheets = bSheets;
565
567
569 ImplInitSettings( true, true );
570}
571
573{
574 if ( i < mpImpl->maItemList.size() )
575 {
577 return &mpImpl->maItemList[maCurrentItemList];
578 }
579 return nullptr;
580}
581
583{
584 if ( maCurrentItemList > 0 )
585 {
586 return &mpImpl->maItemList[--maCurrentItemList];
587 }
588 return nullptr;
589}
590
592{
593 if ( maCurrentItemList + 1 < mpImpl->maItemList.size() )
594 {
595 return &mpImpl->maItemList[++maCurrentItemList];
596 }
597 return nullptr;
598}
599
600void TabBar::ImplInitSettings( bool bFont, bool bBackground )
601{
602 // FIXME RenderContext
603
604 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
605
606 if (bFont)
607 {
608 vcl::Font aToolFont = rStyleSettings.GetToolFont();
609 aToolFont.SetWeight( WEIGHT_BOLD );
610 ApplyControlFont(*GetOutDev(), aToolFont);
611
612 // Adapt font size if window too small?
613 while (GetTextHeight() > (GetOutputSizePixel().Height() - 1))
614 {
615 vcl::Font aFont = GetFont();
616 if (aFont.GetFontHeight() <= 6)
617 break;
618 aFont.SetFontHeight(aFont.GetFontHeight() - 1);
619 SetFont(aFont);
620 }
621 }
622
623 if (bBackground)
624 {
625 ApplyControlBackground(*GetOutDev(), rStyleSettings.GetFaceColor());
626 }
627}
628
629void TabBar::ImplGetColors(const StyleSettings& rStyleSettings,
630 Color& rFaceColor, Color& rFaceTextColor,
631 Color& rSelectColor, Color& rSelectTextColor)
632{
634 rFaceColor = GetControlBackground();
635 else
636 rFaceColor = rStyleSettings.GetInactiveTabColor();
638 rFaceTextColor = GetControlForeground();
639 else
640 rFaceTextColor = rStyleSettings.GetButtonTextColor();
641 rSelectColor = rStyleSettings.GetActiveTabColor();
642 rSelectTextColor = rStyleSettings.GetWindowTextColor();
643}
644
646{
647 // Sizes should only be retrieved if the text or the font was changed
648 if (!mbSizeFormat)
649 return false;
650
651 // retrieve width of tabs with bold font
652 vcl::Font aFont = GetFont();
653 if (aFont.GetWeight() != WEIGHT_BOLD)
654 {
655 aFont.SetWeight(WEIGHT_BOLD);
656 SetFont(aFont);
657 }
658
659 if (mnMaxPageWidth)
661 else
662 {
664 if (mnCurMaxWidth < 1)
665 mnCurMaxWidth = 1;
666 }
667
668 bool bChanged = false;
669 for (auto& rItem : mpImpl->maItemList)
670 {
671 tools::Long nNewWidth = GetTextWidth(rItem.GetRenderText());
672 if (mnCurMaxWidth && (nNewWidth > mnCurMaxWidth))
673 {
674 rItem.mbShort = true;
675 nNewWidth = mnCurMaxWidth;
676 }
677 else
678 {
679 rItem.mbShort = false;
680 }
681
682 // Padding is dependent on font height - bigger font = bigger padding
683 tools::Long nFontWidth = aFont.GetFontHeight();
684 if (rItem.mbProtect)
685 nNewWidth += 24;
686 nNewWidth += nFontWidth * 2;
687
688 if (rItem.mnWidth != nNewWidth)
689 {
690 rItem.mnWidth = nNewWidth;
691 if (!rItem.maRect.IsEmpty())
692 bChanged = true;
693 }
694 }
695 mbSizeFormat = false;
696 mbFormat = true;
697 return bChanged;
698}
699
701{
703
704 if (!mbFormat)
705 return;
706
708
709 const size_t nItemListSize = mpImpl->maItemList.size();
710 for (size_t nItemIndex = 0; nItemIndex < nItemListSize; nItemIndex++)
711 {
712 // tdf#100584 - arrange sheets depending on the RTL settings
713 auto& rItem = mbMirrored ? mpImpl->maItemList[nItemListSize - nItemIndex - 1]
714 : mpImpl->maItemList[nItemIndex];
715
716 // At all non-visible tabs an empty rectangle is set
717 if ((nItemIndex + 1 < mnFirstPos) || (x > mnLastOffX))
718 rItem.maRect.SetEmpty();
719 else
720 {
721 // Slightly before the tab before the first visible page
722 // should also be visible
723 if (nItemIndex + 1 == mnFirstPos)
724 {
725 rItem.maRect.SetLeft(x - rItem.mnWidth);
726 }
727 else
728 {
729 rItem.maRect.SetLeft(x);
730 x += rItem.mnWidth;
731 }
732 rItem.maRect.SetRight(x);
733 rItem.maRect.SetBottom(maWinSize.Height() - 1);
734
735 if (mbMirrored)
736 {
737 tools::Long nNewLeft = mnOffX + mnLastOffX - rItem.maRect.Right();
738 tools::Long nNewRight = mnOffX + mnLastOffX - rItem.maRect.Left();
739 rItem.maRect.SetRight(nNewRight);
740 rItem.maRect.SetLeft(nNewLeft);
741 }
742 }
743 }
744
745 mbFormat = false;
746
747 // enable/disable button
749}
750
752{
753 sal_uInt16 nCount = mpImpl->getItemSize();
754 if (!nCount || mbSizeFormat || mbFormat)
755 return 0;
756
757 sal_uInt16 nLastFirstPos = nCount - 1;
758 tools::Long nWinWidth = mnLastOffX - mnOffX - ADDNEWPAGE_AREAWIDTH;
759 tools::Long nWidth = mpImpl->maItemList[nLastFirstPos].mnWidth;
760
761 while (nLastFirstPos && (nWidth < nWinWidth))
762 {
763 nLastFirstPos--;
764 nWidth += mpImpl->maItemList[nLastFirstPos].mnWidth;
765 }
766 if ((nLastFirstPos != static_cast<sal_uInt16>(mpImpl->maItemList.size() - 1)) && (nWidth > nWinWidth))
767 nLastFirstPos++;
768 return nLastFirstPos;
769}
770
771IMPL_LINK(TabBar, ContextMenuHdl, const CommandEvent&, rCommandEvent, void)
772{
773 maScrollAreaContextHdl.Call(rCommandEvent);
774}
775
776IMPL_LINK(TabBar, MousePressHdl, const MouseEvent&, rMouseEvent, bool)
777{
778 if (rMouseEvent.IsRight())
779 ContextMenuHdl(CommandEvent(rMouseEvent.GetPosPixel(), CommandEventId::ContextMenu, true));
780 return false;
781}
782
784{
786 {
787 if (!mpImpl->mpSizer)
788 {
789 mpImpl->mpSizer.disposeAndReset(VclPtr<ImplTabSizer>::Create( this, mnWinStyle & (WB_DRAG | WB_3DLOOK)));
790 }
791 mpImpl->mpSizer->Show();
792 }
793 else
794 {
795 mpImpl->mpSizer.disposeAndClear();
796 }
797
798 mpImpl->mxButtonBox.disposeAndReset(VclPtr<TabButtons>::Create(this, mbSheets));
799
800 Link<const CommandEvent&, void> aContextLink = LINK( this, TabBar, ContextMenuHdl );
801
803 {
804 Link<weld::Button&,void> aLink = LINK(this, TabBar, ImplAddClickHandler);
805 mpImpl->mxButtonBox->m_xAddRepeater = std::make_shared<weld::ButtonPressRepeater>(
806 *mpImpl->mxButtonBox->m_xAddButton, aLink, aContextLink);
807 mpImpl->mxButtonBox->m_xAddButton->show();
808 }
809
810 Link<weld::Button&,void> aLink = LINK( this, TabBar, ImplClickHdl );
811
813 {
814 mpImpl->mxButtonBox->m_xPrevRepeater = std::make_shared<weld::ButtonPressRepeater>(
815 *mpImpl->mxButtonBox->m_xPrevButton, aLink, aContextLink);
816 mpImpl->mxButtonBox->m_xPrevButton->show();
817 mpImpl->mxButtonBox->m_xNextRepeater = std::make_shared<weld::ButtonPressRepeater>(
818 *mpImpl->mxButtonBox->m_xNextButton, aLink, aContextLink);
819 mpImpl->mxButtonBox->m_xNextButton->show();
820 }
821
822 if (mnWinStyle & WB_SCROLL)
823 {
824 Link<const MouseEvent&, bool> aBtnContextLink = LINK(this, TabBar, MousePressHdl);
825
826 mpImpl->mxButtonBox->m_xFirstButton->connect_clicked(aLink);
827 mpImpl->mxButtonBox->m_xFirstButton->connect_mouse_press(aBtnContextLink);
828 mpImpl->mxButtonBox->m_xFirstButton->show();
829 mpImpl->mxButtonBox->m_xLastButton->connect_clicked(aLink);
830 mpImpl->mxButtonBox->m_xLastButton->connect_mouse_press(aBtnContextLink);
831 mpImpl->mxButtonBox->m_xLastButton->show();
832 }
833
834 mpImpl->mxButtonBox->Show();
835}
836
838{
839 if (mbSizeFormat || mbFormat)
840 return;
841
842 // enable/disable buttons
843 bool bEnableBtn = mbScrollAlwaysEnabled || mnFirstPos > 0;
844 mpImpl->mxButtonBox->m_xFirstButton->set_sensitive(bEnableBtn);
845 mpImpl->mxButtonBox->m_xPrevButton->set_sensitive(bEnableBtn);
846 if (!bEnableBtn && mpImpl->mxButtonBox->m_xPrevRepeater)
847 mpImpl->mxButtonBox->m_xPrevRepeater->Stop();
849 mpImpl->mxButtonBox->m_xLastButton->set_sensitive(bEnableBtn);
850 mpImpl->mxButtonBox->m_xNextButton->set_sensitive(bEnableBtn);
851 if (!bEnableBtn && mpImpl->mxButtonBox->m_xNextRepeater)
852 mpImpl->mxButtonBox->m_xNextRepeater->Stop();
853}
854
855void TabBar::SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled)
856{
857 mbScrollAlwaysEnabled = bScrollAlwaysEnabled;
859}
860
861void TabBar::ImplShowPage( sal_uInt16 nPos )
862{
863 if (nPos >= mpImpl->getItemSize())
864 return;
865
866 // calculate width
868
869 auto& rItem = mpImpl->maItemList[nPos];
870 if (nPos < mnFirstPos)
871 SetFirstPageId( rItem.mnId );
872 else if (rItem.maRect.Right() > nWidth)
873 {
874 while (rItem.maRect.Right() > nWidth)
875 {
876 sal_uInt16 nNewPos = mnFirstPos + 1;
877 SetFirstPageId(GetPageId(nNewPos));
878 ImplFormat();
879 if (nNewPos != mnFirstPos)
880 break;
881 }
882 }
883}
884
885IMPL_LINK( TabBar, ImplClickHdl, weld::Button&, rBtn, void )
886{
887 if (&rBtn != mpImpl->mxButtonBox->m_xFirstButton.get() && &rBtn != mpImpl->mxButtonBox->m_xLastButton.get())
888 {
889 if ((GetPointerState().mnState & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)) == 0)
890 {
891 // like tdf#149482 if we didn't see a mouse up, but find that the mouse is no
892 // longer pressed at this point, then bail
893 mpImpl->mxButtonBox->m_xPrevRepeater->Stop();
894 mpImpl->mxButtonBox->m_xNextRepeater->Stop();
895 return;
896 }
897 }
898
899 EndEditMode();
900
901 sal_uInt16 nNewPos = mnFirstPos;
902
903 if (&rBtn == mpImpl->mxButtonBox->m_xFirstButton.get() || (&rBtn == mpImpl->mxButtonBox->m_xPrevButton.get() &&
904 mpImpl->mxButtonBox->m_xPrevRepeater->IsModKeyPressed()))
905 {
906 nNewPos = 0;
907 }
908 else if (&rBtn == mpImpl->mxButtonBox->m_xLastButton.get() || (&rBtn == mpImpl->mxButtonBox->m_xNextButton.get() &&
909 mpImpl->mxButtonBox->m_xNextRepeater->IsModKeyPressed()))
910 {
911 sal_uInt16 nCount = GetPageCount();
912 if (nCount)
913 nNewPos = nCount - 1;
914 }
915 else if (&rBtn == mpImpl->mxButtonBox->m_xPrevButton.get())
916 {
917 if (mnFirstPos)
918 nNewPos = mnFirstPos - 1;
919 }
920 else if (&rBtn == mpImpl->mxButtonBox->m_xNextButton.get())
921 {
922 sal_uInt16 nCount = GetPageCount();
923 if (mnFirstPos < nCount)
924 nNewPos = mnFirstPos+1;
925 }
926 else
927 {
928 return;
929 }
930
931 if (nNewPos != mnFirstPos)
932 SetFirstPageId(GetPageId(nNewPos));
933}
934
935IMPL_LINK_NOARG(TabBar, ImplAddClickHandler, weld::Button&, void)
936{
937 if ((GetPointerState().mnState & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)) == 0)
938 {
939 // tdf#149482 if we didn't see a mouse up, but find that the mouse is no
940 // longer pressed at this point, then bail
941 mpImpl->mxButtonBox->m_xAddRepeater->Stop();
942 return;
943 }
944
945 EndEditMode();
946 AddTabClick();
947}
948
950{
951 if (rMEvt.IsLeaveWindow())
952 mbInSelect = false;
953
954 Window::MouseMove(rMEvt);
955}
956
958{
959 // Only terminate EditMode and do not execute click
960 // if clicked inside our window,
961 if (IsInEditMode())
962 {
963 EndEditMode();
964 return;
965 }
966
967 sal_uInt16 nSelId = GetPageId(rMEvt.GetPosPixel());
968
969 if (!rMEvt.IsLeft())
970 {
971 Window::MouseButtonDown(rMEvt);
972 if (nSelId > 0 && nSelId != mnCurPageId)
973 {
974 if (ImplDeactivatePage())
975 {
976 SetCurPageId(nSelId);
979 ImplSelect();
980 }
981 mbInSelect = true;
982 }
983 return;
984 }
985
986 if (rMEvt.IsMod2() && mbAutoEditMode && nSelId)
987 {
988 if (StartEditMode(nSelId))
989 return;
990 }
991
992 if ((rMEvt.GetMode() & (MouseEventModifiers::MULTISELECT | MouseEventModifiers::RANGESELECT)) && (rMEvt.GetClicks() == 1))
993 {
994 if (nSelId)
995 {
996 sal_uInt16 nPos = GetPagePos(nSelId);
997
998 bool bSelectTab = false;
999
1000 if ((rMEvt.GetMode() & MouseEventModifiers::MULTISELECT) && (mnWinStyle & WB_MULTISELECT))
1001 {
1002 if (nSelId != mnCurPageId)
1003 {
1004 SelectPage(nSelId, !IsPageSelected(nSelId));
1005 bSelectTab = true;
1006 }
1007 }
1009 {
1010 bSelectTab = true;
1011 sal_uInt16 n;
1012 bool bSelect;
1013 sal_uInt16 nCurPos = GetPagePos(mnCurPageId);
1014 if (nPos <= nCurPos)
1015 {
1016 // Deselect all tabs till the clicked tab
1017 // and select all tabs from the clicked tab
1018 // 'till the actual position
1019 n = 0;
1020 while (n < nCurPos)
1021 {
1022 auto& rItem = mpImpl->maItemList[n];
1023 bSelect = n >= nPos;
1024
1025 if (rItem.mbSelect != bSelect)
1026 {
1027 rItem.mbSelect = bSelect;
1028 if (!rItem.maRect.IsEmpty())
1029 Invalidate(rItem.maRect);
1030 }
1031
1032 n++;
1033 }
1034 }
1035
1036 if (nPos >= nCurPos)
1037 {
1038 // Select all tabs from the actual position till the clicked tab
1039 // and deselect all tabs from the actual position
1040 // till the last tab
1041 sal_uInt16 nCount = mpImpl->getItemSize();
1042 n = nCurPos;
1043 while (n < nCount)
1044 {
1045 auto& rItem = mpImpl->maItemList[n];
1046
1047 bSelect = n <= nPos;
1048
1049 if (rItem.mbSelect != bSelect)
1050 {
1051 rItem.mbSelect = bSelect;
1052 if (!rItem.maRect.IsEmpty())
1053 Invalidate(rItem.maRect);
1054 }
1055
1056 n++;
1057 }
1058 }
1059 }
1060
1061 // scroll the selected tab if required
1062 if (bSelectTab)
1063 {
1066 ImplSelect();
1067 }
1068
1069 mbInSelect = true;
1070
1071 return;
1072 }
1073 }
1074 else if (rMEvt.GetClicks() == 2)
1075 {
1076 // call double-click-handler if required
1077 if (!rMEvt.GetModifier() && (!nSelId || (nSelId == mnCurPageId)))
1078 {
1079 sal_uInt16 nOldCurId = mnCurPageId;
1080 mnCurPageId = nSelId;
1081 DoubleClick();
1082 // check, as actual page could be switched inside
1083 // the doubleclick-handler
1084 if (mnCurPageId == nSelId)
1085 mnCurPageId = nOldCurId;
1086 }
1087
1088 return;
1089 }
1090 else
1091 {
1092 if (nSelId)
1093 {
1094 // execute Select if not actual page
1095 if (nSelId != mnCurPageId)
1096 {
1097 sal_uInt16 nPos = GetPagePos(nSelId);
1098 auto& rItem = mpImpl->maItemList[nPos];
1099
1100 if (!rItem.mbSelect)
1101 {
1102 // make not valid
1103 bool bUpdate = false;
1104 if (IsReallyVisible() && IsUpdateMode())
1105 bUpdate = true;
1106
1107 // deselect all selected items
1108 for (auto& xItem : mpImpl->maItemList)
1109 {
1110 if (xItem.mbSelect || (xItem.mnId == mnCurPageId))
1111 {
1112 xItem.mbSelect = false;
1113 if (bUpdate)
1114 Invalidate(xItem.maRect);
1115 }
1116 }
1117 }
1118
1119 if (ImplDeactivatePage())
1120 {
1121 SetCurPageId(nSelId);
1124 ImplSelect();
1125 }
1126
1127 mbInSelect = true;
1128 }
1129
1130 return;
1131 }
1132 }
1133
1134 Window::MouseButtonDown(rMEvt);
1135}
1136
1138{
1139 mbInSelect = false;
1140 Window::MouseButtonUp(rMEvt);
1141}
1142
1143void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rect)
1144{
1145 if (rRenderContext.IsNativeControlSupported(ControlType::WindowBackground,ControlPart::Entire))
1146 {
1147 rRenderContext.DrawNativeControl(ControlType::WindowBackground,ControlPart::Entire,rect,
1148 ControlState::ENABLED,ImplControlValue(0),OUString());
1149 }
1150 // calculate items and emit
1151 sal_uInt16 nItemCount = mpImpl->getItemSize();
1152 if (!nItemCount)
1153 return;
1154
1155 ImplPrePaint();
1156
1157 Color aFaceColor, aSelectColor, aFaceTextColor, aSelectTextColor;
1158 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1159 ImplGetColors(rStyleSettings, aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
1160
1162 rRenderContext.SetClipRegion(vcl::Region(GetPageArea()));
1163
1164 // select font
1165 vcl::Font aFont = rRenderContext.GetFont();
1166 vcl::Font aLightFont = aFont;
1167 aLightFont.SetWeight(WEIGHT_NORMAL);
1168
1169 TabDrawer aDrawer(rRenderContext);
1170
1171 aDrawer.setSelectedFillColor(aSelectColor);
1172
1173 // Now, start drawing the tabs.
1174
1175 ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount);
1176 ImplTabBarItem* pCurItem = nullptr;
1177 while (pItem)
1178 {
1179 // emit CurrentItem last, as it covers all others
1180 if (!pCurItem && (pItem->mnId == mnCurPageId))
1181 {
1182 pCurItem = pItem;
1183 pItem = prev();
1184 if (!pItem)
1185 pItem = pCurItem;
1186 continue;
1187 }
1188
1189 bool bCurrent = pItem == pCurItem;
1190
1191 if (!pItem->maRect.IsEmpty())
1192 {
1193 tools::Rectangle aRect = pItem->maRect;
1194 bool bSelected = pItem->IsSelected(pCurItem);
1195 // We disable custom background color in high contrast mode.
1196 bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode();
1197 OUString aText = pItem->mbShort ?
1198 rRenderContext.GetEllipsisString(pItem->GetRenderText(), mnCurMaxWidth) :
1199 pItem->GetRenderText();
1200
1201 aDrawer.setRect(aRect);
1202 aDrawer.setSelected(bSelected);
1203 aDrawer.setCustomColored(bCustomBgColor);
1204 aDrawer.setEnabled(true);
1205 aDrawer.setCustomColor(pItem->maTabBgColor);
1206 aDrawer.mbProtect = pItem->mbProtect;
1207 aDrawer.drawTab();
1208
1209 // currently visible sheet is drawn using a bold font
1210 if (bCurrent)
1211 rRenderContext.SetFont(aFont);
1212 else
1213 rRenderContext.SetFont(aLightFont);
1214
1215 // Set the correct FillInBrush depending on status
1216
1217 if (bSelected)
1218 rRenderContext.SetTextColor(aSelectTextColor);
1219 else if (bCustomBgColor)
1220 rRenderContext.SetTextColor(pItem->maTabTextColor);
1221 else
1222 rRenderContext.SetTextColor(aFaceTextColor);
1223
1224 // Special display of tab name depending on page bits
1225
1226 if (pItem->mnBits & TabBarPageBits::Blue)
1227 {
1228 rRenderContext.SetTextColor(COL_LIGHTBLUE);
1229 }
1230 if (pItem->mnBits & TabBarPageBits::Italic)
1231 {
1232 vcl::Font aSpecialFont = rRenderContext.GetFont();
1233 aSpecialFont.SetItalic(FontItalic::ITALIC_NORMAL);
1234 rRenderContext.SetFont(aSpecialFont);
1235 }
1236 if (pItem->mnBits & TabBarPageBits::Underline)
1237 {
1238 vcl::Font aSpecialFont = rRenderContext.GetFont();
1239 aSpecialFont.SetUnderline(LINESTYLE_SINGLE);
1240 rRenderContext.SetFont(aSpecialFont);
1241 }
1242
1243 aDrawer.drawText(aText);
1244
1245 if (bCurrent)
1246 {
1247 rRenderContext.SetLineColor();
1248 rRenderContext.SetFillColor(aSelectColor);
1249 aDrawer.drawOverTopBorder();
1250 break;
1251 }
1252
1253 pItem = prev();
1254 }
1255 else
1256 {
1257 if (bCurrent)
1258 break;
1259
1260 pItem = nullptr;
1261 }
1262
1263 if (!pItem)
1264 pItem = pCurItem;
1265 }
1266 rRenderContext.Pop();
1267}
1268
1270{
1271 Size aNewSize = GetOutputSizePixel();
1272
1273 tools::Long nSizerWidth = 0;
1274
1275 // order the Sizer
1276 if ( mpImpl->mpSizer )
1277 {
1278 Size aSizerSize = mpImpl->mpSizer->GetSizePixel();
1279 Point aNewSizerPos( mbMirrored ? 0 : (aNewSize.Width()-aSizerSize.Width()), 0 );
1280 Size aNewSizerSize( aSizerSize.Width(), aNewSize.Height() );
1281 mpImpl->mpSizer->SetPosSizePixel( aNewSizerPos, aNewSizerSize );
1282 nSizerWidth = aSizerSize.Width();
1283 }
1284
1285 // order the scroll buttons
1286 tools::Long const nHeight = aNewSize.Height();
1287 // adapt font height?
1288 ImplInitSettings( true, false );
1289
1290 mpImpl->mxButtonBox->AdaptToHeight(nHeight);
1291 Size const aBtnsSize(mpImpl->mxButtonBox->get_preferred_size().Width(), nHeight);
1292 Point aPos(mbMirrored ? (aNewSize.Width() - aBtnsSize.Width()) : 0, 0);
1293 mpImpl->mxButtonBox->SetPosSizePixel(aPos, aBtnsSize);
1294 auto nButtonWidth = aBtnsSize.Width();
1295
1296 // store size
1297 maWinSize = aNewSize;
1298
1299 if( mbMirrored )
1300 {
1301 mnOffX = nSizerWidth;
1303 }
1304 else
1305 {
1307 mnLastOffX = maWinSize.Width() - nSizerWidth - 1;
1308 }
1309
1310 // reformat
1311 mbSizeFormat = true;
1312 if ( IsReallyVisible() )
1313 {
1314 if ( ImplCalcWidth() )
1315 Invalidate();
1316
1317 ImplFormat();
1318
1319 // Ensure as many tabs as possible are visible:
1320 sal_uInt16 nLastFirstPos = ImplGetLastFirstPos();
1321 if ( mnFirstPos > nLastFirstPos )
1322 {
1323 mnFirstPos = nLastFirstPos;
1324 mbFormat = true;
1325 Invalidate();
1326 }
1327 // Ensure the currently selected page is visible
1329
1330 ImplFormat();
1331 }
1332
1333 // enable/disable button
1335}
1336
1338{
1339 if (rNEvt.GetType() == NotifyEventType::COMMAND)
1340 {
1341 if (rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel)
1342 {
1344 sal_uInt16 nNewPos = mnFirstPos;
1345 if (pData->GetNotchDelta() > 0)
1346 {
1347 if (mnFirstPos)
1348 nNewPos = mnFirstPos - 1;
1349 }
1350 else if (pData->GetNotchDelta() < 0)
1351 {
1352 sal_uInt16 nCount = GetPageCount();
1353 if (mnFirstPos < nCount)
1354 nNewPos = mnFirstPos + 1;
1355 }
1356 if (nNewPos != mnFirstPos)
1357 SetFirstPageId(GetPageId(nNewPos));
1358 }
1359 }
1360 return Window::PreNotify(rNEvt);
1361}
1362
1364{
1365 sal_uInt16 nItemId = GetPageId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
1366 if (nItemId)
1367 {
1368 if (rHEvt.GetMode() & HelpEventMode::BALLOON)
1369 {
1370 OUString aStr = GetHelpText(nItemId);
1371 if (!aStr.isEmpty())
1372 {
1373 tools::Rectangle aItemRect = GetPageRect(nItemId);
1374 Point aPt = OutputToScreenPixel(aItemRect.TopLeft());
1375 aItemRect.SetLeft( aPt.X() );
1376 aItemRect.SetTop( aPt.Y() );
1377 aPt = OutputToScreenPixel(aItemRect.BottomRight());
1378 aItemRect.SetRight( aPt.X() );
1379 aItemRect.SetBottom( aPt.Y() );
1380 Help::ShowBalloon(this, aItemRect.Center(), aItemRect, aStr);
1381 return;
1382 }
1383 }
1384
1385 // show text for quick- or balloon-help
1386 // if this is isolated or not fully visible
1387 if (rHEvt.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
1388 {
1389 sal_uInt16 nPos = GetPagePos(nItemId);
1390 auto& rItem = mpImpl->maItemList[nPos];
1391 if (rItem.mbShort || (rItem.maRect.Right() - 5 > mnLastOffX))
1392 {
1393 tools::Rectangle aItemRect = GetPageRect(nItemId);
1394 Point aPt = OutputToScreenPixel(aItemRect.TopLeft());
1395 aItemRect.SetLeft( aPt.X() );
1396 aItemRect.SetTop( aPt.Y() );
1397 aPt = OutputToScreenPixel(aItemRect.BottomRight());
1398 aItemRect.SetRight( aPt.X() );
1399 aItemRect.SetBottom( aPt.Y() );
1400 OUString aStr = mpImpl->maItemList[nPos].maText;
1401 if (!aStr.isEmpty())
1402 {
1403 if (rHEvt.GetMode() & HelpEventMode::BALLOON)
1404 Help::ShowBalloon(this, aItemRect.Center(), aItemRect, aStr);
1405 else
1406 Help::ShowQuickHelp(this, aItemRect, aStr);
1407 return;
1408 }
1409 }
1410 }
1411 }
1412
1413 Window::RequestHelp(rHEvt);
1414}
1415
1417{
1418 Window::StateChanged(nType);
1419
1420 if (nType == StateChangedType::InitShow)
1421 {
1422 if ( (mbSizeFormat || mbFormat) && !mpImpl->maItemList.empty() )
1423 ImplFormat();
1424 }
1425 else if (nType == StateChangedType::Zoom ||
1426 nType == StateChangedType::ControlFont)
1427 {
1428 ImplInitSettings(true, false);
1429 Invalidate();
1430 }
1431 else if (nType == StateChangedType::ControlForeground)
1432 Invalidate();
1433 else if (nType == StateChangedType::ControlBackground)
1434 {
1435 ImplInitSettings(false, true);
1436 Invalidate();
1437 }
1438 else if (nType == StateChangedType::Mirroring)
1439 {
1440 bool bIsRTLEnabled = IsRTLEnabled();
1441 // reacts on calls of EnableRTL, have to mirror all child controls
1442 if (mpImpl->mpSizer)
1443 mpImpl->mpSizer->EnableRTL(bIsRTLEnabled);
1444 if (mpImpl->mxButtonBox)
1445 {
1446 mpImpl->mxButtonBox->m_xFirstButton->set_direction(bIsRTLEnabled);
1447 mpImpl->mxButtonBox->m_xPrevButton->set_direction(bIsRTLEnabled);
1448 mpImpl->mxButtonBox->m_xNextButton->set_direction(bIsRTLEnabled);
1449 mpImpl->mxButtonBox->m_xLastButton->set_direction(bIsRTLEnabled);
1450 mpImpl->mxButtonBox->m_xAddButton->set_direction(bIsRTLEnabled);
1451 }
1452 if (mpImpl->mxEdit)
1453 {
1454 weld::Entry& rEntry = mpImpl->mxEdit->get_widget();
1455 rEntry.set_direction(bIsRTLEnabled);
1456 }
1457 }
1458}
1459
1461{
1462 Window::DataChanged(rDCEvt);
1463
1464 if (rDCEvt.GetType() == DataChangedEventType::FONTS
1465 || rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION
1466 || (rDCEvt.GetType() == DataChangedEventType::SETTINGS
1467 && rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
1468 {
1469 ImplInitSettings(true, true);
1470 Invalidate();
1471 }
1472}
1473
1475{
1476 Select();
1477 CallEventListeners(VclEventId::TabbarPageSelected, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)));
1478}
1479
1481{
1482 maSelectHdl.Call(this);
1483}
1484
1486{
1487}
1488
1490{
1491 maSplitHdl.Call(this);
1492}
1493
1495{
1496 ActivatePage();
1497
1498 CallEventListeners(VclEventId::TabbarPageActivated, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)));
1499}
1500
1502{}
1503
1505{
1506 bool bRet = DeactivatePage();
1507
1508 CallEventListeners(VclEventId::TabbarPageDeactivated, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(mnCurPageId)));
1509
1510 return bRet;
1511}
1512
1514{
1515 sal_uInt16 nItemCount = mpImpl->getItemSize();
1516 if (!nItemCount)
1517 return;
1518
1519 // tabbar should be formatted
1520 ImplFormat();
1521
1522 // assure the actual tabpage becomes visible at first format
1523 if (!mbFirstFormat)
1524 return;
1525
1526 mbFirstFormat = false;
1527
1528 if (!mnCurPageId || (mnFirstPos != 0) || mbDropPos)
1529 return;
1530
1531 auto& rItem = mpImpl->maItemList[GetPagePos(mnCurPageId)];
1532 if (rItem.maRect.IsEmpty())
1533 {
1534 // set mbDropPos (or misuse) to prevent Invalidate()
1535 mbDropPos = true;
1537 mbDropPos = false;
1538 if (mnFirstPos != 0)
1539 ImplFormat();
1540 }
1541}
1542
1544{
1545 // find last visible entry
1546 sal_uInt16 n = mnFirstPos + 1;
1547 if (n >= nItemCount)
1548 n = nItemCount-1;
1549 ImplTabBarItem* pItem = seek(n);
1550 while (pItem)
1551 {
1552 if (!pItem->maRect.IsEmpty())
1553 {
1554 n++;
1555 pItem = next();
1556 }
1557 else
1558 break;
1559 }
1560
1561 // draw all tabs (from back to front and actual last)
1562 if (pItem)
1563 n--;
1564 else if (n >= nItemCount)
1565 n = nItemCount-1;
1566 pItem = seek(n);
1567 return pItem;
1568}
1569
1571{
1572 return true;
1573}
1574
1576{
1577 return true;
1578}
1579
1581{
1582 return TABBAR_RENAMING_YES;
1583}
1584
1586{
1587}
1588
1590{
1591
1592}
1593
1595{
1596
1597}
1598
1599void TabBar::InsertPage(sal_uInt16 nPageId, const OUString& rText,
1600 TabBarPageBits nBits, sal_uInt16 nPos)
1601{
1602 assert (nPageId && "TabBar::InsertPage(): PageId must not be 0");
1603 assert ((GetPagePos(nPageId) == PAGE_NOT_FOUND) && "TabBar::InsertPage(): Page already exists");
1604 assert ((nBits <= TPB_DISPLAY_NAME_ALLFLAGS) && "TabBar::InsertPage(): Invalid flag set in nBits");
1605
1606 // create PageItem and insert in the item list
1607 ImplTabBarItem aItem( nPageId, rText, nBits );
1608 if (nPos < mpImpl->maItemList.size())
1609 {
1610 auto it = mpImpl->maItemList.begin();
1611 it += nPos;
1612 mpImpl->maItemList.insert(it, aItem);
1613 }
1614 else
1615 {
1616 mpImpl->maItemList.push_back(aItem);
1617 }
1618 mbSizeFormat = true;
1619
1620 // set CurPageId if required
1621 if (!mnCurPageId)
1623
1624 // redraw bar
1625 if (IsReallyVisible() && IsUpdateMode())
1626 Invalidate();
1627
1628 CallEventListeners(VclEventId::TabbarPageInserted, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)));
1629}
1630
1631Color TabBar::GetTabBgColor(sal_uInt16 nPageId) const
1632{
1633 sal_uInt16 nPos = GetPagePos(nPageId);
1634
1635 if (nPos != PAGE_NOT_FOUND)
1636 return mpImpl->maItemList[nPos].maTabBgColor;
1637 else
1638 return COL_AUTO;
1639}
1640
1641void TabBar::SetTabBgColor(sal_uInt16 nPageId, const Color& aTabBgColor)
1642{
1643 sal_uInt16 nPos = GetPagePos(nPageId);
1644 if (nPos == PAGE_NOT_FOUND)
1645 return;
1646
1647 auto& rItem = mpImpl->maItemList[nPos];
1648 if (aTabBgColor != COL_AUTO)
1649 {
1650 rItem.maTabBgColor = aTabBgColor;
1651 if (aTabBgColor.GetLuminance() <= 128) //Do not use aTabBgColor.IsDark(), because that threshold is way too low...
1652 rItem.maTabTextColor = COL_WHITE;
1653 else
1654 rItem.maTabTextColor = COL_BLACK;
1655 }
1656 else
1657 {
1658 rItem.maTabBgColor = COL_AUTO;
1659 rItem.maTabTextColor = COL_AUTO;
1660 }
1661}
1662
1663void TabBar::RemovePage(sal_uInt16 nPageId)
1664{
1665 sal_uInt16 nPos = GetPagePos(nPageId);
1666
1667 // does item exist
1668 if (nPos == PAGE_NOT_FOUND)
1669 return;
1670
1671 if (mnCurPageId == nPageId)
1672 mnCurPageId = 0;
1673
1674 // check if first visible page should be moved
1675 if (mnFirstPos > nPos)
1676 mnFirstPos--;
1677
1678 // delete item data
1679 auto it = mpImpl->maItemList.begin();
1680 it += nPos;
1681 mpImpl->maItemList.erase(it);
1682
1683 // redraw bar
1684 if (IsReallyVisible() && IsUpdateMode())
1685 Invalidate();
1686
1687 CallEventListeners(VclEventId::TabbarPageRemoved, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)));
1688}
1689
1690void TabBar::MovePage(sal_uInt16 nPageId, sal_uInt16 nNewPos)
1691{
1692 sal_uInt16 nPos = GetPagePos(nPageId);
1693 Pair aPair(nPos, nNewPos);
1694
1695 if (nPos < nNewPos)
1696 nNewPos--;
1697
1698 if (nPos == nNewPos)
1699 return;
1700
1701 // does item exit
1702 if (nPos == PAGE_NOT_FOUND)
1703 return;
1704
1705 // move tabbar item in the list
1706 auto it = mpImpl->maItemList.begin();
1707 it += nPos;
1708 ImplTabBarItem aItem = std::move(*it);
1709 mpImpl->maItemList.erase(it);
1710 if (nNewPos < mpImpl->maItemList.size())
1711 {
1712 it = mpImpl->maItemList.begin();
1713 it += nNewPos;
1714 mpImpl->maItemList.insert(it, aItem);
1715 }
1716 else
1717 {
1718 mpImpl->maItemList.push_back(aItem);
1719 }
1720
1721 // redraw bar
1722 if (IsReallyVisible() && IsUpdateMode())
1723 Invalidate();
1724
1725 CallEventListeners( VclEventId::TabbarPageMoved, static_cast<void*>(&aPair) );
1726}
1727
1729{
1730 // delete all items
1731 mpImpl->maItemList.clear();
1732
1733 // remove items from the list
1734 mbSizeFormat = true;
1735 mnCurPageId = 0;
1736 mnFirstPos = 0;
1738
1739 // redraw bar
1740 if (IsReallyVisible() && IsUpdateMode())
1741 Invalidate();
1742
1743 CallEventListeners(VclEventId::TabbarPageRemoved, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(PAGE_NOT_FOUND)));
1744}
1745
1746bool TabBar::IsPageEnabled(sal_uInt16 nPageId) const
1747{
1748 if (isDisposed())
1749 return false;
1750 sal_uInt16 nPos = GetPagePos(nPageId);
1751
1752 return nPos != PAGE_NOT_FOUND;
1753}
1754
1755void TabBar::SetPageBits(sal_uInt16 nPageId, TabBarPageBits nBits)
1756{
1757 sal_uInt16 nPos = GetPagePos(nPageId);
1758
1759 if (nPos == PAGE_NOT_FOUND)
1760 return;
1761
1762 auto& rItem = mpImpl->maItemList[nPos];
1763
1764 if (rItem.mnBits != nBits)
1765 {
1766 rItem.mnBits = nBits;
1767
1768 // redraw bar
1769 if (IsReallyVisible() && IsUpdateMode())
1770 Invalidate(rItem.maRect);
1771 }
1772}
1773
1774TabBarPageBits TabBar::GetPageBits(sal_uInt16 nPageId) const
1775{
1776 sal_uInt16 nPos = GetPagePos(nPageId);
1777
1778 if (nPos != PAGE_NOT_FOUND)
1779 return mpImpl->maItemList[nPos].mnBits;
1780 else
1781 return TabBarPageBits::NONE;
1782}
1783
1784sal_uInt16 TabBar::GetPageCount() const
1785{
1786 return mpImpl->getItemSize();
1787}
1788
1789sal_uInt16 TabBar::GetPageId(sal_uInt16 nPos) const
1790{
1791 return nPos < mpImpl->maItemList.size() ? mpImpl->maItemList[nPos].mnId : 0;
1792}
1793
1794sal_uInt16 TabBar::GetPagePos(sal_uInt16 nPageId) const
1795{
1796 for (size_t i = 0; i < mpImpl->maItemList.size(); ++i)
1797 {
1798 if (mpImpl->maItemList[i].mnId == nPageId)
1799 {
1800 return static_cast<sal_uInt16>(i);
1801 }
1802 }
1803 return PAGE_NOT_FOUND;
1804}
1805
1806sal_uInt16 TabBar::GetPageId(const Point& rPos) const
1807{
1808 for (const auto& rItem : mpImpl->maItemList)
1809 {
1810 if (rItem.maRect.Contains(rPos))
1811 return rItem.mnId;
1812 }
1813
1814 return 0;
1815}
1816
1817tools::Rectangle TabBar::GetPageRect(sal_uInt16 nPageId) const
1818{
1819 sal_uInt16 nPos = GetPagePos(nPageId);
1820
1821 if (nPos != PAGE_NOT_FOUND)
1822 return mpImpl->maItemList[nPos].maRect;
1823 else
1824 return tools::Rectangle();
1825}
1826
1827void TabBar::SetCurPageId(sal_uInt16 nPageId)
1828{
1829 sal_uInt16 nPos = GetPagePos(nPageId);
1830
1831 // do nothing if item does not exit
1832 if (nPos == PAGE_NOT_FOUND)
1833 return;
1834
1835 // do nothing if the actual page did not change
1836 if (nPageId == mnCurPageId)
1837 return;
1838
1839 // make invalid
1840 bool bUpdate = false;
1841 if (IsReallyVisible() && IsUpdateMode())
1842 bUpdate = true;
1843
1844 auto& rItem = mpImpl->maItemList[nPos];
1845 ImplTabBarItem* pOldItem;
1846
1847 if (mnCurPageId)
1848 pOldItem = &mpImpl->maItemList[GetPagePos(mnCurPageId)];
1849 else
1850 pOldItem = nullptr;
1851
1852 // deselect previous page if page was not selected, if this is the
1853 // only selected page
1854 if (!rItem.mbSelect && pOldItem)
1855 {
1856 sal_uInt16 nSelPageCount = GetSelectPageCount();
1857 if (nSelPageCount == 1)
1858 pOldItem->mbSelect = false;
1859 rItem.mbSelect = true;
1860 }
1861
1863 mbFormat = true;
1864
1865 // assure the actual page becomes visible
1866 if (IsReallyVisible())
1867 {
1868 if (nPos < mnFirstPos)
1870 else
1871 {
1872 // calculate visible width
1873 tools::Long nWidth = mnLastOffX;
1874 if (nWidth > ADDNEWPAGE_AREAWIDTH)
1875 nWidth -= ADDNEWPAGE_AREAWIDTH;
1876
1877 if (rItem.maRect.IsEmpty())
1878 ImplFormat();
1879
1880 while ((mbMirrored ? (rItem.maRect.Left() < mnOffX) : (rItem.maRect.Right() > nWidth)) ||
1881 rItem.maRect.IsEmpty())
1882 {
1883 sal_uInt16 nNewPos = mnFirstPos + 1;
1884 // assure at least the actual tabpages are visible as first tabpage
1885 if (nNewPos >= nPos)
1886 {
1888 break;
1889 }
1890 else
1891 SetFirstPageId(GetPageId(nNewPos));
1892 ImplFormat();
1893 // abort if first page is not forwarded
1894 if (nNewPos != mnFirstPos)
1895 break;
1896 }
1897 }
1898 }
1899
1900 // redraw bar
1901 if (bUpdate)
1902 {
1903 Invalidate(rItem.maRect);
1904 if (pOldItem)
1905 Invalidate(pOldItem->maRect);
1906 }
1907}
1908
1909void TabBar::MakeVisible(sal_uInt16 nPageId)
1910{
1911 if (!IsReallyVisible())
1912 return;
1913
1914 sal_uInt16 nPos = GetPagePos(nPageId);
1915
1916 // do nothing if item does not exist
1917 if (nPos == PAGE_NOT_FOUND)
1918 return;
1919
1920 if (nPos < mnFirstPos)
1922 else
1923 {
1924 auto& rItem = mpImpl->maItemList[nPos];
1925
1926 // calculate visible area
1927 tools::Long nWidth = mnLastOffX;
1928
1929 if (mbFormat || rItem.maRect.IsEmpty())
1930 {
1931 mbFormat = true;
1932 ImplFormat();
1933 }
1934
1935 while ((rItem.maRect.Right() > nWidth) ||
1936 rItem.maRect.IsEmpty())
1937 {
1938 sal_uInt16 nNewPos = mnFirstPos+1;
1939 // assure at least the actual tabpages are visible as first tabpage
1940 if (nNewPos >= nPos)
1941 {
1943 break;
1944 }
1945 else
1946 SetFirstPageId(GetPageId(nNewPos));
1947 ImplFormat();
1948 // abort if first page is not forwarded
1949 if (nNewPos != mnFirstPos)
1950 break;
1951 }
1952 }
1953}
1954
1955void TabBar::SetFirstPageId(sal_uInt16 nPageId)
1956{
1957 sal_uInt16 nPos = GetPagePos(nPageId);
1958
1959 // return false if item does not exist
1960 if (nPos == PAGE_NOT_FOUND)
1961 return;
1962
1963 if (nPos == mnFirstPos)
1964 return;
1965
1966 // assure as much pages are visible as possible
1967 ImplFormat();
1968 sal_uInt16 nLastFirstPos = ImplGetLastFirstPos();
1969 sal_uInt16 nNewPos;
1970 if (nPos > nLastFirstPos)
1971 nNewPos = nLastFirstPos;
1972 else
1973 nNewPos = nPos;
1974
1975 if (nNewPos != mnFirstPos)
1976 {
1977 mnFirstPos = nNewPos;
1978 mbFormat = true;
1979
1980 // redraw bar (attention: check mbDropPos,
1981 // as if this flag was set, we do not re-paint immediately
1982 if (IsReallyVisible() && IsUpdateMode() && !mbDropPos)
1983 Invalidate();
1984 }
1985}
1986
1987void TabBar::SelectPage(sal_uInt16 nPageId, bool bSelect)
1988{
1989 sal_uInt16 nPos = GetPagePos(nPageId);
1990
1991 if (nPos == PAGE_NOT_FOUND)
1992 return;
1993
1994 auto& rItem = mpImpl->maItemList[nPos];
1995
1996 if (rItem.mbSelect != bSelect)
1997 {
1998 rItem.mbSelect = bSelect;
1999
2000 // redraw bar
2001 if (IsReallyVisible() && IsUpdateMode())
2002 Invalidate(rItem.maRect);
2003 }
2004}
2005
2007{
2008 sal_uInt16 nSelected = 0;
2009 for (const auto& rItem : mpImpl->maItemList)
2010 {
2011 if (rItem.mbSelect)
2012 nSelected++;
2013 }
2014
2015 return nSelected;
2016}
2017
2018bool TabBar::IsPageSelected(sal_uInt16 nPageId) const
2019{
2020 sal_uInt16 nPos = GetPagePos(nPageId);
2021 if (nPos != PAGE_NOT_FOUND)
2022 return mpImpl->maItemList[nPos].mbSelect;
2023 else
2024 return false;
2025}
2026
2027void TabBar::SetProtectionSymbol(sal_uInt16 nPageId, bool bProtection)
2028{
2029 sal_uInt16 nPos = GetPagePos(nPageId);
2030 if (nPos != PAGE_NOT_FOUND)
2031 {
2032 if (mpImpl->maItemList[nPos].mbProtect != bProtection)
2033 {
2034 mpImpl->maItemList[nPos].mbProtect = bProtection;
2035 mbSizeFormat = true; // render text width changes, thus bar width
2036
2037 // redraw bar
2038 if (IsReallyVisible() && IsUpdateMode())
2039 Invalidate();
2040 }
2041 }
2042}
2043
2044bool TabBar::StartEditMode(sal_uInt16 nPageId)
2045{
2046 sal_uInt16 nPos = GetPagePos( nPageId );
2047 if (mpImpl->mxEdit || (nPos == PAGE_NOT_FOUND) || (mnLastOffX < 8))
2048 return false;
2049
2050 mnEditId = nPageId;
2051 if (StartRenaming())
2052 {
2054 ImplFormat();
2056
2057 mpImpl->mxEdit.disposeAndReset(VclPtr<TabBarEdit>::Create(this));
2059 tools::Long nX = aRect.Left();
2060 tools::Long nWidth = aRect.GetWidth();
2061 if (mnEditId != GetCurPageId())
2062 nX += 1;
2063 if (nX + nWidth > mnLastOffX)
2064 nWidth = mnLastOffX-nX;
2065 if (nWidth < 3)
2066 {
2067 nX = aRect.Left();
2068 nWidth = aRect.GetWidth();
2069 }
2070 weld::Entry& rEntry = mpImpl->mxEdit->get_widget();
2071 rEntry.set_text(GetPageText(mnEditId));
2072 mpImpl->mxEdit->SetPosSizePixel(Point(nX, aRect.Top() + mnOffY + 1), Size(nWidth, aRect.GetHeight() - 3));
2073 vcl::Font aFont = GetPointFont(*GetOutDev()); // FIXME RenderContext
2074
2075 Color aForegroundColor;
2076 Color aBackgroundColor;
2077 Color aFaceColor;
2078 Color aSelectColor;
2079 Color aFaceTextColor;
2080 Color aSelectTextColor;
2081
2082 ImplGetColors(Application::GetSettings().GetStyleSettings(), aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
2083
2084 if (mnEditId != GetCurPageId())
2085 {
2086 aFont.SetWeight(WEIGHT_LIGHT);
2087 }
2089 {
2090 aForegroundColor = aSelectTextColor;
2091 aBackgroundColor = aSelectColor;
2092 }
2093 else
2094 {
2095 aForegroundColor = aFaceTextColor;
2096 aBackgroundColor = aFaceColor;
2097 }
2099 {
2100 aForegroundColor = COL_LIGHTBLUE;
2101 }
2102 rEntry.set_font(aFont);
2103 rEntry.set_font_color(aForegroundColor);
2104 mpImpl->mxEdit->SetControlBackground(aBackgroundColor);
2105 rEntry.grab_focus();
2106 rEntry.select_region(0, -1);
2107 mpImpl->mxEdit->Show();
2108 return true;
2109 }
2110 else
2111 {
2112 mnEditId = 0;
2113 return false;
2114 }
2115}
2116
2118{
2119 return bool(mpImpl->mxEdit);
2120}
2121
2122void TabBar::EndEditMode(bool bCancel)
2123{
2124 if (!mpImpl->mxEdit)
2125 return;
2126
2127 // call hdl
2128 bool bEnd = true;
2129 mbEditCanceled = bCancel;
2130 weld::Entry& rEntry = mpImpl->mxEdit->get_widget();
2131 maEditText = rEntry.get_text();
2132 mpImpl->mxEdit->SetPostEvent();
2133 if (!bCancel)
2134 {
2136 if (nAllowRenaming == TABBAR_RENAMING_YES)
2138 else if (nAllowRenaming == TABBAR_RENAMING_NO)
2139 bEnd = false;
2140 else // nAllowRenaming == TABBAR_RENAMING_CANCEL
2141 mbEditCanceled = true;
2142 }
2143
2144 // renaming not allowed, then reset edit data
2145 if (!bEnd)
2146 {
2147 mpImpl->mxEdit->ResetPostEvent();
2148 rEntry.grab_focus();
2149 }
2150 else
2151 {
2152 // close edit and call end hdl
2153 mpImpl->mxEdit.disposeAndClear();
2154
2155 EndRenaming();
2156 mnEditId = 0;
2157 }
2158
2159 // reset
2160 maEditText.clear();
2161 mbEditCanceled = false;
2162}
2163
2164void TabBar::SetMirrored(bool bMirrored)
2165{
2166 if (mbMirrored != bMirrored)
2167 {
2168 mbMirrored = bMirrored;
2169 mbSizeFormat = true;
2170 ImplInitControls(); // for button images
2171 Resize(); // recalculates control positions
2172 Mirror();
2173 }
2174}
2175
2177{
2179}
2180
2182{
2184}
2185
2187{
2188 if (mnMaxPageWidth != nMaxWidth)
2189 {
2190 mnMaxPageWidth = nMaxWidth;
2191 mbSizeFormat = true;
2192
2193 // redraw bar
2194 if (IsReallyVisible() && IsUpdateMode())
2195 Invalidate();
2196 }
2197}
2198
2199void TabBar::SetPageText(sal_uInt16 nPageId, const OUString& rText)
2200{
2201 sal_uInt16 nPos = GetPagePos(nPageId);
2202 if (nPos != PAGE_NOT_FOUND)
2203 {
2204 mpImpl->maItemList[nPos].maText = rText;
2205 mbSizeFormat = true;
2206
2207 // redraw bar
2208 if (IsReallyVisible() && IsUpdateMode())
2209 Invalidate();
2210
2211 CallEventListeners(VclEventId::TabbarPageTextChanged, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId)));
2212 }
2213}
2214
2215OUString TabBar::GetPageText(sal_uInt16 nPageId) const
2216{
2217 sal_uInt16 nPos = GetPagePos(nPageId);
2218 if (nPos != PAGE_NOT_FOUND)
2219 return mpImpl->maItemList[nPos].maText;
2220 return OUString();
2221}
2222
2223OUString TabBar::GetAuxiliaryText(sal_uInt16 nPageId) const
2224{
2225 sal_uInt16 nPos = GetPagePos(nPageId);
2226 if (nPos != PAGE_NOT_FOUND)
2227 return mpImpl->maItemList[nPos].maAuxiliaryText;
2228 return OUString();
2229}
2230
2231void TabBar::SetAuxiliaryText(sal_uInt16 nPageId, const OUString& rText )
2232{
2233 sal_uInt16 nPos = GetPagePos(nPageId);
2234 if (nPos != PAGE_NOT_FOUND)
2235 {
2236 mpImpl->maItemList[nPos].maAuxiliaryText = rText;
2237 // no redraw bar, no CallEventListener, internal use in LayerTabBar
2238 }
2239}
2240
2241OUString TabBar::GetHelpText(sal_uInt16 nPageId) const
2242{
2243 sal_uInt16 nPos = GetPagePos(nPageId);
2244 if (nPos != PAGE_NOT_FOUND)
2245 {
2246 auto& rItem = mpImpl->maItemList[nPos];
2247 if (rItem.maHelpText.isEmpty() && !rItem.maHelpId.isEmpty())
2248 {
2249 Help* pHelp = Application::GetHelp();
2250 if (pHelp)
2251 rItem.maHelpText = pHelp->GetHelpText(OStringToOUString(rItem.maHelpId, RTL_TEXTENCODING_UTF8), this);
2252 }
2253
2254 return rItem.maHelpText;
2255 }
2256 return OUString();
2257}
2258
2259bool TabBar::StartDrag(const CommandEvent& rCEvt, vcl::Region& rRegion)
2260{
2261 if (!(mnWinStyle & WB_DRAG) || (rCEvt.GetCommand() != CommandEventId::StartDrag))
2262 return false;
2263
2264 // Check if the clicked page was selected. If this is not the case
2265 // set it as actual entry. We check for this only at a mouse action
2266 // if Drag and Drop can be triggered from the keyboard.
2267 // We only do this, if Select() was not triggered, as the Select()
2268 // could have scrolled the area
2269 if (rCEvt.IsMouseEvent() && !mbInSelect)
2270 {
2271 sal_uInt16 nSelId = GetPageId(rCEvt.GetMousePosPixel());
2272
2273 // do not start dragging if no entry was clicked
2274 if (!nSelId)
2275 return false;
2276
2277 // check if page was selected. If not set it as actual
2278 // page and call Select()
2279 if (!IsPageSelected(nSelId))
2280 {
2281 if (ImplDeactivatePage())
2282 {
2283 SetCurPageId(nSelId);
2286 ImplSelect();
2287 }
2288 else
2289 return false;
2290 }
2291 }
2292 mbInSelect = false;
2293
2294 vcl::Region aRegion;
2295
2296 // assign region
2297 rRegion = aRegion;
2298
2299 return true;
2300}
2301
2302sal_uInt16 TabBar::ShowDropPos(const Point& rPos)
2303{
2304 sal_uInt16 nNewDropPos;
2305 sal_uInt16 nItemCount = mpImpl->getItemSize();
2306 sal_Int16 nScroll = 0;
2307
2308 if (rPos.X() > mnLastOffX-TABBAR_DRAG_SCROLLOFF)
2309 {
2310 auto& rItem = mpImpl->maItemList[mpImpl->maItemList.size() - 1];
2311 if (!rItem.maRect.IsEmpty() && (rPos.X() > rItem.maRect.Right()))
2312 nNewDropPos = mpImpl->getItemSize();
2313 else
2314 {
2315 nNewDropPos = mnFirstPos + 1;
2316 nScroll = 1;
2317 }
2318 }
2319 else if ((rPos.X() <= mnOffX) ||
2320 (!mnOffX && (rPos.X() <= TABBAR_DRAG_SCROLLOFF)))
2321 {
2322 if (mnFirstPos)
2323 {
2324 nNewDropPos = mnFirstPos;
2325 nScroll = -1;
2326 }
2327 else
2328 nNewDropPos = 0;
2329 }
2330 else
2331 {
2332 sal_uInt16 nDropId = GetPageId(rPos);
2333 if (nDropId)
2334 {
2335 nNewDropPos = GetPagePos(nDropId);
2336 if (mnFirstPos && (nNewDropPos == mnFirstPos - 1))
2337 nScroll = -1;
2338 }
2339 else
2340 nNewDropPos = nItemCount;
2341 }
2342
2343 if (mbDropPos && (nNewDropPos == mnDropPos) && !nScroll)
2344 return mnDropPos;
2345
2346 if (mbDropPos)
2347 HideDropPos();
2348 mbDropPos = true;
2349 mnDropPos = nNewDropPos;
2350
2351 if (nScroll)
2352 {
2353 sal_uInt16 nOldFirstPos = mnFirstPos;
2355
2356 // draw immediately, as Paint not possible during Drag and Drop
2357 if (nOldFirstPos != mnFirstPos)
2358 {
2360 GetOutDev()->SetFillColor(GetBackground().GetColor());
2361 GetOutDev()->DrawRect(aRect);
2362 Invalidate(aRect);
2363 }
2364 }
2365
2366 // draw drop position arrows
2368 const Color aTextColor = rStyles.GetLabelTextColor();
2369 tools::Long nX;
2370 tools::Long nY = (maWinSize.Height() / 2) - 1;
2371 sal_uInt16 nCurPos = GetPagePos(mnCurPageId);
2372
2373 sal_Int32 nTriangleWidth = 3 * GetDPIScaleFactor();
2374
2375 if (mnDropPos < nItemCount)
2376 {
2377 GetOutDev()->SetLineColor(aTextColor);
2378 GetOutDev()->SetFillColor(aTextColor);
2379
2380 auto& rItem = mpImpl->maItemList[mnDropPos];
2381 nX = rItem.maRect.Left();
2382 if ( mnDropPos == nCurPos )
2383 nX--;
2384 else
2385 nX++;
2386
2387 if (!rItem.IsDefaultTabBgColor() && !rItem.mbSelect)
2388 {
2389 GetOutDev()->SetLineColor(rItem.maTabTextColor);
2390 GetOutDev()->SetFillColor(rItem.maTabTextColor);
2391 }
2392
2393 tools::Polygon aPoly(3);
2394 aPoly.SetPoint(Point(nX, nY), 0);
2395 aPoly.SetPoint(Point(nX + nTriangleWidth, nY - nTriangleWidth), 1);
2396 aPoly.SetPoint(Point(nX + nTriangleWidth, nY + nTriangleWidth), 2);
2397 GetOutDev()->DrawPolygon(aPoly);
2398 }
2399 if (mnDropPos > 0 && mnDropPos < nItemCount + 1)
2400 {
2401 GetOutDev()->SetLineColor(aTextColor);
2402 GetOutDev()->SetFillColor(aTextColor);
2403
2404 auto& rItem = mpImpl->maItemList[mnDropPos - 1];
2405 nX = rItem.maRect.Right();
2406 if (mnDropPos == nCurPos)
2407 nX++;
2408 if (!rItem.IsDefaultTabBgColor() && !rItem.mbSelect)
2409 {
2410 GetOutDev()->SetLineColor(rItem.maTabTextColor);
2411 GetOutDev()->SetFillColor(rItem.maTabTextColor);
2412 }
2413 tools::Polygon aPoly(3);
2414 aPoly.SetPoint(Point(nX, nY), 0);
2415 aPoly.SetPoint(Point(nX - nTriangleWidth, nY - nTriangleWidth), 1);
2416 aPoly.SetPoint(Point(nX - nTriangleWidth, nY + nTriangleWidth), 2);
2417 GetOutDev()->DrawPolygon(aPoly);
2418 }
2419
2420 return mnDropPos;
2421}
2422
2424{
2425 if (!mbDropPos)
2426 return;
2427
2428 tools::Long nX;
2429 tools::Long nY1 = (maWinSize.Height() / 2) - 3;
2430 tools::Long nY2 = nY1 + 5;
2431 sal_uInt16 nItemCount = mpImpl->getItemSize();
2432
2433 if (mnDropPos < nItemCount)
2434 {
2435 auto& rItem = mpImpl->maItemList[mnDropPos];
2436 nX = rItem.maRect.Left();
2437 // immediately call Paint, as it is not possible during drag and drop
2438 tools::Rectangle aRect( nX-1, nY1, nX+3, nY2 );
2439 vcl::Region aRegion( aRect );
2440 GetOutDev()->SetClipRegion( aRegion );
2441 Invalidate(aRect);
2443 }
2444 if (mnDropPos > 0 && mnDropPos < nItemCount + 1)
2445 {
2446 auto& rItem = mpImpl->maItemList[mnDropPos - 1];
2447 nX = rItem.maRect.Right();
2448 // immediately call Paint, as it is not possible during drag and drop
2449 tools::Rectangle aRect(nX - 2, nY1, nX + 1, nY2);
2450 vcl::Region aRegion(aRect);
2451 GetOutDev()->SetClipRegion(aRegion);
2452 Invalidate(aRect);
2454 }
2455
2456 mbDropPos = false;
2457 mnDropPos = 0;
2458}
2459
2460void TabBar::SwitchPage(const Point& rPos)
2461{
2462 sal_uInt16 nSwitchId = GetPageId(rPos);
2463 if (!nSwitchId)
2464 EndSwitchPage();
2465 else
2466 {
2467 if (nSwitchId != mnSwitchId)
2468 {
2469 mnSwitchId = nSwitchId;
2471 }
2472 else
2473 {
2474 // change only after 500 ms
2475 if (mnSwitchId != GetCurPageId())
2476 {
2478 {
2479 if (ImplDeactivatePage())
2480 {
2484 ImplSelect();
2485 }
2486 }
2487 }
2488 }
2489 }
2490}
2491
2493{
2494 mnSwitchTime = 0;
2495 mnSwitchId = 0;
2496}
2497
2499{
2500 if (mnWinStyle == nStyle)
2501 return;
2502 mnWinStyle = nStyle;
2504 // order possible controls
2505 if (IsReallyVisible() && IsUpdateMode())
2506 Resize();
2507}
2508
2510{
2511 tools::Long nWidth = 0;
2512
2513 if (!mpImpl->maItemList.empty())
2514 {
2515 const_cast<TabBar*>(this)->ImplCalcWidth();
2516 for (const auto& rItem : mpImpl->maItemList)
2517 {
2518 nWidth += rItem.mnWidth;
2519 }
2520 }
2521
2522 return Size(nWidth, GetSettings().GetStyleSettings().GetScrollBarSize());
2523}
2524
2526{
2529}
2530
2531void TabBar::SetAddButtonEnabled(bool bAddButtonEnabled)
2532{
2533 mpImpl->mxButtonBox->m_xAddButton->set_sensitive(bAddButtonEnabled);
2534}
2535
2536css::uno::Reference<css::accessibility::XAccessible> TabBar::CreateAccessible()
2537{
2538 return mpImpl->maAccessibleFactory.getFactory().createAccessibleTabBar(*this);
2539}
2540
2541/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nPageId
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
static const AllSettings & GetSettings()
static Help * GetHelp()
sal_uInt8 GetLuminance() const
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
void DrawHandle(const tools::Rectangle &rRectangle)
HelpEventMode GetMode() const
const Point & GetMousePosPixel() const
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
tools::Long mnStartWidth
Definition: tabbar.cxx:260
void ImplTrack(const Point &rScreenPos)
Definition: tabbar.cxx:271
ImplTabSizer(TabBar *pParent, WinBits nWinStyle)
Definition: tabbar.cxx:263
virtual void Paint(vcl::RenderContext &, const tools::Rectangle &rRect) override
Definition: tabbar.cxx:310
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: tabbar.cxx:282
TabBar * GetParent() const
Definition: tabbar.cxx:250
Point maStartPos
Definition: tabbar.cxx:259
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: tabbar.cxx:298
virtual void dispose() override
void InvalidateChildSizeCache()
MouseEventModifiers GetMode() const
bool IsMod2() const
bool IsLeaveWindow() const
sal_uInt16 GetModifier() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
bool IsLeft() const
const CommandEvent * GetCommandEvent() const
NotifyEventType GetType() const
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
const vcl::Font & GetFont() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetLineColor()
OUString GetEllipsisString(const OUString &rStr, tools::Long nMaxWidth, DrawTextFlags nStyle=DrawTextFlags::EndEllipsis) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void DrawPolygon(const tools::Polygon &rPoly)
void SetTextColor(const Color &rColor)
void SetClipRegion()
void SetFillColor()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const AllSettings & GetSettings() const
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetDarkShadowColor() const
bool GetHighContrastMode() const
const Color & GetShadowColor() const
const Color & GetLabelTextColor() const
const Color & GetWindowTextColor() const
const vcl::Font & GetToolFont() const
const Color & GetActiveTabColor() const
const Color & GetInactiveTabColor() const
const Color & GetFaceColor() const
const Color & GetButtonTextColor() const
TabBar(vcl::Window *pParent, WinBits nWinStyle, bool bSheets=false)
Definition: tabbar.cxx:516
SVT_DLLPRIVATE void ImplFormat()
Definition: tabbar.cxx:700
virtual void Resize() override
Definition: tabbar.cxx:1269
void SetTabBgColor(sal_uInt16 nPageId, const Color &aTabBgColor)
Definition: tabbar.cxx:1641
bool mbFormat
Definition: tabbar.hxx:334
bool IsInEditMode() const
Definition: tabbar.cxx:2117
tools::Long mnLastOffX
Definition: tabbar.hxx:324
bool IsPageSelected(sal_uInt16 nPageId) const
Definition: tabbar.cxx:2018
SVT_DLLPRIVATE void ImplPrePaint()
Definition: tabbar.cxx:1513
void SetCurPageId(sal_uInt16 nPageId)
Definition: tabbar.cxx:1827
virtual void ActivatePage()
Definition: tabbar.cxx:1501
sal_uInt16 ShowDropPos(const Point &rPos)
Definition: tabbar.cxx:2302
static const sal_uInt16 PAGE_NOT_FOUND
Definition: tabbar.hxx:384
void SetPageBits(sal_uInt16 nPageId, TabBarPageBits nBits)
Definition: tabbar.cxx:1755
Size CalcWindowSizePixel() const
Definition: tabbar.cxx:2509
bool mbMirrored
Definition: tabbar.hxx:341
bool mbDropPos
Definition: tabbar.hxx:339
tools::Long mnOffX
Definition: tabbar.hxx:322
OUString maEditText
Definition: tabbar.hxx:318
tools::Long mnOffY
Definition: tabbar.hxx:323
void SelectPage(sal_uInt16 nPageId, bool bSelect)
Definition: tabbar.cxx:1987
bool IsEffectiveRTL() const
Returns true, if the control draws from right to left (see SetEffectiveRTL()).
Definition: tabbar.cxx:2181
std::unique_ptr< TabBar_Impl > mpImpl
Definition: tabbar.hxx:316
sal_uInt16 mnFirstPos
Definition: tabbar.hxx:329
virtual void Mirror()
Definition: tabbar.cxx:1589
tools::Rectangle GetPageArea() const
Definition: tabbar.cxx:2525
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: tabbar.cxx:1137
sal_uInt16 mnCurPageId
Definition: tabbar.hxx:328
bool IsMirrored() const
Returns true, if the control is set to mirrored mode (see SetMirrored()).
Definition: tabbar.hxx:464
void SetAuxiliaryText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabbar.cxx:2231
SVT_DLLPRIVATE void ImplGetColors(const StyleSettings &rStyleSettings, Color &rFaceColor, Color &rFaceTextColor, Color &rSelectColor, Color &rSelectTextColor)
Definition: tabbar.cxx:629
SVT_DLLPRIVATE void ImplShowPage(sal_uInt16 nPos)
Definition: tabbar.cxx:861
Size maWinSize
Definition: tabbar.hxx:319
SVT_DLLPRIVATE void ImplInitControls()
Definition: tabbar.cxx:783
bool mbInSelect
Definition: tabbar.hxx:340
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: tabbar.cxx:949
virtual void Select()
Definition: tabbar.cxx:1480
void EndEditMode(bool bCancel=false)
Definition: tabbar.cxx:2122
void HideDropPos()
Definition: tabbar.cxx:2423
void Split()
Definition: tabbar.cxx:1489
void SetAddButtonEnabled(bool bAddButtonEnabled)
Definition: tabbar.cxx:2531
sal_uInt16 mnSwitchId
Definition: tabbar.hxx:331
SVT_DLLPRIVATE ImplTabBarItem * ImplGetLastTabBarItem(sal_uInt16 nItemCount)
Definition: tabbar.cxx:1543
void SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled)
Definition: tabbar.cxx:855
void SetEffectiveRTL(bool bRTL)
Sets the control to LTR or RTL mode regardless of the GUI direction.
Definition: tabbar.cxx:2176
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: tabbar.cxx:1143
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: tabbar.cxx:2536
void MovePage(sal_uInt16 nPageId, sal_uInt16 nNewPos)
Definition: tabbar.cxx:1690
virtual bool DeactivatePage()
Definition: tabbar.cxx:1570
SVT_DLLPRIVATE bool ImplCalcWidth()
Definition: tabbar.cxx:645
sal_uInt16 GetPagePos(sal_uInt16 nPageId) const
Definition: tabbar.cxx:1794
virtual void StateChanged(StateChangedType nStateChange) override
Definition: tabbar.cxx:1416
bool StartEditMode(sal_uInt16 nPageId)
Definition: tabbar.cxx:2044
sal_uInt16 mnDropPos
Definition: tabbar.hxx:330
virtual TabBarAllowRenamingReturnCode AllowRenaming()
Definition: tabbar.cxx:1580
bool mbEditCanceled
Definition: tabbar.hxx:338
OUString GetAuxiliaryText(sal_uInt16 nPageId) const
Definition: tabbar.cxx:2223
void SetStyle(WinBits nStyle)
Definition: tabbar.cxx:2498
void SetMirrored(bool bMirrored)
Mirrors the entire control including position of buttons and splitter.
Definition: tabbar.cxx:2164
void Clear()
Definition: tabbar.cxx:1728
void EndSwitchPage()
Definition: tabbar.cxx:2492
sal_uInt16 mnEditId
Definition: tabbar.hxx:332
virtual void SetPageText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabbar.cxx:2199
bool mbScrollAlwaysEnabled
Definition: tabbar.hxx:342
sal_uInt64 mnSwitchTime
Definition: tabbar.hxx:326
tools::Rectangle GetPageRect(sal_uInt16 nPageId) const
Definition: tabbar.cxx:1817
tools::Long mnSplitSize
Definition: tabbar.hxx:325
ImplTabBarItem * next()
Definition: tabbar.cxx:591
SVT_DLLPRIVATE void ImplEnableControls()
Definition: tabbar.cxx:837
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: tabbar.cxx:1337
sal_uInt16 GetSelectPageCount() const
Definition: tabbar.cxx:2006
void MakeVisible(sal_uInt16 nPageId)
Definition: tabbar.cxx:1909
tools::Long mnCurMaxWidth
Definition: tabbar.hxx:321
bool IsPageEnabled(sal_uInt16 nPageId) const
Definition: tabbar.cxx:1746
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: tabbar.cxx:1363
Link< TabBar *, void > maSelectHdl
Definition: tabbar.hxx:345
void RemovePage(sal_uInt16 nPageId)
Definition: tabbar.cxx:1663
SVT_DLLPRIVATE bool ImplDeactivatePage()
Definition: tabbar.cxx:1504
void SetMaxPageWidth(tools::Long nMaxWidth)
Definition: tabbar.cxx:2186
bool mbSheets
Definition: tabbar.hxx:343
SVT_DLLPRIVATE sal_uInt16 ImplGetLastFirstPos()
Definition: tabbar.cxx:751
OUString GetPageText(sal_uInt16 nPageId) const
Definition: tabbar.cxx:2215
sal_uInt16 GetPageCount() const
Definition: tabbar.cxx:1784
virtual void DoubleClick()
Definition: tabbar.cxx:1485
virtual void InsertPage(sal_uInt16 nPageId, const OUString &rText, TabBarPageBits nBits=TabBarPageBits::NONE, sal_uInt16 nPos=TabBar::APPEND)
Definition: tabbar.cxx:1599
bool StartDrag(const CommandEvent &rCEvt, vcl::Region &rRegion)
Definition: tabbar.cxx:2259
ImplTabBarItem * prev()
Definition: tabbar.cxx:582
sal_uInt16 GetPageId(sal_uInt16 nPos) const
Definition: tabbar.cxx:1789
virtual void EndRenaming()
Definition: tabbar.cxx:1585
bool mbAutoEditMode
Definition: tabbar.hxx:337
TabBarPageBits GetPageBits(sal_uInt16 nPageId) const
Definition: tabbar.cxx:1774
bool mbFirstFormat
Definition: tabbar.hxx:335
virtual ~TabBar() override
Definition: tabbar.cxx:523
SVT_DLLPRIVATE void ImplInitSettings(bool bFont, bool bBackground)
Definition: tabbar.cxx:600
size_t maCurrentItemList
Definition: tabbar.hxx:348
void SwitchPage(const Point &rPos)
Definition: tabbar.cxx:2460
WinBits mnWinStyle
Definition: tabbar.hxx:327
virtual bool StartRenaming()
Definition: tabbar.cxx:1575
void SetFirstPageId(sal_uInt16 nPageId)
Definition: tabbar.cxx:1955
SVT_DLLPRIVATE void ImplActivatePage()
Definition: tabbar.cxx:1494
sal_uInt16 GetCurPageId() const
Definition: tabbar.hxx:436
static const sal_uInt16 APPEND
Definition: tabbar.hxx:383
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: tabbar.cxx:1460
void SetProtectionSymbol(sal_uInt16 nPageId, bool bProtection)
Definition: tabbar.cxx:2027
Color GetTabBgColor(sal_uInt16 nPageId) const
Definition: tabbar.cxx:1631
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: tabbar.cxx:957
SVT_DLLPRIVATE void ImplSelect()
Definition: tabbar.cxx:1474
virtual void AddTabClick()
Definition: tabbar.cxx:1594
virtual void dispose() override
Definition: tabbar.cxx:528
Link< TabBar *, void > maSplitHdl
Definition: tabbar.hxx:346
tools::Long mnMaxPageWidth
Definition: tabbar.hxx:320
SVT_DLLPRIVATE void ImplInit(WinBits nWinStyle, bool bSheets)
Definition: tabbar.cxx:538
ImplTabBarItem * seek(size_t i)
Definition: tabbar.cxx:572
bool mbSizeFormat
Definition: tabbar.hxx:336
bool IsTrackingEnded() const
bool IsTrackingCanceled() const
const MouseEvent & GetMouseEvent() const
bool isDisposed() const
void SetPoint(const Point &rPt, sal_uInt16 nPos)
constexpr Point Center() const
constexpr tools::Long GetWidth() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
tools::Long getOpenHeight() const
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
static sal_uInt64 GetSystemTicks()
tools::Long GetFontHeight() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
void SetFontHeight(tools::Long nHeight)
void SetUnderline(FontLineStyle)
FontWeight GetWeight()
Point OutputToScreenPixel(const Point &rPos) const
const Wallpaper & GetBackground() const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetFont(const vcl::Font &rNewFont)
float GetDPIScaleFactor() const
bool IsReallyVisible() const
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
vcl::Window * GetParent() const
void PaintImmediately()
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
virtual void SetSizePixel(const Size &rNewSize)
const Color & GetControlForeground() const
bool IsUpdateMode() const
tools::Long GetTextHeight() const
bool IsControlForeground() const
const AllSettings & GetSettings() const
vcl::Font GetPointFont(vcl::RenderContext const &rRenderContext) const
::OutputDevice const * GetOutDev() const
const vcl::Font & GetFont() const
bool IsRTLEnabled() const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
bool IsControlBackground() const
const Color & GetControlBackground() const
virtual void SetPointer(PointerStyle)
void SetPaintTransparent(bool bTransparent)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Point ScreenToOutputPixel(const Point &rPos) const
const OUString & GetHelpText() const
void SetBackground()
virtual void set_font(const vcl::Font &rFont)=0
virtual void select_region(int nStartPos, int nEndPos)=0
virtual void set_text(const OUString &rText)=0
virtual void set_font_color(const Color &rColor)=0
virtual OUString get_text() const=0
virtual void grab_focus()=0
virtual void set_direction(bool bRTL)=0
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_LIGHTBLUE(0x00, 0x00, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
int nCount
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
float x
#define MOUSE_LEFT
#define MOUSE_MIDDLE
#define MOUSE_RIGHT
LINESTYLE_SINGLE
WEIGHT_BOLD
WEIGHT_NORMAL
WEIGHT_LIGHT
sal_Int64 n
constexpr sal_uInt16 KEY_ESCAPE
sal_uInt16 nPos
aStr
std::unique_ptr< sal_Int32[]> pData
int i
bool IsMirrored(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
long Long
QPRO_FUNC_TYPE nType
sal_uInt16 mnId
Definition: tabbar.cxx:202
OUString maAuxiliaryText
Definition: tabbar.cxx:206
tools::Long mnWidth
Definition: tabbar.cxx:208
bool IsSelected(ImplTabBarItem const *pCurItem) const
Definition: tabbar.cxx:234
bool mbProtect
Definition: tabbar.cxx:212
TabBarPageBits mnBits
Definition: tabbar.cxx:203
Color maTabBgColor
Definition: tabbar.cxx:213
OUString const & GetRenderText() const
Definition: tabbar.cxx:239
ImplTabBarItem(sal_uInt16 nItemId, OUString aText, TabBarPageBits nPageBits)
Definition: tabbar.cxx:216
bool IsDefaultTabBgColor() const
Definition: tabbar.cxx:229
tools::Rectangle maRect
Definition: tabbar.cxx:207
OString maHelpId
Definition: tabbar.cxx:209
OUString maText
Definition: tabbar.cxx:204
Color maTabTextColor
Definition: tabbar.cxx:214
OUString maHelpText
Definition: tabbar.cxx:205
ScopedVclPtr< ImplTabSizer > mpSizer
Definition: tabbar.cxx:503
vcl::AccessibleFactoryAccess maAccessibleFactory
Definition: tabbar.cxx:508
sal_uInt16 getItemSize() const
Definition: tabbar.cxx:510
ScopedVclPtr< TabBarEdit > mxEdit
Definition: tabbar.cxx:505
std::vector< ImplTabBarItem > maItemList
Definition: tabbar.cxx:506
ScopedVclPtr< TabButtons > mxButtonBox
Definition: tabbar.cxx:504
OUString SvtResId(TranslateId aId)
Definition: svtresid.cxx:24
IMPL_LINK(TabBarEdit, KeyInputHdl, const KeyEvent &, rKEvt, bool)
Definition: tabbar.cxx:379
IMPL_LINK_NOARG(TabBarEdit, ActivatedHdl, weld::Entry &, bool)
Definition: tabbar.cxx:369
TabBarAllowRenamingReturnCode
Definition: tabbar.hxx:298
@ TABBAR_RENAMING_NO
Definition: tabbar.hxx:299
@ TABBAR_RENAMING_YES
Definition: tabbar.hxx:300
#define WB_INSERTTAB
Definition: tabbar.hxx:277
TabBarPageBits
Definition: tabbar.hxx:282
#define WB_MULTISELECT
Definition: tabbar.hxx:275
#define WB_RANGESELECT
Definition: tabbar.hxx:274
#define TPB_DISPLAY_NAME_ALLFLAGS
Definition: tabbar.hxx:294
#define WB_MINSCROLL
Definition: tabbar.hxx:276
const tools::Long nButtonWidth
StateChangedType
sal_Int64 WinBits
WinBits const WB_DRAG
WinBits const WB_SIZEABLE
WinBits const WB_3DLOOK
WinBits const WB_SCROLL
WinBits const WB_CLIPCHILDREN