LibreOffice Module vcl (master) 1
tabctrl.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#include <sal/config.h>
21#include <sal/log.hxx>
22
24#include <vcl/svapp.hxx>
25#include <vcl/help.hxx>
26#include <vcl/event.hxx>
27#include <vcl/menu.hxx>
29#include <vcl/tabpage.hxx>
30#include <vcl/tabctrl.hxx>
31#include <vcl/toolbox.hxx>
32#include <vcl/layout.hxx>
33#include <vcl/mnemonic.hxx>
35#include <vcl/settings.hxx>
37#include <bitmaps.hlst>
38#include <tools/json_writer.hxx>
39
40#include <svdata.hxx>
41#include <window.h>
42
43#include <deque>
44#include <unordered_map>
45#include <vector>
46
47class ImplTabItem final
48{
49 sal_uInt16 m_nId;
50
51public:
53 OUString maText;
54 OUString maFormatText;
55 OUString maHelpText;
58 OString maTabName;
60 sal_uInt16 mnLine;
65
66 ImplTabItem(sal_uInt16 nId);
67
68 sal_uInt16 id() const { return m_nId; }
69};
70
72 : m_nId(nId)
73 , mnLine(0)
74 , mbFullVisible(false)
75 , m_bEnabled(true)
76 , m_bVisible(true)
77{
78}
79
81{
82 std::unordered_map< int, int > maLayoutPageIdToLine;
83 std::unordered_map< int, int > maLayoutLineToPageId;
84 std::vector< ImplTabItem > maItemList;
86};
87
88// for the Tab positions
89#define TAB_PAGERECT 0xFFFF
90
92{
93 mbLayoutDirty = true;
94
95 if ( !(nStyle & WB_NOTABSTOP) )
96 nStyle |= WB_TABSTOP;
97 if ( !(nStyle & WB_NOGROUP) )
98 nStyle |= WB_GROUP;
99 if ( !(nStyle & WB_NODIALOGCONTROL) )
100 nStyle |= WB_DIALOGCONTROL;
101
102 Control::ImplInit( pParent, nStyle, nullptr );
103
104 mnLastWidth = 0;
105 mnLastHeight = 0;
106 mnActPageId = 0;
107 mnCurPageId = 0;
108 mbFormat = true;
109 mbShowTabs = true;
110 mbRestoreHelpId = false;
111 mbSmallInvalidate = false;
113 mpTabCtrlData->mpListBox = nullptr;
114
115 ImplInitSettings( true );
116
117 if( nStyle & WB_DROPDOWN )
118 {
120 mpTabCtrlData->mpListBox->SetPosSizePixel( Point( 0, 0 ), Size( 200, 20 ) );
121 mpTabCtrlData->mpListBox->SetSelectHdl( LINK( this, TabControl, ImplListBoxSelectHdl ) );
122 mpTabCtrlData->mpListBox->Show();
123 }
124
125 // if the tabcontrol is drawn (ie filled) by a native widget, make sure all controls will have transparent background
126 // otherwise they will paint with a wrong background
129
130 if (pParent && pParent->IsDialog())
131 pParent->AddChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) );
132}
133
135{
136 return _rStyle.GetTabFont();
137}
138
140{
141 return _rStyle.GetTabTextColor();
142}
143
144void TabControl::ImplInitSettings( bool bBackground )
145{
147
148 if ( !bBackground )
149 return;
150
151 vcl::Window* pParent = GetParent();
152 if ( !IsControlBackground() &&
156
157 {
158 // set transparent mode for NWF tabcontrols to have
159 // the background always cleared properly
162 SetPaintTransparent( true );
165 }
166 else
167 {
170 SetPaintTransparent( false );
171
172 if ( IsControlBackground() )
174 else
175 SetBackground( pParent->GetBackground() );
176 }
177}
178
180{
181 if( HasLayoutData() )
182 {
184 mpTabCtrlData->maLayoutPageIdToLine.clear();
185 mpTabCtrlData->maLayoutLineToPageId.clear();
186 }
187}
188
191{
192 ImplInit( pParent, nStyle );
193 SAL_INFO( "vcl", "*** TABCONTROL no notabs? " << (( GetStyle() & WB_NOBORDER ) ? "true" : "false") );
194}
195
197{
198 disposeOnce();
199}
200
202{
203 Window *pParent = GetParent();
204 if (pParent && pParent->IsDialog())
205 GetParent()->RemoveChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) );
206
208
209 // delete TabCtrl data
210 if (mpTabCtrlData)
211 mpTabCtrlData->mpListBox.disposeAndClear();
212 mpTabCtrlData.reset();
214}
215
216ImplTabItem* TabControl::ImplGetItem( sal_uInt16 nId ) const
217{
218 for (auto & item : mpTabCtrlData->maItemList)
219 {
220 if (item.id() == nId)
221 return &item;
222 }
223
224 return nullptr;
225}
226
228{
229 pItem->maFormatText = pItem->maText;
230 Size aSize( GetOutDev()->GetCtrlTextWidth( pItem->maFormatText ), GetTextHeight() );
231 Size aImageSize( 0, 0 );
232 if( !!pItem->maTabImage )
233 {
234 aImageSize = pItem->maTabImage.GetSizePixel();
235 if( !pItem->maFormatText.isEmpty() )
236 aImageSize.AdjustWidth(GetTextHeight()/4 );
237 }
238 aSize.AdjustWidth(aImageSize.Width() );
239 if( aImageSize.Height() > aSize.Height() )
240 aSize.setHeight( aImageSize.Height() );
241
244
245 tools::Rectangle aCtrlRegion( Point( 0, 0 ), aSize );
246 tools::Rectangle aBoundingRgn, aContentRgn;
248 aSize.Width() - TAB_TABOFFSET_X * 2,
249 aSize.Height() - TAB_TABOFFSET_Y * 2));
251 ControlState::ENABLED, aControlValue,
252 aBoundingRgn, aContentRgn ) )
253 {
254 return aContentRgn.GetSize();
255 }
256
257 // For languages with short names (e.g. Chinese), because the space is
258 // normally only one pixel per char
259 if ( pItem->maFormatText.getLength() < TAB_EXTRASPACE_X )
260 aSize.AdjustWidth(TAB_EXTRASPACE_X-pItem->maFormatText.getLength() );
261
262 // shorten Text if needed
263 if ( aSize.Width()+4 >= nMaxWidth )
264 {
265 OUString aAppendStr("...");
266 pItem->maFormatText += aAppendStr;
267 do
268 {
269 if (pItem->maFormatText.getLength() > aAppendStr.getLength())
270 pItem->maFormatText = pItem->maFormatText.replaceAt( pItem->maFormatText.getLength()-aAppendStr.getLength()-1, 1, u"" );
271 aSize.setWidth( GetOutDev()->GetCtrlTextWidth( pItem->maFormatText ) );
272 aSize.AdjustWidth(aImageSize.Width() );
274 }
275 while ( (aSize.Width()+4 >= nMaxWidth) && (pItem->maFormatText.getLength() > aAppendStr.getLength()) );
276 if ( aSize.Width()+4 >= nMaxWidth )
277 {
278 pItem->maFormatText = ".";
279 aSize.setWidth( 1 );
280 }
281 }
282
283 if( pItem->maFormatText.isEmpty() )
284 {
285 if( aSize.Height() < aImageSize.Height()+4 ) //leave space for focus rect
286 aSize.setHeight( aImageSize.Height()+4 );
287 }
288
289 return aSize;
290}
291
292// Feel free to move this to some more general place for reuse
293// http://en.wikipedia.org/wiki/Word_wrap#Minimum_raggedness
294// Mostly based on Alexey Frunze's nifty example at
295// http://stackoverflow.com/questions/9071205/balanced-word-wrap-minimum-raggedness-in-php
297{
298 static std::deque<size_t> GetEndOfLineIndexes(const std::vector<sal_Int32>& rWidthsOf, sal_Int32 nLineWidth)
299 {
300 ++nLineWidth;
301
302 size_t nWidthsCount = rWidthsOf.size();
303 std::vector<sal_Int32> aCosts(nWidthsCount * nWidthsCount);
304
305 // cost function c(i, j) that computes the cost of a line consisting of
306 // the words Word[i] to Word[j]
307 for (size_t i = 0; i < nWidthsCount; ++i)
308 {
309 for (size_t j = 0; j < nWidthsCount; ++j)
310 {
311 if (j >= i)
312 {
313 sal_Int32 c = nLineWidth - (j - i);
314 for (size_t k = i; k <= j; ++k)
315 c -= rWidthsOf[k];
316 c = (c >= 0) ? c * c : SAL_MAX_INT32;
317 aCosts[j * nWidthsCount + i] = c;
318 }
319 else
320 {
321 aCosts[j * nWidthsCount + i] = SAL_MAX_INT32;
322 }
323 }
324 }
325
326 std::vector<sal_Int32> aFunction(nWidthsCount);
327 std::vector<sal_Int32> aWrapPoints(nWidthsCount);
328
329 // f(j) in aFunction[], collect wrap points in aWrapPoints[]
330 for (size_t j = 0; j < nWidthsCount; ++j)
331 {
332 aFunction[j] = aCosts[j * nWidthsCount];
333 if (aFunction[j] == SAL_MAX_INT32)
334 {
335 for (size_t k = 0; k < j; ++k)
336 {
337 sal_Int32 s;
338 if (aFunction[k] == SAL_MAX_INT32 || aCosts[j * nWidthsCount + k + 1] == SAL_MAX_INT32)
339 s = SAL_MAX_INT32;
340 else
341 s = aFunction[k] + aCosts[j * nWidthsCount + k + 1];
342 if (aFunction[j] > s)
343 {
344 aFunction[j] = s;
345 aWrapPoints[j] = k + 1;
346 }
347 }
348 }
349 }
350
351 std::deque<size_t> aSolution;
352
353 // no solution
354 if (aFunction[nWidthsCount - 1] == SAL_MAX_INT32)
355 return aSolution;
356
357 // optimal solution
358 size_t j = nWidthsCount - 1;
359 while (true)
360 {
361 aSolution.push_front(j);
362 if (!aWrapPoints[j])
363 break;
364 j = aWrapPoints[j] - 1;
365 }
366
367 return aSolution;
368 }
369};
370
371static void lcl_AdjustSingleLineTabs(tools::Long nMaxWidth, ImplTabCtrlData *pTabCtrlData)
372{
373 if (!ImplGetSVData()->maNWFData.mbCenteredTabs)
374 return;
375
376 int nRightSpace = nMaxWidth; // space left on the right by the tabs
377 for (auto const& item : pTabCtrlData->maItemList)
378 {
379 if (!item.m_bVisible)
380 continue;
381 nRightSpace -= item.maRect.GetWidth();
382 }
383 nRightSpace /= 2;
384
385 for (auto& item : pTabCtrlData->maItemList)
386 {
387 if (!item.m_bVisible)
388 continue;
389 item.maRect.AdjustLeft(nRightSpace);
390 item.maRect.AdjustRight(nRightSpace);
391 }
392}
393
395{
396 if ( nWidth <= 0 )
397 return false;
398 if ( mpTabCtrlData->maItemList.empty() )
399 return false;
400
401 tools::Long nMaxWidth = nWidth;
402
403 const tools::Long nOffsetX = 2;
404 const tools::Long nOffsetY = 2;
405
406 //fdo#66435 throw Knuth/Tex minimum raggedness algorithm at the problem
407 //of ugly bare tabs on lines of their own
408
409 //collect widths
410 std::vector<sal_Int32> aWidths;
411 for (auto & item : mpTabCtrlData->maItemList)
412 {
413 if (!item.m_bVisible)
414 continue;
415 aWidths.push_back(ImplGetItemSize(&item, nMaxWidth).Width());
416 }
417
418 //aBreakIndexes will contain the indexes of the last tab on each row
419 std::deque<size_t> aBreakIndexes(MinimumRaggednessWrap::GetEndOfLineIndexes(aWidths, nMaxWidth - nOffsetX - 2));
420
421 tools::Long nX = nOffsetX;
422 tools::Long nY = nOffsetY;
423
424 sal_uInt16 nLines = 0;
425 sal_uInt16 nCurLine = 0;
426
427 tools::Long nLineWidthAry[100];
428 sal_uInt16 nLinePosAry[101];
429 nLineWidthAry[0] = 0;
430 nLinePosAry[0] = 0;
431
432 size_t nIndex = 0;
433
434 for (auto & item : mpTabCtrlData->maItemList)
435 {
436 if (!item.m_bVisible)
437 continue;
438
439 Size aSize = ImplGetItemSize( &item, nMaxWidth );
440
441 bool bNewLine = false;
442 if (!aBreakIndexes.empty() && nIndex > aBreakIndexes.front())
443 {
444 aBreakIndexes.pop_front();
445 bNewLine = true;
446 }
447
448 if ( bNewLine && (nWidth > 2+nOffsetX) )
449 {
450 if ( nLines == 99 )
451 break;
452
453 nX = nOffsetX;
454 nY += aSize.Height();
455 nLines++;
456 nLineWidthAry[nLines] = 0;
457 nLinePosAry[nLines] = nIndex;
458 }
459
460 tools::Rectangle aNewRect( Point( nX, nY ), aSize );
461 if ( mbSmallInvalidate && (item.maRect != aNewRect) )
462 mbSmallInvalidate = false;
463 item.maRect = aNewRect;
464 item.mnLine = nLines;
465 item.mbFullVisible = true;
466
467 nLineWidthAry[nLines] += aSize.Width();
468 nX += aSize.Width();
469
470 if (item.id() == mnCurPageId)
471 nCurLine = nLines;
472
473 ++nIndex;
474 }
475
476 if (nLines) // two or more lines
477 {
478 tools::Long nLineHeightAry[100];
479 tools::Long nIH = 0;
480 for (const auto& item : mpTabCtrlData->maItemList)
481 {
482 if (!item.m_bVisible)
483 continue;
484 nIH = item.maRect.Bottom() - 1;
485 break;
486 }
487
488 for ( sal_uInt16 i = 0; i < nLines+1; i++ )
489 {
490 if ( i <= nCurLine )
491 nLineHeightAry[i] = nIH*(nLines-(nCurLine-i));
492 else
493 nLineHeightAry[i] = nIH*(i-nCurLine-1);
494 }
495
496 nLinePosAry[nLines+1] = static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size());
497
498 tools::Long nDX = 0;
499 tools::Long nModDX = 0;
500 tools::Long nIDX = 0;
501
502 sal_uInt16 i = 0;
503 sal_uInt16 n = 0;
504
505 for (auto & item : mpTabCtrlData->maItemList)
506 {
507 if (!item.m_bVisible)
508 continue;
509
510 if ( i == nLinePosAry[n] )
511 {
512 if ( n == nLines+1 )
513 break;
514
515 nIDX = 0;
516 if( nLinePosAry[n+1]-i > 0 )
517 {
518 nDX = ( nWidth - nOffsetX - nLineWidthAry[n] ) / ( nLinePosAry[n+1] - i );
519 nModDX = ( nWidth - nOffsetX - nLineWidthAry[n] ) % ( nLinePosAry[n+1] - i );
520 }
521 else
522 {
523 // FIXME: this is a case of tabctrl way too small
524 nDX = 0;
525 nModDX = 0;
526 }
527 n++;
528 }
529
530 item.maRect.AdjustLeft(nIDX );
531 item.maRect.AdjustRight(nIDX + nDX );
532 item.maRect.SetTop( nLineHeightAry[n-1] );
533 item.maRect.SetBottom(nLineHeightAry[n-1] + nIH - 1);
534 nIDX += nDX;
535
536 if ( nModDX )
537 {
538 nIDX++;
539 item.maRect.AdjustRight( 1 );
540 nModDX--;
541 }
542
543 i++;
544 }
545 }
546 else // only one line
547 lcl_AdjustSingleLineTabs(nMaxWidth, mpTabCtrlData.get());
548
549 return true;
550}
551
553{
555 if ( nWidth < 0 )
556 nWidth = aWinSize.Width();
557 if ( nHeight < 0 )
558 nHeight = aWinSize.Height();
559
560 if ( mpTabCtrlData->maItemList.empty() )
561 {
562 tools::Long nW = nWidth-TAB_OFFSET*2;
563 tools::Long nH = nHeight-TAB_OFFSET*2;
564 return (nW > 0 && nH > 0)
567 }
568
569 if ( nItemPos == TAB_PAGERECT )
570 {
571 sal_uInt16 nLastPos;
572 if ( mnCurPageId )
573 nLastPos = GetPagePos( mnCurPageId );
574 else
575 nLastPos = 0;
576
577 tools::Rectangle aRect = ImplGetTabRect( nLastPos, nWidth, nHeight );
578 if (aRect.IsEmpty())
579 return aRect;
580
581 // with show-tabs of true (the usual) the page rect is from under the
582 // visible tab to the bottom of the TabControl, otherwise it extends
583 // from the top of the TabControl
584 tools::Long nTabBottom = mbShowTabs ? aRect.Bottom() : 0;
585
586 tools::Long nW = nWidth-TAB_OFFSET*2;
587 tools::Long nH = nHeight - nTabBottom - TAB_OFFSET*2;
588 return (nW > 0 && nH > 0)
589 ? tools::Rectangle( Point( TAB_OFFSET, nTabBottom + TAB_OFFSET ), Size( nW, nH ) )
591 }
592
593 ImplTabItem* const pItem = (nItemPos < mpTabCtrlData->maItemList.size())
594 ? &mpTabCtrlData->maItemList[nItemPos] : nullptr;
595 return ImplGetTabRect(pItem, nWidth, nHeight);
596}
597
599{
600 if ((nWidth <= 1) || (nHeight <= 0) || !pItem || !pItem->m_bVisible)
601 return tools::Rectangle();
602
603 nWidth -= 1;
604
605 if ( mbFormat || (mnLastWidth != nWidth) || (mnLastHeight != nHeight) )
606 {
607 vcl::Font aFont( GetFont() );
608 aFont.SetTransparent( true );
609 SetFont( aFont );
610
611 bool bRet = ImplPlaceTabs( nWidth );
612 if ( !bRet )
613 return tools::Rectangle();
614
615 mnLastWidth = nWidth;
616 mnLastHeight = nHeight;
617 mbFormat = false;
618 }
619
620 return pItem->maRect;
621}
622
623void TabControl::ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId )
624{
626
627 ImplTabItem* pOldItem = ImplGetItem( nOldId );
628 ImplTabItem* pItem = ImplGetItem( nId );
629 TabPage* pOldPage = pOldItem ? pOldItem->mpTabPage.get() : nullptr;
630 TabPage* pPage = pItem ? pItem->mpTabPage.get() : nullptr;
631 vcl::Window* pCtrlParent = GetParent();
632
633 if ( IsReallyVisible() && IsUpdateMode() )
634 {
635 sal_uInt16 nPos = GetPagePos( nId );
637
638 if ( !pOldItem || !pItem || (pOldItem->mnLine != pItem->mnLine) )
639 {
640 aRect.SetLeft( 0 );
641 aRect.SetTop( 0 );
643 }
644 else
645 {
646 aRect.AdjustLeft( -3 );
647 aRect.AdjustTop( -2 );
648 aRect.AdjustRight(3 );
649 Invalidate( aRect );
650 nPos = GetPagePos( nOldId );
651 aRect = ImplGetTabRect( nPos );
652 aRect.AdjustLeft( -3 );
653 aRect.AdjustTop( -2 );
654 aRect.AdjustRight(3 );
655 }
656 Invalidate( aRect );
657 }
658
659 if ( pOldPage == pPage )
660 return;
661
663
664 if ( pOldPage )
665 {
666 if ( mbRestoreHelpId )
667 pCtrlParent->SetHelpId( OString() );
668 }
669
670 if ( pPage )
671 {
672 if ( GetStyle() & WB_NOBORDER )
673 {
674 tools::Rectangle aRectNoTab(Point(0, 0), GetSizePixel());
675 pPage->SetPosSizePixel( aRectNoTab.TopLeft(), aRectNoTab.GetSize() );
676 }
677 else
678 pPage->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() );
679
680 // activate page here so the controls can be switched
681 // also set the help id of the parent window to that of the tab page
682 if ( GetHelpId().isEmpty() )
683 {
684 mbRestoreHelpId = true;
685 pCtrlParent->SetHelpId( pPage->GetHelpId() );
686 }
687
688 pPage->Show();
689
690 if ( pOldPage && pOldPage->HasChildPathFocus() )
691 {
692 vcl::Window* pFirstChild = pPage->ImplGetDlgWindow( 0, GetDlgWindowType::First );
693 if ( pFirstChild )
695 else
696 GrabFocus();
697 }
698 }
699
700 if ( pOldPage )
701 pOldPage->Hide();
702
703 // Invalidate the same region that will be send to NWF
704 // to always allow for bitmap caching
705 // see Window::DrawNativeControl()
707 {
708 aRect.AdjustLeft( -(TAB_OFFSET) );
709 aRect.AdjustTop( -(TAB_OFFSET) );
710 aRect.AdjustRight(TAB_OFFSET );
711 aRect.AdjustBottom(TAB_OFFSET );
712 }
713
714 Invalidate( aRect );
715}
716
718{
719 // resize/position current TabPage
721 if ( pItem && pItem->mpTabPage )
722 {
723 if ( GetStyle() & WB_NOBORDER )
724 {
725 tools::Rectangle aRectNoTab(Point(0, 0), GetSizePixel());
726 pItem->mpTabPage->SetPosSizePixel( aRectNoTab.TopLeft(), aRectNoTab.GetSize() );
727 return true;
728 }
730 pItem->mpTabPage->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() );
731 return true;
732 }
733
734 return false;
735}
736
738{
739 sal_uInt16 nCurPos = GetPagePos( GetCurPageId() );
740
741 if ( bNext )
742 nCurPos = (nCurPos + 1) % GetPageCount();
743 else
744 {
745 if ( !nCurPos )
746 nCurPos = GetPageCount()-1;
747 else
748 nCurPos--;
749 }
750
751 SelectTabPage( GetPageId( nCurPos ) );
752}
753
755{
756 if ( !GetPageCount() || mpTabCtrlData->mpListBox )
757 return;
758
759 sal_uInt16 nCurPos = GetPagePos( mnCurPageId );
760 tools::Rectangle aRect = ImplGetTabRect( nCurPos );
761 const ImplTabItem& rItem = mpTabCtrlData->maItemList[ nCurPos ];
762 Size aTabSize = aRect.GetSize();
763 Size aImageSize( 0, 0 );
764 tools::Long nTextHeight = GetTextHeight();
765 tools::Long nTextWidth = GetOutDev()->GetCtrlTextWidth( rItem.maFormatText );
766 sal_uInt16 nOff;
767
768 if ( !(GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::Mono) )
769 nOff = 1;
770 else
771 nOff = 0;
772
773 if( !! rItem.maTabImage )
774 {
775 aImageSize = rItem.maTabImage.GetSizePixel();
776 if( !rItem.maFormatText.isEmpty() )
777 aImageSize.AdjustWidth(GetTextHeight()/4 );
778 }
779
780 if( !rItem.maFormatText.isEmpty() )
781 {
782 // show focus around text
783 aRect.SetLeft( aRect.Left()+aImageSize.Width()+((aTabSize.Width()-nTextWidth-aImageSize.Width())/2)-nOff-1-1 );
784 aRect.SetTop( aRect.Top()+((aTabSize.Height()-nTextHeight)/2)-1-1 );
785 aRect.SetRight( aRect.Left()+nTextWidth+2 );
786 aRect.SetBottom( aRect.Top()+nTextHeight+2 );
787 }
788 else
789 {
790 // show focus around image
791 tools::Long nXPos = aRect.Left()+((aTabSize.Width()-nTextWidth-aImageSize.Width())/2)-nOff-1;
792 tools::Long nYPos = aRect.Top();
793 if( aImageSize.Height() < aRect.GetHeight() )
794 nYPos += (aRect.GetHeight() - aImageSize.Height())/2;
795
796 aRect.SetLeft( nXPos - 2 );
797 aRect.SetTop( nYPos - 2 );
798 aRect.SetRight( aRect.Left() + aImageSize.Width() + 4 );
799 aRect.SetBottom( aRect.Top() + aImageSize.Height() + 4 );
800 }
801 ShowFocus( aRect );
802}
803
804void TabControl::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem const * pItem, const tools::Rectangle& rCurRect,
805 bool bFirstInGroup, bool bLastInGroup )
806{
807 if (!pItem->m_bVisible || pItem->maRect.IsEmpty())
808 return;
809
810 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
811 tools::Rectangle aRect = pItem->maRect;
812 tools::Long nLeftBottom = aRect.Bottom();
813 tools::Long nRightBottom = aRect.Bottom();
814 bool bLeftBorder = true;
815 bool bRightBorder = true;
816 sal_uInt16 nOff;
817 bool bNativeOK = false;
818
819 sal_uInt16 nOff2 = 0;
820 sal_uInt16 nOff3 = 0;
821
822 if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
823 nOff = 1;
824 else
825 nOff = 0;
826
827 // if this is the active Page, we have to draw a little more
828 if (pItem->id() == mnCurPageId)
829 {
830 nOff2 = 2;
831 if (!ImplGetSVData()->maNWFData.mbNoActiveTabTextRaise)
832 nOff3 = 1;
833 }
834 else
835 {
836 Point aLeftTestPos = aRect.BottomLeft();
837 Point aRightTestPos = aRect.BottomRight();
838 if (aLeftTestPos.Y() == rCurRect.Bottom())
839 {
840 aLeftTestPos.AdjustX( -2 );
841 if (rCurRect.Contains(aLeftTestPos))
842 bLeftBorder = false;
843 aRightTestPos.AdjustX(2 );
844 if (rCurRect.Contains(aRightTestPos))
845 bRightBorder = false;
846 }
847 else
848 {
849 if (rCurRect.Contains(aLeftTestPos))
850 nLeftBottom -= 2;
851 if (rCurRect.Contains(aRightTestPos))
852 nRightBottom -= 2;
853 }
854 }
855
857
858 if (pItem->id() == mnCurPageId)
859 {
861 // only the selected item can be focused
862 if (HasFocus())
864 }
865 if (IsEnabled())
868 {
870 for (auto const& item : mpTabCtrlData->maItemList)
871 if ((&item != pItem) && item.m_bVisible && item.maRect.Contains(GetPointerPosPixel()))
872 {
873 nState &= ~ControlState::ROLLOVER; // avoid multiple highlighted tabs
874 break;
875 }
877 }
878
880 if ( bNativeOK )
881 {
883 pItem->maRect.Top() + TAB_TABOFFSET_Y,
884 pItem->maRect.Right() - TAB_TABOFFSET_X,
885 pItem->maRect.Bottom() - TAB_TABOFFSET_Y));
886 if (pItem->maRect.Left() < 5)
888 if (pItem->maRect.Right() > mnLastWidth - 5)
890 if (bFirstInGroup)
892 if (bLastInGroup)
894
895 tools::Rectangle aCtrlRegion( pItem->maRect );
898 aCtrlRegion, nState, tiValue, OUString() );
899 }
900
901 if (!bNativeOK)
902 {
903 if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
904 {
905 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
906 rRenderContext.DrawPixel(Point(aRect.Left() + 1 - nOff2, aRect.Top() + 1 - nOff2)); // diagonally indented top-left pixel
907 if (bLeftBorder)
908 {
909 rRenderContext.DrawLine(Point(aRect.Left() - nOff2, aRect.Top() + 2 - nOff2),
910 Point(aRect.Left() - nOff2, nLeftBottom - 1));
911 }
912 rRenderContext.DrawLine(Point(aRect.Left() + 2 - nOff2, aRect.Top() - nOff2), // top line starting 2px from left border
913 Point(aRect.Right() + nOff2 - 3, aRect.Top() - nOff2)); // ending 3px from right border
914
915 if (bRightBorder)
916 {
917 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
918 rRenderContext.DrawLine(Point(aRect.Right() + nOff2 - 2, aRect.Top() + 1 - nOff2),
919 Point(aRect.Right() + nOff2 - 2, nRightBottom - 1));
920
921 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
922 rRenderContext.DrawLine(Point(aRect.Right() + nOff2 - 1, aRect.Top() + 3 - nOff2),
923 Point(aRect.Right() + nOff2 - 1, nRightBottom - 1));
924 }
925 }
926 else
927 {
928 rRenderContext.SetLineColor(COL_BLACK);
929 rRenderContext.DrawPixel(Point(aRect.Left() + 1 - nOff2, aRect.Top() + 1 - nOff2));
930 rRenderContext.DrawPixel(Point(aRect.Right() + nOff2 - 2, aRect.Top() + 1 - nOff2));
931 if (bLeftBorder)
932 {
933 rRenderContext.DrawLine(Point(aRect.Left() - nOff2, aRect.Top() + 2 - nOff2),
934 Point(aRect.Left() - nOff2, nLeftBottom - 1));
935 }
936 rRenderContext.DrawLine(Point(aRect.Left() + 2 - nOff2, aRect.Top() - nOff2),
937 Point(aRect.Right() - 3, aRect.Top() - nOff2));
938 if (bRightBorder)
939 {
940 rRenderContext.DrawLine(Point(aRect.Right() + nOff2 - 1, aRect.Top() + 2 - nOff2),
941 Point(aRect.Right() + nOff2 - 1, nRightBottom - 1));
942 }
943 }
944 }
945
946 // set font accordingly, current item is painted bold
947 // we set the font attributes always before drawing to be re-entrant (DrawNativeControl may trigger additional paints)
948 vcl::Font aFont(rRenderContext.GetFont());
949 aFont.SetTransparent(true);
950 rRenderContext.SetFont(aFont);
951
952 Size aTabSize = aRect.GetSize();
953 Size aImageSize(0, 0);
954 tools::Long nTextHeight = rRenderContext.GetTextHeight();
955 tools::Long nTextWidth = rRenderContext.GetCtrlTextWidth(pItem->maFormatText);
956 if (!!pItem->maTabImage)
957 {
958 aImageSize = pItem->maTabImage.GetSizePixel();
959 if (!pItem->maFormatText.isEmpty())
960 aImageSize.AdjustWidth(GetTextHeight() / 4 );
961 }
962 tools::Long nXPos = aRect.Left() + ((aTabSize.Width() - nTextWidth - aImageSize.Width()) / 2) - nOff - nOff3;
963 tools::Long nYPos = aRect.Top() + ((aTabSize.Height() - nTextHeight) / 2) - nOff3;
964 if (!pItem->maFormatText.isEmpty())
965 {
967 if (!pItem->m_bEnabled)
968 nStyle |= DrawTextFlags::Disable;
969
970 Color aColor(rStyleSettings.GetTabTextColor());
972 aColor = rStyleSettings.GetTabHighlightTextColor();
974 aColor = rStyleSettings.GetTabRolloverTextColor();
975
976 Color aOldColor(rRenderContext.GetTextColor());
977 rRenderContext.SetTextColor(aColor);
978
979 const tools::Rectangle aOutRect(nXPos + aImageSize.Width(), nYPos,
980 nXPos + aImageSize.Width() + nTextWidth, nYPos + nTextHeight);
981 DrawControlText(rRenderContext, aOutRect, pItem->maFormatText, nStyle,
982 nullptr, nullptr);
983
984 rRenderContext.SetTextColor(aOldColor);
985 }
986
987 if (!!pItem->maTabImage)
988 {
989 Point aImgTL( nXPos, aRect.Top() );
990 if (aImageSize.Height() < aRect.GetHeight())
991 aImgTL.AdjustY((aRect.GetHeight() - aImageSize.Height()) / 2 );
992 rRenderContext.DrawImage(aImgTL, pItem->maTabImage, pItem->m_bEnabled ? DrawImageFlags::NONE : DrawImageFlags::Disable );
993 }
994}
995
997{
998 bool bRet = false;
999
1000 if ( GetPageCount() > 1 )
1001 {
1002 vcl::KeyCode aKeyCode = rKeyEvent.GetKeyCode();
1003 sal_uInt16 nKeyCode = aKeyCode.GetCode();
1004
1005 if ( aKeyCode.IsMod1() )
1006 {
1007 if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
1008 {
1009 if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
1010 {
1011 ImplActivateTabPage( false );
1012 bRet = true;
1013 }
1014 }
1015 else
1016 {
1017 if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
1018 {
1019 ImplActivateTabPage( true );
1020 bRet = true;
1021 }
1022 }
1023 }
1024 }
1025
1026 return bRet;
1027}
1028
1029IMPL_LINK_NOARG(TabControl, ImplListBoxSelectHdl, ListBox&, void)
1030{
1031 SelectTabPage( GetPageId( mpTabCtrlData->mpListBox->GetSelectedEntryPos() ) );
1032}
1033
1034IMPL_LINK( TabControl, ImplWindowEventListener, VclWindowEvent&, rEvent, void )
1035{
1036 if ( rEvent.GetId() == VclEventId::WindowKeyInput )
1037 {
1038 // Do not handle events from TabControl or its children, which is done in Notify(), where the events can be consumed.
1039 if ( !IsWindowOrChild( rEvent.GetWindow() ) )
1040 {
1041 KeyEvent* pKeyEvent = static_cast< KeyEvent* >(rEvent.GetData());
1042 ImplHandleKeyEvent( *pKeyEvent );
1043 }
1044 }
1045}
1046
1048{
1049 if (mpTabCtrlData->mpListBox || !rMEvt.IsLeft())
1050 return;
1051
1052 ImplTabItem *pItem = ImplGetItem(rMEvt.GetPosPixel());
1053 if (pItem && pItem->m_bEnabled)
1054 SelectTabPage(pItem->id());
1055}
1056
1057void TabControl::KeyInput( const KeyEvent& rKEvt )
1058{
1059 if( mpTabCtrlData->mpListBox )
1060 mpTabCtrlData->mpListBox->KeyInput( rKEvt );
1061 else if ( GetPageCount() > 1 )
1062 {
1063 vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1064 sal_uInt16 nKeyCode = aKeyCode.GetCode();
1065
1066 if ( (nKeyCode == KEY_LEFT) || (nKeyCode == KEY_RIGHT) )
1067 {
1068 bool bNext = (nKeyCode == KEY_RIGHT);
1069 ImplActivateTabPage( bNext );
1070 }
1071 }
1072
1073 Control::KeyInput( rKEvt );
1074}
1075
1076static bool lcl_canPaint(const vcl::RenderContext& rRenderContext, const tools::Rectangle& rDrawRect,
1077 const tools::Rectangle& rItemRect)
1078{
1079 vcl::Region aClipRgn(rRenderContext.GetActiveClipRegion());
1080 aClipRgn.Intersect(rItemRect);
1081 if (!rDrawRect.IsEmpty())
1082 aClipRgn.Intersect(rDrawRect);
1083 return !aClipRgn.IsEmpty();
1084}
1085
1086void TabControl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
1087{
1088 if (GetStyle() & WB_NOBORDER)
1089 return;
1090
1091 Control::Paint(rRenderContext, rRect);
1092
1093 HideFocus();
1094
1095 // reformat if needed
1097
1098 // find current item
1099 ImplTabItem* pCurItem = nullptr;
1100 for (auto & item : mpTabCtrlData->maItemList)
1101 {
1102 if (item.id() == mnCurPageId)
1103 {
1104 pCurItem = &item;
1105 break;
1106 }
1107 }
1108
1109 // Draw the TabPage border
1110 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1111 tools::Rectangle aCurRect;
1112 aRect.AdjustLeft( -(TAB_OFFSET) );
1113 aRect.AdjustTop( -(TAB_OFFSET) );
1114 aRect.AdjustRight(TAB_OFFSET );
1115 aRect.AdjustBottom(TAB_OFFSET );
1116
1117 // if we have an invisible tabpage or no tabpage at all the tabpage rect should be
1118 // increased to avoid round corners that might be drawn by a theme
1119 // in this case we're only interested in the top border of the tabpage because the tabitems are used
1120 // standalone (eg impress)
1121 bool bNoTabPage = false;
1122 TabPage* pCurPage = pCurItem ? pCurItem->mpTabPage.get() : nullptr;
1123 if (!pCurPage || !pCurPage->IsVisible())
1124 {
1125 bNoTabPage = true;
1126 aRect.AdjustLeft( -10 );
1127 aRect.AdjustRight(10 );
1128 }
1129
1131 {
1132 const bool bPaneWithHeader = mbShowTabs && rRenderContext.IsNativeControlSupported(ControlType::TabPane, ControlPart::TabPaneWithHeader);
1133 tools::Rectangle aHeaderRect(aRect.Left(), 0, aRect.Right(), aRect.Top());
1134
1135 if (mpTabCtrlData->maItemList.size())
1136 {
1137 tools::Long nLeft = LONG_MAX;
1138 tools::Long nRight = 0;
1139 for (const auto &item : mpTabCtrlData->maItemList)
1140 {
1141 if (!item.m_bVisible)
1142 continue;
1143 nRight = std::max(nRight, item.maRect.Right());
1144 nLeft = std::min(nLeft, item.maRect.Left());
1145 }
1146 aHeaderRect.SetLeft(nLeft);
1147 aHeaderRect.SetRight(nRight);
1148 }
1149
1150 if (bPaneWithHeader)
1151 aRect.SetTop(0);
1152
1153 const TabPaneValue aTabPaneValue(aHeaderRect, pCurItem ? pCurItem->maRect : tools::Rectangle());
1154
1156 if (!IsEnabled())
1157 nState &= ~ControlState::ENABLED;
1158 if (HasFocus())
1160
1161 if (lcl_canPaint(rRenderContext, rRect, aRect))
1163 aRect, nState, aTabPaneValue, OUString());
1164
1165 if (!bPaneWithHeader && rRenderContext.IsNativeControlSupported(ControlType::TabHeader, ControlPart::Entire)
1166 && lcl_canPaint(rRenderContext, rRect, aHeaderRect))
1168 aHeaderRect, nState, aTabPaneValue, OUString());
1169 }
1170 else
1171 {
1172 tools::Long nTopOff = 1;
1173 if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
1174 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
1175 else
1176 rRenderContext.SetLineColor(COL_BLACK);
1177 if (mbShowTabs && pCurItem && !pCurItem->maRect.IsEmpty())
1178 {
1179 aCurRect = pCurItem->maRect;
1180 rRenderContext.DrawLine(aRect.TopLeft(), Point(aCurRect.Left() - 2, aRect.Top()));
1181 if (aCurRect.Right() + 1 < aRect.Right())
1182 {
1183 rRenderContext.DrawLine(Point(aCurRect.Right(), aRect.Top()), aRect.TopRight());
1184 }
1185 else
1186 {
1187 nTopOff = 0;
1188 }
1189 }
1190 else
1191 rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
1192
1193 rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
1194
1195 if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
1196 {
1197 // if we have not tab page the bottom line of the tab page
1198 // directly touches the tab items, so choose a color that fits seamlessly
1199 if (bNoTabPage)
1200 rRenderContext.SetLineColor(rStyleSettings.GetDialogColor());
1201 else
1202 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
1203 rRenderContext.DrawLine(Point(1, aRect.Bottom() - 1), Point(aRect.Right() - 1, aRect.Bottom() - 1));
1204 rRenderContext.DrawLine(Point(aRect.Right() - 1, aRect.Top() + nTopOff), Point(aRect.Right() - 1, aRect.Bottom() - 1));
1205 if (bNoTabPage)
1206 rRenderContext.SetLineColor(rStyleSettings.GetDialogColor());
1207 else
1208 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
1209 rRenderContext.DrawLine(Point(0, aRect.Bottom()), Point(aRect.Right(), aRect.Bottom()));
1210 rRenderContext.DrawLine(Point(aRect.Right(), aRect.Top() + nTopOff), Point(aRect.Right(), aRect.Bottom()));
1211 }
1212 else
1213 {
1214 rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
1215 rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
1216 }
1217 }
1218
1219 if (mbShowTabs && !mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == nullptr)
1220 {
1221 // Some native toolkits (GTK+) draw tabs right-to-left, with an
1222 // overlap between adjacent tabs
1223 bool bDrawTabsRTL = rRenderContext.IsNativeControlSupported(ControlType::TabItem, ControlPart::TabsDrawRtl);
1224 ImplTabItem* pFirstTab = nullptr;
1225 ImplTabItem* pLastTab = nullptr;
1226 size_t idx;
1227
1228 // Even though there is a tab overlap with GTK+, the first tab is not
1229 // overlapped on the left side. Other toolkits ignore this option.
1230 if (bDrawTabsRTL)
1231 {
1232 pFirstTab = mpTabCtrlData->maItemList.data();
1233 pLastTab = pFirstTab + mpTabCtrlData->maItemList.size() - 1;
1234 idx = mpTabCtrlData->maItemList.size() - 1;
1235 }
1236 else
1237 {
1238 pLastTab = mpTabCtrlData->maItemList.data();
1239 pFirstTab = pLastTab + mpTabCtrlData->maItemList.size() - 1;
1240 idx = 0;
1241 }
1242
1243 while (idx < mpTabCtrlData->maItemList.size())
1244 {
1245 ImplTabItem* pItem = &mpTabCtrlData->maItemList[idx];
1246
1247 if (pItem != pCurItem && pItem->m_bVisible && lcl_canPaint(rRenderContext, rRect, pItem->maRect))
1248 ImplDrawItem(rRenderContext, pItem, aCurRect, pItem == pFirstTab, pItem == pLastTab);
1249
1250 if (bDrawTabsRTL)
1251 idx--;
1252 else
1253 idx++;
1254 }
1255
1256 if (pCurItem && lcl_canPaint(rRenderContext, rRect, pCurItem->maRect))
1257 ImplDrawItem(rRenderContext, pCurItem, aCurRect, pCurItem == pFirstTab, pCurItem == pLastTab);
1258 }
1259
1260 if (HasFocus())
1261 ImplShowFocus();
1262
1263 mbSmallInvalidate = true;
1264}
1265
1266void TabControl::setAllocation(const Size &rAllocation)
1267{
1269
1270 if ( !IsReallyShown() )
1271 return;
1272
1273 if( mpTabCtrlData->mpListBox )
1274 {
1275 // get the listbox' preferred size
1276 Size aTabCtrlSize( GetSizePixel() );
1277 tools::Long nPrefWidth = mpTabCtrlData->mpListBox->get_preferred_size().Width();
1278 if( nPrefWidth > aTabCtrlSize.Width() )
1279 nPrefWidth = aTabCtrlSize.Width();
1280 Size aNewSize( nPrefWidth, LogicToPixel( Size( 12, 12 ), MapMode( MapUnit::MapAppFont ) ).Height() );
1281 Point aNewPos( (aTabCtrlSize.Width() - nPrefWidth) / 2, 0 );
1282 mpTabCtrlData->mpListBox->SetPosSizePixel( aNewPos, aNewSize );
1283 }
1284
1285 mbFormat = true;
1286
1287 // resize/position active TabPage
1288 bool bTabPage = ImplPosCurTabPage();
1289
1290 // check what needs to be invalidated
1291 Size aNewSize = rAllocation;
1292 tools::Long nNewWidth = aNewSize.Width();
1293 for (auto const& item : mpTabCtrlData->maItemList)
1294 {
1295 if (!item.m_bVisible)
1296 continue;
1297 if (!item.mbFullVisible || (item.maRect.Right()-2 >= nNewWidth))
1298 {
1299 mbSmallInvalidate = false;
1300 break;
1301 }
1302 }
1303
1304 if ( mbSmallInvalidate )
1305 {
1311 if ( bTabPage )
1313 else
1314 Invalidate( aRect );
1315
1316 }
1317 else
1318 {
1319 if ( bTabPage )
1321 else
1322 Invalidate();
1323 }
1324
1325 mbLayoutDirty = false;
1326}
1327
1328void TabControl::SetPosSizePixel(const Point& rNewPos, const Size& rNewSize)
1329{
1330 Window::SetPosSizePixel(rNewPos, rNewSize);
1331 //if size changed, TabControl::Resize got called already
1332 if (mbLayoutDirty)
1333 setAllocation(rNewSize);
1334}
1335
1336void TabControl::SetSizePixel(const Size& rNewSize)
1337{
1338 Window::SetSizePixel(rNewSize);
1339 //if size changed, TabControl::Resize got called already
1340 if (mbLayoutDirty)
1341 setAllocation(rNewSize);
1342}
1343
1344void TabControl::SetPosPixel(const Point& rPos)
1345{
1346 Window::SetPosPixel(rPos);
1347 if (mbLayoutDirty)
1349}
1350
1352{
1354}
1355
1357{
1358 if( ! mpTabCtrlData->mpListBox )
1359 {
1360 if (mbShowTabs)
1361 {
1362 ImplShowFocus();
1364 }
1365 else
1366 {
1367 // no tabs, focus first thing in current page
1369 if (pItem && pItem->mpTabPage)
1370 {
1372 if ( pFirstChild )
1374 }
1375 }
1376 }
1377 else
1378 {
1379 if( mpTabCtrlData->mpListBox->IsReallyVisible() )
1380 mpTabCtrlData->mpListBox->GrabFocus();
1381 }
1382
1384}
1385
1387{
1388 if( mpTabCtrlData && ! mpTabCtrlData->mpListBox )
1389 HideFocus();
1391}
1392
1394{
1395 sal_uInt16 nItemId = rHEvt.KeyboardActivated() ? mnCurPageId : GetPageId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
1396
1397 if ( nItemId )
1398 {
1399 if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
1400 {
1401 OUString aStr = GetHelpText( nItemId );
1402 if ( !aStr.isEmpty() )
1403 {
1404 tools::Rectangle aItemRect = ImplGetTabRect( GetPagePos( nItemId ) );
1405 Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1406 aItemRect.SetLeft( aPt.X() );
1407 aItemRect.SetTop( aPt.Y() );
1408 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1409 aItemRect.SetRight( aPt.X() );
1410 aItemRect.SetBottom( aPt.Y() );
1411 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
1412 return;
1413 }
1414 }
1415
1416 // for Quick or Ballon Help, we show the text, if it is cut
1418 {
1419 ImplTabItem* pItem = ImplGetItem( nItemId );
1420 const OUString& rStr = pItem->maText;
1421 if ( rStr != pItem->maFormatText )
1422 {
1423 tools::Rectangle aItemRect = ImplGetTabRect( GetPagePos( nItemId ) );
1424 Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1425 aItemRect.SetLeft( aPt.X() );
1426 aItemRect.SetTop( aPt.Y() );
1427 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1428 aItemRect.SetRight( aPt.X() );
1429 aItemRect.SetBottom( aPt.Y() );
1430 if ( !rStr.isEmpty() )
1431 {
1432 if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
1433 Help::ShowBalloon( this, aItemRect.Center(), aItemRect, rStr );
1434 else
1435 Help::ShowQuickHelp( this, aItemRect, rStr );
1436 return;
1437 }
1438 }
1439 }
1440
1441 if ( rHEvt.GetMode() & HelpEventMode::QUICK )
1442 {
1443 ImplTabItem* pItem = ImplGetItem( nItemId );
1444 const OUString& rHelpText = pItem->maHelpText;
1445 if (!rHelpText.isEmpty())
1446 {
1447 tools::Rectangle aItemRect = ImplGetTabRect( GetPagePos( nItemId ) );
1448 Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
1449 aItemRect.SetLeft( aPt.X() );
1450 aItemRect.SetTop( aPt.Y() );
1451 aPt = OutputToScreenPixel( aItemRect.BottomRight() );
1452 aItemRect.SetRight( aPt.X() );
1453 aItemRect.SetBottom( aPt.Y() );
1454 Help::ShowQuickHelp( this, aItemRect, rHelpText );
1455 return;
1456 }
1457 }
1458 }
1459
1460 Control::RequestHelp( rHEvt );
1461}
1462
1464{
1465 if( (mpTabCtrlData->mpListBox == nullptr) && (rCEvt.GetCommand() == CommandEventId::ContextMenu) && (GetPageCount() > 1) )
1466 {
1467 Point aMenuPos;
1468 bool bMenu;
1469 if ( rCEvt.IsMouseEvent() )
1470 {
1471 aMenuPos = rCEvt.GetMousePosPixel();
1472 bMenu = GetPageId( aMenuPos ) != 0;
1473 }
1474 else
1475 {
1476 aMenuPos = ImplGetTabRect( GetPagePos( mnCurPageId ) ).Center();
1477 bMenu = true;
1478 }
1479
1480 if ( bMenu )
1481 {
1483 for (auto const& item : mpTabCtrlData->maItemList)
1484 {
1485 aMenu->InsertItem(item.id(), item.maText, MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK);
1486 if (item.id() == mnCurPageId)
1487 aMenu->CheckItem(item.id());
1488 aMenu->SetHelpId(item.id(), OString());
1489 }
1490
1491 sal_uInt16 nId = aMenu->Execute( this, aMenuPos );
1492 if ( nId && (nId != mnCurPageId) )
1493 SelectTabPage( nId );
1494 return;
1495 }
1496 }
1497
1498 Control::Command( rCEvt );
1499}
1500
1502{
1504
1506 {
1508 if( mpTabCtrlData->mpListBox )
1509 Resize();
1510 }
1511 else if ( nType == StateChangedType::UpdateMode )
1512 {
1513 if ( IsUpdateMode() )
1514 Invalidate();
1515 }
1516 else if ( (nType == StateChangedType::Zoom) ||
1518 {
1519 ImplInitSettings( false );
1520 Invalidate();
1521 }
1523 {
1524 ImplInitSettings( false );
1525 Invalidate();
1526 }
1528 {
1529 ImplInitSettings( true );
1530 Invalidate();
1531 }
1532}
1533
1535{
1536 Control::DataChanged( rDCEvt );
1537
1538 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1540 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1541 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1542 {
1543 ImplInitSettings( true );
1544 Invalidate();
1545 }
1546}
1547
1548ImplTabItem* TabControl::ImplGetItem(const Point& rPt) const
1549{
1550 ImplTabItem* pFoundItem = nullptr;
1551 int nFound = 0;
1552 for (auto & item : mpTabCtrlData->maItemList)
1553 {
1554 if (item.m_bVisible && item.maRect.Contains(rPt))
1555 {
1556 nFound++;
1557 pFoundItem = &item;
1558 }
1559 }
1560
1561 // assure that only one tab is highlighted at a time
1562 assert(nFound <= 1);
1563 return nFound == 1 ? pFoundItem : nullptr;
1564}
1565
1567{
1568 if( rNEvt.GetType() == NotifyEventType::MOUSEMOVE )
1569 {
1570 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
1571 if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
1572 {
1573 // trigger redraw if mouse over state has changed
1575 {
1578 if ((pItem != pLastItem) || pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
1579 {
1580 vcl::Region aClipRgn;
1581 if (pLastItem)
1582 {
1583 // allow for slightly bigger tabitems
1584 // as used by gtk
1585 // TODO: query for the correct sizes
1586 tools::Rectangle aRect(pLastItem->maRect);
1587 aRect.AdjustLeft( -2 );
1588 aRect.AdjustRight(2 );
1589 aRect.AdjustTop( -3 );
1590 aClipRgn.Union( aRect );
1591 }
1592
1593 if (pItem)
1594 {
1595 // allow for slightly bigger tabitems
1596 // as used by gtk
1597 // TODO: query for the correct sizes
1598 tools::Rectangle aRect(pItem->maRect);
1599 aRect.AdjustLeft( -2 );
1600 aRect.AdjustRight(2 );
1601 aRect.AdjustTop( -3 );
1602 aClipRgn.Union( aRect );
1603 }
1604
1605 if( !aClipRgn.IsEmpty() )
1606 Invalidate( aClipRgn );
1607 }
1608 }
1609 }
1610 }
1611
1612 return Control::PreNotify(rNEvt);
1613}
1614
1616{
1617 bool bRet = false;
1618
1619 if ( rNEvt.GetType() == NotifyEventType::KEYINPUT )
1620 bRet = ImplHandleKeyEvent( *rNEvt.GetKeyEvent() );
1621
1622 return bRet || Control::EventNotify( rNEvt );
1623}
1624
1626{
1627 maActivateHdl.Call( this );
1628}
1629
1631{
1632 return !maDeactivateHdl.IsSet() || maDeactivateHdl.Call( this );
1633}
1634
1636{
1638
1639 Size aNewSize( rSize );
1640 aNewSize.AdjustWidth(TAB_OFFSET*2 );
1642 aNewSize.Width(), aNewSize.Height() );
1643 aNewSize.AdjustHeight(aRect.Top()+TAB_OFFSET );
1644 Window::SetOutputSizePixel( aNewSize );
1645}
1646
1647void TabControl::InsertPage( sal_uInt16 nPageId, const OUString& rText,
1648 sal_uInt16 nPos )
1649{
1650 SAL_WARN_IF( !nPageId, "vcl", "TabControl::InsertPage(): PageId == 0" );
1652 "TabControl::InsertPage(): PageId already exists" );
1653
1654 // insert new page item
1655 ImplTabItem* pItem = nullptr;
1656 if( nPos == TAB_APPEND || size_t(nPos) >= mpTabCtrlData->maItemList.size() )
1657 {
1658 mpTabCtrlData->maItemList.emplace_back(nPageId);
1659 pItem = &mpTabCtrlData->maItemList.back();
1660 if( mpTabCtrlData->mpListBox )
1661 mpTabCtrlData->mpListBox->InsertEntry( rText );
1662 }
1663 else
1664 {
1665 std::vector< ImplTabItem >::iterator new_it =
1666 mpTabCtrlData->maItemList.emplace(mpTabCtrlData->maItemList.begin() + nPos, nPageId);
1667 pItem = &(*new_it);
1668 if( mpTabCtrlData->mpListBox )
1669 mpTabCtrlData->mpListBox->InsertEntry( rText, nPos);
1670 }
1671 if( mpTabCtrlData->mpListBox )
1672 {
1673 if( ! mnCurPageId )
1674 mpTabCtrlData->mpListBox->SelectEntryPos( 0 );
1675 mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() );
1676 }
1677
1678 // set current page id
1679 if ( !mnCurPageId )
1681
1682 // init new page item
1683 pItem->maText = rText;
1684 pItem->mbFullVisible = false;
1685
1686 mbFormat = true;
1687 if ( IsUpdateMode() )
1688 Invalidate();
1689
1691 if( mpTabCtrlData->mpListBox ) // reposition/resize listbox
1692 Resize();
1693
1694 CallEventListeners( VclEventId::TabpageInserted, reinterpret_cast<void*>(nPageId) );
1695}
1696
1697void TabControl::RemovePage( sal_uInt16 nPageId )
1698{
1699 sal_uInt16 nPos = GetPagePos( nPageId );
1700
1701 // does the item exist ?
1702 if ( nPos == TAB_PAGE_NOTFOUND )
1703 return;
1704
1705 //remove page item
1706 std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin() + nPos;
1707 bool bIsCurrentPage = (it->id() == mnCurPageId);
1708 mpTabCtrlData->maItemList.erase( it );
1709 if( mpTabCtrlData->mpListBox )
1710 {
1711 mpTabCtrlData->mpListBox->RemoveEntry( nPos );
1712 mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() );
1713 }
1714
1715 // If current page is removed, then first page gets the current page
1716 if ( bIsCurrentPage )
1717 {
1718 mnCurPageId = 0;
1719
1720 if( ! mpTabCtrlData->maItemList.empty() )
1721 {
1722 // don't do this by simply setting mnCurPageId to pFirstItem->id()
1723 // this leaves a lot of stuff (such trivia as _showing_ the new current page) undone
1724 // instead, call SetCurPageId
1725 // without this, the next (outside) call to SetCurPageId with the id of the first page
1726 // will result in doing nothing (as we assume that nothing changed, then), and the page
1727 // will never be shown.
1728 // 86875 - 05/11/2001 - frank.schoenheit@germany.sun.com
1729
1730 SetCurPageId(mpTabCtrlData->maItemList[0].id());
1731 }
1732 }
1733
1734 mbFormat = true;
1735 if ( IsUpdateMode() )
1736 Invalidate();
1737
1739
1740 CallEventListeners( VclEventId::TabpageRemoved, reinterpret_cast<void*>(nPageId) );
1741}
1742
1743void TabControl::SetPageEnabled( sal_uInt16 i_nPageId, bool i_bEnable )
1744{
1745 ImplTabItem* pItem = ImplGetItem( i_nPageId );
1746
1747 if (!pItem || pItem->m_bEnabled == i_bEnable)
1748 return;
1749
1750 pItem->m_bEnabled = i_bEnable;
1751 if (!pItem->m_bVisible)
1752 return;
1753
1754 mbFormat = true;
1755 if( mpTabCtrlData->mpListBox )
1756 mpTabCtrlData->mpListBox->SetEntryFlags( GetPagePos( i_nPageId ),
1758
1759 // SetCurPageId will change to a valid page
1760 if (pItem->id() == mnCurPageId)
1762 else if ( IsUpdateMode() )
1763 Invalidate();
1764}
1765
1766void TabControl::SetPageVisible( sal_uInt16 nPageId, bool bVisible )
1767{
1768 ImplTabItem* pItem = ImplGetItem( nPageId );
1769 if (!pItem || pItem->m_bVisible == bVisible)
1770 return;
1771
1772 pItem->m_bVisible = bVisible;
1773 if (!bVisible)
1774 {
1775 if (pItem->mbFullVisible)
1776 mbSmallInvalidate = false;
1777 pItem->mbFullVisible = false;
1778 pItem->maRect.SetEmpty();
1779 }
1780 mbFormat = true;
1781
1782 // SetCurPageId will change to a valid page
1783 if (pItem->id() == mnCurPageId)
1785 else if (IsUpdateMode())
1786 Invalidate();
1787}
1788
1790{
1791 return static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size());
1792}
1793
1794sal_uInt16 TabControl::GetPageId( sal_uInt16 nPos ) const
1795{
1796 if( size_t(nPos) < mpTabCtrlData->maItemList.size() )
1797 return mpTabCtrlData->maItemList[nPos].id();
1798 return 0;
1799}
1800
1801sal_uInt16 TabControl::GetPagePos( sal_uInt16 nPageId ) const
1802{
1803 sal_uInt16 nPos = 0;
1804 for (auto const& item : mpTabCtrlData->maItemList)
1805 {
1806 if (item.id() == nPageId)
1807 return nPos;
1808 ++nPos;
1809 }
1810
1811 return TAB_PAGE_NOTFOUND;
1812}
1813
1814sal_uInt16 TabControl::GetPageId( const Point& rPos ) const
1815{
1817 const auto &rList = mpTabCtrlData->maItemList;
1818 const auto it = std::find_if(rList.begin(), rList.end(), [&rPos, &winSize, this](const auto &item) {
1819 return const_cast<TabControl*>(this)->ImplGetTabRect(&item, winSize.Width(), winSize.Height()).Contains(rPos); });
1820 return (it != rList.end()) ? it->id() : 0;
1821}
1822
1823sal_uInt16 TabControl::GetPageId( const OString& rName ) const
1824{
1825 const auto &rList = mpTabCtrlData->maItemList;
1826 const auto it = std::find_if(rList.begin(), rList.end(), [&rName](const auto &item) {
1827 return item.maTabName == rName; });
1828 return (it != rList.end()) ? it->id() : 0;
1829}
1830
1831void TabControl::SetCurPageId( sal_uInt16 nPageId )
1832{
1833 sal_uInt16 nPos = GetPagePos( nPageId );
1834 while (nPos != TAB_PAGE_NOTFOUND && !mpTabCtrlData->maItemList[nPos].m_bEnabled)
1835 {
1836 nPos++;
1837 if( size_t(nPos) >= mpTabCtrlData->maItemList.size() )
1838 nPos = 0;
1839 if (mpTabCtrlData->maItemList[nPos].id() == nPageId)
1840 break;
1841 }
1842
1843 if( nPos == TAB_PAGE_NOTFOUND )
1844 return;
1845
1846 nPageId = mpTabCtrlData->maItemList[nPos].id();
1847 if ( nPageId == mnCurPageId )
1848 {
1849 if ( mnActPageId )
1851 return;
1852 }
1853
1854 if ( mnActPageId )
1856 else
1857 {
1858 mbFormat = true;
1859 sal_uInt16 nOldId = mnCurPageId;
1861 ImplChangeTabPage( nPageId, nOldId );
1862 }
1863}
1864
1866{
1867 if ( mnActPageId )
1868 return mnActPageId;
1869 else
1870 return mnCurPageId;
1871}
1872
1873void TabControl::SelectTabPage( sal_uInt16 nPageId )
1874{
1875 if ( !nPageId || (nPageId == mnCurPageId) )
1876 return;
1877
1879
1881 if ( DeactivatePage() )
1882 {
1884 ActivatePage();
1885 // Page could have been switched by the Activate handler
1887 mnActPageId = 0;
1889 if( mpTabCtrlData->mpListBox )
1890 mpTabCtrlData->mpListBox->SelectEntryPos( GetPagePos( nPageId ) );
1891 CallEventListeners( VclEventId::TabpageActivate, reinterpret_cast<void*>(nPageId) );
1892 }
1893}
1894
1895void TabControl::SetTabPage( sal_uInt16 nPageId, TabPage* pTabPage )
1896{
1897 ImplTabItem* pItem = ImplGetItem( nPageId );
1898
1899 if ( !pItem || (pItem->mpTabPage.get() == pTabPage) )
1900 return;
1901
1902 if ( pTabPage )
1903 {
1904 if ( IsDefaultSize() )
1905 SetTabPageSizePixel( pTabPage->GetSizePixel() );
1906
1907 // only set here, so that Resize does not reposition TabPage
1908 pItem->mpTabPage = pTabPage;
1909 queue_resize();
1910
1911 if (pItem->id() == mnCurPageId)
1912 ImplChangeTabPage(pItem->id(), 0);
1913 }
1914 else
1915 {
1916 pItem->mpTabPage = nullptr;
1917 queue_resize();
1918 }
1919}
1920
1921TabPage* TabControl::GetTabPage( sal_uInt16 nPageId ) const
1922{
1923 ImplTabItem* pItem = ImplGetItem( nPageId );
1924
1925 if ( pItem )
1926 return pItem->mpTabPage;
1927 else
1928 return nullptr;
1929}
1930
1931void TabControl::SetPageText( sal_uInt16 nPageId, const OUString& rText )
1932{
1933 ImplTabItem* pItem = ImplGetItem( nPageId );
1934
1935 if ( !pItem || pItem->maText == rText )
1936 return;
1937
1938 pItem->maText = rText;
1939 mbFormat = true;
1940 if( mpTabCtrlData->mpListBox )
1941 {
1942 sal_uInt16 nPos = GetPagePos( nPageId );
1943 mpTabCtrlData->mpListBox->RemoveEntry( nPos );
1944 mpTabCtrlData->mpListBox->InsertEntry( rText, nPos );
1945 }
1946 if ( IsUpdateMode() )
1947 Invalidate();
1950}
1951
1952OUString const & TabControl::GetPageText( sal_uInt16 nPageId ) const
1953{
1954 ImplTabItem* pItem = ImplGetItem( nPageId );
1955
1956 assert( pItem );
1957
1958 return pItem->maText;
1959}
1960
1961void TabControl::SetHelpText( sal_uInt16 nPageId, const OUString& rText )
1962{
1963 ImplTabItem* pItem = ImplGetItem( nPageId );
1964
1965 assert( pItem );
1966
1967 pItem->maHelpText = rText;
1968}
1969
1970const OUString& TabControl::GetHelpText( sal_uInt16 nPageId ) const
1971{
1972 ImplTabItem* pItem = ImplGetItem( nPageId );
1973 assert( pItem );
1974 return pItem->maHelpText;
1975}
1976
1977void TabControl::SetAccessibleName(sal_uInt16 nPageId, const OUString& rName)
1978{
1979 ImplTabItem* pItem = ImplGetItem( nPageId );
1980 assert( pItem );
1981 pItem->maAccessibleName = rName;
1982}
1983
1984OUString TabControl::GetAccessibleName( sal_uInt16 nPageId ) const
1985{
1986 ImplTabItem* pItem = ImplGetItem( nPageId );
1987 assert( pItem );
1988 if (!pItem->maAccessibleName.isEmpty())
1989 return pItem->maAccessibleName;
1990 return removeMnemonicFromString(pItem->maText);
1991}
1992
1993void TabControl::SetAccessibleDescription(sal_uInt16 nPageId, const OUString& rDesc)
1994{
1995 ImplTabItem* pItem = ImplGetItem( nPageId );
1996 assert( pItem );
1997 pItem->maAccessibleDescription = rDesc;
1998}
1999
2000OUString TabControl::GetAccessibleDescription( sal_uInt16 nPageId ) const
2001{
2002 ImplTabItem* pItem = ImplGetItem( nPageId );
2003 assert( pItem );
2004 if (!pItem->maAccessibleDescription.isEmpty())
2005 return pItem->maAccessibleDescription;
2006 return pItem->maHelpText;
2007}
2008
2009void TabControl::SetPageName( sal_uInt16 nPageId, const OString& rName ) const
2010{
2011 ImplTabItem* pItem = ImplGetItem( nPageId );
2012
2013 if ( pItem )
2014 pItem->maTabName = rName;
2015}
2016
2017OString TabControl::GetPageName( sal_uInt16 nPageId ) const
2018{
2019 ImplTabItem* pItem = ImplGetItem( nPageId );
2020
2021 if (pItem)
2022 return pItem->maTabName;
2023
2024 return OString();
2025}
2026
2027void TabControl::SetPageImage( sal_uInt16 i_nPageId, const Image& i_rImage )
2028{
2029 ImplTabItem* pItem = ImplGetItem( i_nPageId );
2030
2031 if ( pItem )
2032 {
2033 pItem->maTabImage = i_rImage;
2034 mbFormat = true;
2035 if ( IsUpdateMode() )
2036 Invalidate();
2037 }
2038}
2039
2041{
2042 tools::Rectangle aRet;
2043
2044 if( !HasLayoutData() || mpTabCtrlData->maLayoutPageIdToLine.empty() )
2046
2047 if( HasLayoutData() )
2048 {
2049 std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( static_cast<int>(nPageId) );
2050 if( it != mpTabCtrlData->maLayoutPageIdToLine.end() )
2051 {
2052 Pair aPair = mxLayoutData->GetLineStartEnd( it->second );
2053 if( (aPair.B() - aPair.A()) >= nIndex )
2054 aRet = mxLayoutData->GetCharacterBounds( aPair.A() + nIndex );
2055 }
2056 }
2057
2058 return aRet;
2059}
2060
2061tools::Long TabControl::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const
2062{
2063 tools::Long nRet = -1;
2064
2065 if( !HasLayoutData() || mpTabCtrlData->maLayoutPageIdToLine.empty() )
2067
2068 if( HasLayoutData() )
2069 {
2070 int nIndex = mxLayoutData->GetIndexForPoint( rPoint );
2071 if( nIndex != -1 )
2072 {
2073 // what line (->pageid) is this index in ?
2074 int nLines = mxLayoutData->GetLineCount();
2075 int nLine = -1;
2076 while( ++nLine < nLines )
2077 {
2078 Pair aPair = mxLayoutData->GetLineStartEnd( nLine );
2079 if( aPair.A() <= nIndex && aPair.B() >= nIndex )
2080 {
2081 nRet = nIndex - aPair.A();
2082 rPageId = static_cast<sal_uInt16>(mpTabCtrlData->maLayoutLineToPageId[ nLine ]);
2083 break;
2084 }
2085 }
2086 }
2087 }
2088
2089 return nRet;
2090}
2091
2093{
2094 mpTabCtrlData->maLayoutLineToPageId.clear();
2095 mpTabCtrlData->maLayoutPageIdToLine.clear();
2096 const_cast<TabControl*>(this)->Invalidate();
2097}
2098
2100{
2101 tools::Rectangle aRet;
2102
2103 ImplTabItem* pItem = ImplGetItem( nPageId );
2104 if (pItem && pItem->m_bVisible)
2105 aRet = pItem->maRect;
2106
2107 return aRet;
2108}
2109
2110Size TabControl::ImplCalculateRequisition(sal_uInt16& nHeaderHeight) const
2111{
2112 Size aOptimalPageSize(0, 0);
2113
2114 sal_uInt16 nOrigPageId = GetCurPageId();
2115 for (auto const& item : mpTabCtrlData->maItemList)
2116 {
2117 const TabPage *pPage = item.mpTabPage;
2118 //it's a real nuisance if the page is not inserted yet :-(
2119 //We need to force all tabs to exist to get overall optimal size for dialog
2120 if (!pPage)
2121 {
2122 TabControl *pThis = const_cast<TabControl*>(this);
2123 pThis->SetCurPageId(item.id());
2124 pThis->ActivatePage();
2125 pPage = item.mpTabPage;
2126 }
2127
2128 if (!pPage)
2129 continue;
2130
2131 Size aPageSize(VclContainer::getLayoutRequisition(*pPage));
2132
2133 if (aPageSize.Width() > aOptimalPageSize.Width())
2134 aOptimalPageSize.setWidth( aPageSize.Width() );
2135 if (aPageSize.Height() > aOptimalPageSize.Height())
2136 aOptimalPageSize.setHeight( aPageSize.Height() );
2137 }
2138
2139 //fdo#61940 If we were forced to activate pages in order to on-demand
2140 //create them to get their optimal size, then switch back to the original
2141 //page and re-activate it
2142 if (nOrigPageId != GetCurPageId())
2143 {
2144 TabControl *pThis = const_cast<TabControl*>(this);
2145 pThis->SetCurPageId(nOrigPageId);
2146 pThis->ActivatePage();
2147 }
2148
2149 tools::Long nTabLabelsBottom = 0, nTabLabelsRight = 0;
2150 if (mbShowTabs)
2151 {
2152 for (sal_uInt16 nPos(0), sizeList(static_cast <sal_uInt16> (mpTabCtrlData->maItemList.size()));
2153 nPos < sizeList; ++nPos)
2154 {
2155 TabControl* pThis = const_cast<TabControl*>(this);
2156
2157 tools::Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX);
2158 if (aTabRect.Bottom() > nTabLabelsBottom)
2159 {
2160 nTabLabelsBottom = aTabRect.Bottom();
2161 nHeaderHeight = nTabLabelsBottom;
2162 }
2163 if (!aTabRect.IsEmpty() && aTabRect.Right() > nTabLabelsRight)
2164 nTabLabelsRight = aTabRect.Right();
2165 }
2166 }
2167
2168 Size aOptimalSize(aOptimalPageSize);
2169 aOptimalSize.AdjustHeight(nTabLabelsBottom );
2170 aOptimalSize.setWidth( std::max(nTabLabelsRight, aOptimalSize.Width()) );
2171
2172 aOptimalSize.AdjustWidth(TAB_OFFSET * 2 );
2173 aOptimalSize.AdjustHeight(TAB_OFFSET * 2 );
2174
2175 return aOptimalSize;
2176}
2177
2179{
2180 sal_uInt16 nHeaderHeight;
2181 return ImplCalculateRequisition(nHeaderHeight);
2182}
2183
2185{
2186 return calculateRequisition();
2187}
2188
2190{
2191 mbLayoutDirty = true;
2192 Window::queue_resize(eReason);
2193}
2194
2195std::vector<sal_uInt16> TabControl::GetPageIDs() const
2196{
2197 std::vector<sal_uInt16> aIDs;
2198 for (auto const& item : mpTabCtrlData->maItemList)
2199 {
2200 aIDs.push_back(item.id());
2201 }
2202
2203 return aIDs;
2204}
2205
2206bool TabControl::set_property(const OString &rKey, const OUString &rValue)
2207{
2208 if (rKey == "show-tabs")
2209 {
2210 mbShowTabs = toBool(rValue);
2211 queue_resize();
2212 }
2213 else
2214 return Control::set_property(rKey, rValue);
2215 return true;
2216}
2217
2219{
2221}
2222
2224{
2225 rJsonWriter.put("id", get_id());
2226 rJsonWriter.put("type", "tabcontrol");
2227 rJsonWriter.put("selected", GetCurPageId());
2228
2229 {
2230 auto childrenNode = rJsonWriter.startArray("children");
2231 for (auto id : GetPageIDs())
2232 {
2233 TabPage* pChild = GetTabPage(id);
2234
2235 if (pChild)
2236 {
2237 auto childNode = rJsonWriter.startStruct();
2238 pChild->DumpAsPropertyTree(rJsonWriter);
2239
2240 if (!pChild->IsVisible())
2241 rJsonWriter.put("hidden", true);
2242 }
2243 }
2244 }
2245 {
2246 auto tabsNode = rJsonWriter.startArray("tabs");
2247 for(auto id : GetPageIDs())
2248 {
2249 auto tabNode = rJsonWriter.startStruct();
2250 rJsonWriter.put("text", GetPageText(id));
2251 rJsonWriter.put("id", id);
2252 rJsonWriter.put("name", GetPageName(id));
2253 }
2254 }
2255}
2256
2257sal_uInt16 NotebookbarTabControlBase::m_nHeaderHeight = 0;
2258
2259IMPL_LINK_NOARG(NotebookbarTabControlBase, OpenMenu, Button*, void)
2260{
2261 m_aIconClickHdl.Call(static_cast<NotebookBar*>(GetParent()->GetParent()));
2262}
2263
2264NotebookbarTabControlBase::NotebookbarTabControlBase(vcl::Window* pParent)
2265 : TabControl(pParent, WB_STDTABCONTROL)
2266 , bLastContextWasSupported(true)
2267 , eLastContext(vcl::EnumContext::Context::Any)
2268{
2269 m_pOpenMenu = VclPtr<PushButton>::Create( this , WB_CENTER | WB_VCENTER );
2270 m_pOpenMenu->SetClickHdl(LINK(this, NotebookbarTabControlBase, OpenMenu));
2271 m_pOpenMenu->SetModeImage(Image(StockImage::Yes, SV_RESID_BITMAP_NOTEBOOKBAR));
2272 m_pOpenMenu->SetSizePixel(m_pOpenMenu->GetOptimalSize());
2273 m_pOpenMenu->Show();
2274}
2275
2276NotebookbarTabControlBase::~NotebookbarTabControlBase()
2277{
2278 disposeOnce();
2279}
2280
2281void NotebookbarTabControlBase::SetContext( vcl::EnumContext::Context eContext )
2282{
2283 if (eLastContext == eContext)
2284 return;
2285
2286 bool bHandled = false;
2287
2288 for (int nChild = 0; nChild < GetPageCount(); ++nChild)
2289 {
2290 sal_uInt16 nPageId = TabControl::GetPageId(nChild);
2291 TabPage* pPage = GetTabPage(nPageId);
2292
2293 if (pPage)
2294 {
2295 SetPageVisible(nPageId, pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Any));
2296
2297 if (!bHandled && bLastContextWasSupported
2298 && pPage->HasContext(vcl::EnumContext::Context::Default))
2299 {
2300 SetCurPageId(nPageId);
2301 }
2302
2303 if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Any)
2304 {
2305 SetCurPageId(nPageId);
2306 bHandled = true;
2307 bLastContextWasSupported = true;
2308 }
2309 }
2310 }
2311
2312 if (!bHandled)
2313 bLastContextWasSupported = false;
2314 eLastContext = eContext;
2315}
2316
2317void NotebookbarTabControlBase::dispose()
2318{
2319 m_pShortcuts.disposeAndClear();
2320 m_pOpenMenu.disposeAndClear();
2322}
2323
2324void NotebookbarTabControlBase::SetToolBox( ToolBox* pToolBox )
2325{
2326 m_pShortcuts.set( pToolBox );
2327}
2328
2329void NotebookbarTabControlBase::SetIconClickHdl( Link<NotebookBar*, void> aHdl )
2330{
2331 m_aIconClickHdl = aHdl;
2332}
2333
2334static bool lcl_isValidPage(const ImplTabItem& rItem, bool& bFound)
2335{
2336 if (rItem.m_bVisible && rItem.m_bEnabled)
2337 bFound = true;
2338 return bFound;
2339}
2340
2341void NotebookbarTabControlBase::ImplActivateTabPage( bool bNext )
2342{
2343 const sal_uInt16 nOldPos = GetPagePos(GetCurPageId());
2344 bool bFound = false;
2345 sal_Int32 nCurPos = nOldPos;
2346
2347 if (bNext)
2348 {
2349 for (nCurPos++; nCurPos < GetPageCount(); nCurPos++)
2350 if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos], bFound))
2351 break;
2352 }
2353 else
2354 {
2355 for (nCurPos--; nCurPos >= 0; nCurPos--)
2356 if (lcl_isValidPage(mpTabCtrlData->maItemList[nCurPos], bFound))
2357 break;
2358 }
2359
2360 if (!bFound)
2361 nCurPos = nOldPos;
2362 SelectTabPage( TabControl::GetPageId( nCurPos ) );
2363}
2364
2365sal_uInt16 NotebookbarTabControlBase::GetHeaderHeight()
2366{
2367 return m_nHeaderHeight;
2368}
2369
2370bool NotebookbarTabControlBase::ImplPlaceTabs( tools::Long nWidth )
2371{
2372 if ( nWidth <= 0 )
2373 return false;
2374 if ( mpTabCtrlData->maItemList.empty() )
2375 return false;
2376 if (!m_pOpenMenu || m_pOpenMenu->isDisposed())
2377 return false;
2378
2379 const tools::Long nHamburgerWidth = m_pOpenMenu->GetSizePixel().Width();
2380 tools::Long nMaxWidth = nWidth - nHamburgerWidth;
2381 tools::Long nShortcutsWidth = m_pShortcuts != nullptr ? m_pShortcuts->GetSizePixel().getWidth() + 1 : 0;
2382 tools::Long nFullWidth = nShortcutsWidth;
2383
2384 const tools::Long nOffsetX = 2 + nShortcutsWidth;
2385 const tools::Long nOffsetY = 2;
2386
2387 //fdo#66435 throw Knuth/Tex minimum raggedness algorithm at the problem
2388 //of ugly bare tabs on lines of their own
2389
2390 for (auto & item : mpTabCtrlData->maItemList)
2391 {
2392 tools::Long nTabWidth = 0;
2393 if (item.m_bVisible)
2394 {
2395 nTabWidth = ImplGetItemSize(&item, nMaxWidth).getWidth();
2396 if (!item.maText.isEmpty() && nTabWidth < 100)
2397 nTabWidth = 100;
2398 }
2399 nFullWidth += nTabWidth;
2400 }
2401
2402 tools::Long nX = nOffsetX;
2403 tools::Long nY = nOffsetY;
2404
2405 tools::Long nLineWidthAry[100];
2406 nLineWidthAry[0] = 0;
2407
2408 for (auto & item : mpTabCtrlData->maItemList)
2409 {
2410 if (!item.m_bVisible)
2411 continue;
2412
2413 Size aSize = ImplGetItemSize( &item, nMaxWidth );
2414
2415 // set minimum tab size
2416 if( nFullWidth < nMaxWidth && !item.maText.isEmpty() && aSize.getWidth() < 100)
2417 aSize.setWidth( 100 );
2418
2419 if( !item.maText.isEmpty() && aSize.getHeight() < 28 )
2420 aSize.setHeight( 28 );
2421
2422 tools::Rectangle aNewRect( Point( nX, nY ), aSize );
2423 if ( mbSmallInvalidate && (item.maRect != aNewRect) )
2424 mbSmallInvalidate = false;
2425
2426 item.maRect = aNewRect;
2427 item.mnLine = 0;
2428 item.mbFullVisible = true;
2429
2430 nLineWidthAry[0] += aSize.Width();
2431 nX += aSize.Width();
2432 }
2433
2434 // we always have only one line of tabs
2435 lcl_AdjustSingleLineTabs(nMaxWidth, mpTabCtrlData.get());
2436
2437 // position the shortcutbox
2438 if (m_pShortcuts)
2439 {
2440 tools::Long nPosY = (m_nHeaderHeight - m_pShortcuts->GetSizePixel().getHeight()) / 2;
2441 m_pShortcuts->SetPosPixel(Point(0, nPosY));
2442 }
2443
2444 tools::Long nPosY = (m_nHeaderHeight - m_pOpenMenu->GetSizePixel().getHeight()) / 2;
2445 // position the menu
2446 m_pOpenMenu->SetPosPixel(Point(nWidth - nHamburgerWidth, nPosY));
2447
2448 return true;
2449}
2450
2451Size NotebookbarTabControlBase::calculateRequisition() const
2452{
2453 return TabControl::ImplCalculateRequisition(m_nHeaderHeight);
2454}
2455
2456Control* NotebookbarTabControlBase::GetOpenMenu()
2457{
2458 return m_pOpenMenu;
2459}
2460
2461/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
sal_Int32 nLineWidth
sal_uInt16 nPageId
static bool toBool(std::string_view rValue)
Definition: builder.cxx:92
const StyleSettings & GetStyleSettings() const
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
Definition: ctrl.hxx:82
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:84
SAL_DLLPRIVATE void ImplClearLayoutData() const
Definition: ctrl.cxx:327
tools::Rectangle DrawControlText(OutputDevice &_rTargetDevice, const tools::Rectangle &_rRect, const OUString &_rStr, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize=nullptr) const
draws the given text onto the given device
Definition: ctrl.cxx:429
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:226
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:257
bool HasLayoutData() const
determines whether we currently have layout data
Definition: ctrl.cxx:91
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:294
void ImplInitSettings()
Definition: ctrl.cxx:424
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:59
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
HelpEventMode GetMode() const
Definition: event.hxx:208
bool KeyboardActivated() const
Definition: event.hxx:209
const Point & GetMousePosPixel() const
Definition: event.hxx:207
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
Definition: help.cxx:157
Definition: image.hxx:40
Size GetSizePixel() const
Definition: Image.cxx:88
OString maTabName
Definition: tabctrl.cxx:58
sal_uInt16 id() const
Definition: tabctrl.cxx:68
ImplTabItem(sal_uInt16 nId)
Definition: tabctrl.cxx:71
sal_uInt16 mnLine
Definition: tabctrl.cxx:60
OUString maAccessibleName
Definition: tabctrl.cxx:56
bool mbFullVisible
Definition: tabctrl.cxx:61
bool m_bVisible
the tab / page can be visible
Definition: tabctrl.cxx:63
tools::Rectangle maRect
Definition: tabctrl.cxx:59
OUString maText
Definition: tabctrl.cxx:53
VclPtr< TabPage > mpTabPage
Definition: tabctrl.cxx:52
bool m_bEnabled
the tab / page is selectable
Definition: tabctrl.cxx:62
OUString maFormatText
Definition: tabctrl.cxx:54
OUString maHelpText
Definition: tabctrl.cxx:55
Image maTabImage
Definition: tabctrl.cxx:64
OUString maAccessibleDescription
Definition: tabctrl.cxx:57
sal_uInt16 m_nId
Definition: tabctrl.cxx:49
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:83
bool IsEnterWindow() const
Definition: event.hxx:138
bool IsSynthetic() const
Definition: event.hxx:142
bool IsLeaveWindow() const
Definition: event.hxx:140
sal_uInt16 GetButtons() const
Definition: event.hxx:147
const Point & GetPosPixel() const
Definition: event.hxx:123
bool IsModifierChanged() const
Definition: event.hxx:144
bool IsLeft() const
Definition: event.hxx:149
This implements Widget Layout-based notebook-like menu bar.
Definition: notebookbar.hxx:28
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:316
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:324
NotifyEventType GetType() const
Definition: event.hxx:308
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
virtual vcl::Region GetActiveClipRegion() const
tools::Long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
Definition: text.cxx:2306
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:161
void SetLineColor()
Definition: line.cxx:37
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void DrawPixel(const Point &rPt)
Definition: pixel.cxx:54
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Color & GetTextColor() const
Definition: outdev.hxx:1003
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:897
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
tools::Long A() const
tools::Long B() const
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:408
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetDarkShadowColor() const
const Color & GetShadowColor() const
StyleSettingsOptions GetOptions() const
const Color & GetTabRolloverTextColor() const
const Color & GetTabTextColor() const
const vcl::Font & GetTabFont() const
const Color & GetLightColor() const
const Color & GetDialogColor() const
const Color & GetTabHighlightTextColor() const
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual void FillLayoutData() const override
Definition: tabctrl.cxx:2092
bool mbShowTabs
Definition: tabctrl.hxx:60
sal_uInt16 GetPageCount() const
Definition: tabctrl.cxx:1789
bool mbRestoreHelpId
Definition: tabctrl.hxx:61
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: tabctrl.cxx:1615
void ActivatePage()
Definition: tabctrl.cxx:1625
tools::Long GetIndexForPoint(const Point &rPoint, sal_uInt16 &rPageId) const
Definition: tabctrl.cxx:2061
void SetPageName(sal_uInt16 nPageId, const OString &rName) const
Definition: tabctrl.cxx:2009
virtual Size calculateRequisition() const
Definition: tabctrl.cxx:2178
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: tabctrl.cxx:1393
tools::Rectangle GetTabBounds(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:2099
SAL_DLLPRIVATE Size ImplGetItemSize(ImplTabItem *pItem, tools::Long nMaxWidth)
Definition: tabctrl.cxx:227
virtual void GetFocus() override
Definition: tabctrl.cxx:1356
Link< TabControl *, bool > maDeactivateHdl
Definition: tabctrl.hxx:65
void setAllocation(const Size &rAllocation)
Definition: tabctrl.cxx:1266
std::vector< sal_uInt16 > GetPageIDs() const
Definition: tabctrl.cxx:2195
virtual void StateChanged(StateChangedType nType) override
Definition: tabctrl.cxx:1501
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: tabctrl.cxx:139
TabControl(vcl::Window *pParent, WinBits nStyle=WB_STDTABCONTROL)
Definition: tabctrl.cxx:189
sal_uInt16 mnCurPageId
Definition: tabctrl.hxx:58
void SetAccessibleDescription(sal_uInt16 nItemId, const OUString &rStr)
Definition: tabctrl.cxx:1993
void SetTabPage(sal_uInt16 nPageId, TabPage *pPage)
Definition: tabctrl.cxx:1895
virtual ~TabControl() override
Definition: tabctrl.cxx:196
SAL_DLLPRIVATE void ImplChangeTabPage(sal_uInt16 nId, sal_uInt16 nOldId)
Definition: tabctrl.cxx:623
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: tabctrl.cxx:134
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabctrl.cxx:1328
void SetAccessibleName(sal_uInt16 nItemId, const OUString &rStr)
Definition: tabctrl.cxx:1977
std::unique_ptr< ImplTabCtrlData > mpTabCtrlData
Definition: tabctrl.hxx:54
virtual void SetSizePixel(const Size &rNewSize) override
Definition: tabctrl.cxx:1336
virtual void Resize() override
Definition: tabctrl.cxx:1351
sal_uInt16 GetPagePos(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:1801
void SetPageVisible(sal_uInt16 nPageId, bool bVisible=true)
Definition: tabctrl.cxx:1766
SAL_DLLPRIVATE tools::Rectangle ImplGetTabRect(sal_uInt16 nPos, tools::Long nWidth=-1, tools::Long nHeight=-1)
Definition: tabctrl.cxx:552
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: tabctrl.cxx:201
SAL_DLLPRIVATE void ImplFreeLayoutData()
Definition: tabctrl.cxx:179
tools::Rectangle GetCharacterBounds(sal_uInt16 nPageId, tools::Long nIndex) const
Definition: tabctrl.cxx:2040
SAL_DLLPRIVATE Size ImplCalculateRequisition(sal_uInt16 &nHeaderHeight) const
Definition: tabctrl.cxx:2110
tools::Long mnLastWidth
Definition: tabctrl.hxx:55
TabPage * GetTabPage(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:1921
virtual void ImplActivateTabPage(bool bNext)
Definition: tabctrl.cxx:737
void SetPageEnabled(sal_uInt16 nPageId, bool bEnable=true)
Definition: tabctrl.cxx:1743
void SetCurPageId(sal_uInt16 nPageId)
Definition: tabctrl.cxx:1831
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: tabctrl.cxx:1047
void SetTabPageSizePixel(const Size &rSize)
Definition: tabctrl.cxx:1635
bool mbSmallInvalidate
Definition: tabctrl.hxx:62
virtual void SetPosPixel(const Point &rPos) override
Definition: tabctrl.cxx:1344
sal_uInt16 mnActPageId
Definition: tabctrl.hxx:57
virtual void LoseFocus() override
Definition: tabctrl.cxx:1386
SAL_DLLPRIVATE bool ImplPosCurTabPage()
Definition: tabctrl.cxx:717
virtual Size GetOptimalSize() const override
Definition: tabctrl.cxx:2184
void SelectTabPage(sal_uInt16 nPageId)
Definition: tabctrl.cxx:1873
bool mbLayoutDirty
Definition: tabctrl.hxx:63
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: tabctrl.cxx:1057
void SetPageImage(sal_uInt16 nPageId, const Image &rImage)
Definition: tabctrl.cxx:2027
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: tabctrl.cxx:91
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: tabctrl.cxx:1534
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: tabctrl.cxx:1086
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent &rKeyEvent)
Definition: tabctrl.cxx:996
void InsertPage(sal_uInt16 nPageId, const OUString &rText, sal_uInt16 nPos=TAB_APPEND)
Definition: tabctrl.cxx:1647
sal_uInt16 GetCurPageId() const
Definition: tabctrl.cxx:1865
SAL_DLLPRIVATE ImplTabItem * ImplGetItem(sal_uInt16 nId) const
Definition: tabctrl.cxx:216
OUString const & GetPageText(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:1952
virtual bool ImplPlaceTabs(tools::Long nWidth)
Definition: tabctrl.cxx:394
sal_uInt16 GetPageId(sal_uInt16 nPos) const
Definition: tabctrl.cxx:1794
SAL_DLLPRIVATE void ImplShowFocus()
Definition: tabctrl.cxx:754
void SetHelpText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabctrl.cxx:1961
bool mbFormat
Definition: tabctrl.hxx:59
virtual void Command(const CommandEvent &rCEvt) override
Definition: tabctrl.cxx:1463
Link< TabControl *, void > maActivateHdl
Definition: tabctrl.hxx:64
OString GetPageName(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:2017
void SetPageText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabctrl.cxx:1931
tools::Long mnLastHeight
Definition: tabctrl.hxx:56
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: tabctrl.cxx:1566
void ImplInitSettings()
Definition: ctrl.cxx:424
virtual FactoryFunction GetUITestFactory() const override
Definition: tabctrl.cxx:2218
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: tabctrl.cxx:2206
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: tabctrl.cxx:2223
bool DeactivatePage()
Definition: tabctrl.cxx:1630
SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext &rRenderContext, ImplTabItem const *pItem, const tools::Rectangle &rCurRect, bool bFirstInGroup, bool bLastInGroup)
Definition: tabctrl.cxx:804
void RemovePage(sal_uInt16 nPageId)
Definition: tabctrl.cxx:1697
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: tabctrl.cxx:2189
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabpage.cxx:198
static int m_nOverlap
TabitemFlags mnAlignment
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
static Size getLayoutRequisition(const vcl::Window &rWindow)
Definition: layout.cxx:170
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
bool mbUseNativeFocus
Definition: window.h:361
void put(const char *pPropName, const OUString &rPropValue)
ScopedJsonWriterArray startArray(const char *)
ScopedJsonWriterStruct startStruct()
constexpr Point Center() const
bool Contains(const Point &rPOINT) const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
void SetTransparent(bool bTransparent)
Definition: font/font.cxx:125
bool IsMod1() const
Definition: keycod.hxx:56
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
bool IsShift() const
Definition: keycod.hxx:54
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:583
bool IsEmpty() const
Definition: region.cxx:229
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:507
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2810
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2080
bool IsReallyVisible() const
Definition: window2.cxx:1138
virtual void GetFocus()
Definition: window.cxx:1845
vcl::Window * GetParent() const
Definition: window2.cxx:1128
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1873
SAL_DLLPRIVATE vcl::Window * ImplGetDlgWindow(sal_uInt16 n, GetDlgWindowType nType, sal_uInt16 nStart=0, sal_uInt16 nEnd=0xFFFF, sal_uInt16 *pIndex=nullptr)
Definition: dlgctrl.cxx:205
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3011
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
bool IsMouseOver() const
Definition: mouse.cxx:620
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3936
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1927
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void HideFocus()
Definition: window2.cxx:95
void GrabFocus()
Definition: window.cxx:2983
bool IsUpdateMode() const
Definition: window2.cxx:1204
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1058
bool HasFocus() const
Definition: window.cxx:2988
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
Point GetLastPointerPosPixel()
Definition: mouse.cxx:576
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
WinBits GetStyle() const
Definition: window2.cxx:984
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2191
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1809
bool IsReallyShown() const
Definition: window2.cxx:1143
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
const OString & GetHelpId() const
Definition: window2.cxx:854
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
bool IsDialog() const
Definition: window2.cxx:1033
Window(WindowType nType)
Definition: window.cxx:95
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
const vcl::Font & GetFont() const
Definition: window3.cxx:58
void Hide()
Definition: window.hxx:885
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
void SetHelpId(const OString &)
Definition: window2.cxx:849
void AddChildEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:323
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:53
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3365
virtual Size GetSizePixel() const
Definition: window.cxx:2406
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1118
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
Point GetPointerPosPixel()
Definition: mouse.cxx:564
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1483
virtual void LoseFocus()
Definition: window.cxx:1859
const Color & GetControlBackground() const
Definition: window2.cxx:1113
OUString GetAccessibleName() const
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
bool IsVisible() const
Definition: window2.cxx:1133
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
bool IsDefaultSize() const
Definition: window2.cxx:1184
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2816
void RemoveChildEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:328
OUString GetAccessibleDescription() const
bool IsEnabled() const
Definition: window2.cxx:1153
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:942
const OUString & GetHelpText() const
Definition: window.cxx:3097
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1053
SAL_DLLPRIVATE void ImplControlFocus(GetFocusFlags nFlags=GetFocusFlags::NONE)
Definition: dlgctrl.cxx:516
void SetBackground()
Definition: window3.cxx:100
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
virtual void SetCurPageId(const OString &rName) override
float u
sal_Int32 nState
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
const sal_uInt16 idx[]
sal_Int32 nIndex
sal_Int64 n
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
constexpr sal_uInt16 KEY_TAB
Definition: keycodes.hxx:121
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
sal_uInt16 nPos
const long LONG_MAX
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
@ DrawDisabled
this flags lets the item be drawn disabled (e.g.
@ DisableSelection
this flag disables a selection of an entry completely.
aStr
static std::deque< size_t > GetEndOfLineIndexes(const std::vector< sal_Int32 > &rWidthsOf, sal_Int32 nLineWidth)
Definition: tabctrl.cxx:298
int i
long Long
sal_Int16 nId
QPRO_FUNC_TYPE nType
ImplSVNWFData maNWFData
Definition: svdata.hxx:407
bool mbNoFocusRects
Definition: svdata.hxx:329
VclPtr< ListBox > mpListBox
Definition: tabctrl.cxx:85
std::unordered_map< int, int > maLayoutLineToPageId
Definition: tabctrl.cxx:83
std::unordered_map< int, int > maLayoutPageIdToLine
Definition: tabctrl.cxx:82
std::vector< ImplTabItem > maItemList
Definition: tabctrl.cxx:84
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
IMPL_LINK_NOARG(TabControl, ImplListBoxSelectHdl, ListBox &, void)
Definition: tabctrl.cxx:1029
static bool lcl_canPaint(const vcl::RenderContext &rRenderContext, const tools::Rectangle &rDrawRect, const tools::Rectangle &rItemRect)
Definition: tabctrl.cxx:1076
#define TAB_PAGERECT
Definition: tabctrl.cxx:89
IMPL_LINK(TabControl, ImplWindowEventListener, VclWindowEvent &, rEvent, void)
Definition: tabctrl.cxx:1034
static bool lcl_isValidPage(const ImplTabItem &rItem, bool &bFound)
Definition: tabctrl.cxx:2334
static void lcl_AdjustSingleLineTabs(tools::Long nMaxWidth, ImplTabCtrlData *pTabCtrlData)
Definition: tabctrl.cxx:371
#define TAB_APPEND
Definition: tabctrl.hxx:38
#define TAB_PAGE_NOTFOUND
Definition: tabctrl.hxx:39
#define TAB_EXTRASPACE_X
Definition: tabctrl.hxx:45
#define TAB_BORDER_LEFT
Definition: tabctrl.hxx:46
#define TAB_BORDER_RIGHT
Definition: tabctrl.hxx:48
#define TAB_TABOFFSET_Y
Definition: tabctrl.hxx:44
#define TAB_OFFSET
Definition: tabctrl.hxx:42
#define TAB_BORDER_TOP
Definition: tabctrl.hxx:47
#define TAB_TABOFFSET_X
Definition: tabctrl.hxx:43
#define TAB_BORDER_BOTTOM
Definition: tabctrl.hxx:49
OUString removeMnemonicFromString(OUString const &rStr)
bool bVisible
#define SAL_MAX_INT32
@ TabpagePageTextChanged
StateChangedType
Definition: window.hxx:291
@ NoChildren
The child windows are not invalidated.
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_VCENTER
Definition: wintypes.hxx:150
WinBits const WB_DIALOGCONTROL
Definition: wintypes.hxx:113
WinBits const WB_CENTER
Definition: wintypes.hxx:147
WinBits const WB_DROPDOWN
Definition: wintypes.hxx:159
WinBits const WB_STDTABCONTROL
Definition: wintypes.hxx:219
WindowType
Definition: wintypes.hxx:27
WinBits const WB_NOTABSTOP
Definition: wintypes.hxx:141
WinBits const WB_GROUP
Definition: wintypes.hxx:142
WinBits const WB_NOGROUP
Definition: wintypes.hxx:143
WinBits const WB_NODIALOGCONTROL
Definition: wintypes.hxx:114
WinBits const WB_TABSTOP
Definition: wintypes.hxx:140
WinBits const WB_NOBORDER
Definition: wintypes.hxx:116