Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ToolDock Class Referencefinal

A dynamic panel where a ToolBar can be docked. More...

#include <ToolDock.h>

Inheritance diagram for ToolDock:
[legend]
Collaboration diagram for ToolDock:
[legend]

Classes

class  LayoutVisitor
 

Public Member Functions

 ToolDock (wxEvtHandler *manager, wxWindow *parent, int dockid)
 Methods for ToolDock. More...
 
 ~ToolDock ()
 
bool AcceptsFocus () const override
 
void LoadConfig ()
 
void LayoutToolBars ()
 
void Expose (int type, bool show)
 
int GetOrder (ToolBar *bar)
 
void Dock (ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
 
void Undock (ToolBar *bar)
 
ToolBarConfiguration::Position PositionBar (ToolBar *t, const wxPoint &pos, wxRect &rect)
 
ToolBarConfigurationGetConfiguration ()
 
void WrapConfiguration (ToolBarConfiguration &backup)
 
void RestoreConfiguration (ToolBarConfiguration &backup)
 
void Updated ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Protected Member Functions

void OnErase (wxEraseEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnGrabber (GrabberEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 

Private Member Functions

void VisitLayout (LayoutVisitor &visitor, ToolBarConfiguration *pWrappedConfiguration=nullptr)
 

Private Attributes

wxEvtHandler * mManager
 
ToolBarConfiguration mConfiguration
 
ToolBarConfiguration mWrappedConfiguration
 
ToolBarmBars [ToolBarCount]
 

Detailed Description

A dynamic panel where a ToolBar can be docked.

Definition at line 289 of file ToolDock.h.

Constructor & Destructor Documentation

◆ ToolDock()

ToolDock::ToolDock ( wxEvtHandler *  manager,
wxWindow *  parent,
int  dockid 
)

Methods for ToolDock.

Definition at line 378 of file ToolDock.cpp.

378 :
379 wxPanelWrapper( parent, dockid, wxDefaultPosition, parent->GetSize() )
380{
381 SetLabel( XO( "ToolDock" ) );
382 SetName( XO( "ToolDock" ) );
383
384 // Init
386 memset(mBars, 0, sizeof(mBars)); // otherwise uninitialized
387 SetBackgroundColour(theTheme.Colour( clrMedium ));
388 SetLayoutDirection(wxLayout_LeftToRight);
389 // Use for testing gaps
390 // SetOwnBackgroundColour( wxColour( 255, 0, 0 ) );
391}
#define XO(s)
Definition: Internat.h:31
static const AttachedProjectObjects::RegisteredFactory manager
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)
ToolBar * mBars[ToolBarCount]
Definition: ToolDock.h:343
wxEvtHandler * mManager
Definition: ToolDock.h:335
void SetLabel(const TranslatableString &label)

References ThemeBase::Colour(), manager, theTheme, and XO.

Here is the call graph for this function:

◆ ~ToolDock()

ToolDock::~ToolDock ( )

Definition at line 396 of file ToolDock.cpp.

397{
398}

Member Function Documentation

◆ AcceptsFocus()

bool ToolDock::AcceptsFocus ( ) const
inlineoverride

Definition at line 296 of file ToolDock.h.

296{ return false; };

◆ Dock()

void ToolDock::Dock ( ToolBar bar,
bool  deflate,
ToolBarConfiguration::Position  ndx = ToolBarConfiguration::UnspecifiedPosition 
)

Definition at line 415 of file ToolDock.cpp.

416{
417#ifndef __WXMAC__
418 // Apply the deflate fix only on Mac, else you introduce the opposite bug on others
419 deflate = false;
420#endif
421
422 // Adopt the toolbar into our family
423 bar->Reparent( this );
424 mBars[ bar->GetId() ] = bar;
425
426 // Reset size
427 bar->SetSize(
428 // Undo the expansion that was applied when un-docking
429 bar->GetSize().x - (deflate ? 2 * ToolBarFloatMargin : 0),
430 // Don't need to adjust y the same way.
431 bar->GetDockedSize().y
432 );
433
434 // Park the NEW bar in the correct berth
435 if (!mConfiguration.Contains(bar) && bar->IsVisible())
436 mConfiguration.Insert( bar, position );
437
438 // Inform toolbar of change
439 bar->SetDocked( this, false );
440}
@ ToolBarFloatMargin
Definition: ToolBar.h:94
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:233
void Insert(ToolBar *bar, Position position=UnspecifiedPosition)
Definition: ToolDock.cpp:98
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:638
bool IsVisible() const
Definition: ToolBar.cpp:431
virtual wxSize GetDockedSize()
Definition: ToolBar.h:148
ToolBarConfiguration mConfiguration
Definition: ToolDock.h:338

References ToolBarConfiguration::Contains(), ToolBar::GetDockedSize(), ToolBarConfiguration::Insert(), ToolBar::IsVisible(), mBars, mConfiguration, ToolBar::SetDocked(), and ToolBarFloatMargin.

Referenced by ToolManager::HandleEscapeKey(), LoadConfig(), ToolManager::OnMouse(), ToolManager::ReadConfig(), and ToolManager::Reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expose()

void ToolDock::Expose ( int  type,
bool  show 
)

Definition at line 834 of file ToolDock.cpp.

835{
836 ToolBar *t = mBars[ type ];
837
838 // Maintain the docked array
839 const auto shown = mConfiguration.Shows( t );
840 if( show && !shown )
841 mConfiguration.Show( t );
842 else if( !show && shown )
843 mConfiguration.Hide( t );
844
845 // Make it (dis)appear
846 t->Expose( show );
847}
void Show(ToolBar *bar)
Definition: ToolDock.cpp:224
bool Shows(const ToolBar *bar) const
Definition: ToolDock.h:246
void Hide(ToolBar *bar)
Definition: ToolDock.cpp:231
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:101
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:444

References ToolBar::Expose(), ToolBarConfiguration::Hide(), mBars, mConfiguration, ToolBarConfiguration::Show(), and ToolBarConfiguration::Shows().

Referenced by ToolManager::Expose(), and LoadConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetConfiguration()

ToolBarConfiguration & ToolDock::GetConfiguration ( )
inline

Definition at line 309 of file ToolDock.h.

310 { return mConfiguration; }

References mConfiguration.

Referenced by ToolManager::Destroy(), LayoutToolBars(), LoadConfig(), ToolManager::OnGrabber(), ToolManager::OnMouse(), OnPaint(), ToolManager::ReadConfig(), VisitLayout(), and ToolManager::WriteConfig().

Here is the caller graph for this function:

◆ GetOrder()

int ToolDock::GetOrder ( ToolBar bar)

◆ LayoutToolBars()

void ToolDock::LayoutToolBars ( )

Definition at line 663 of file ToolDock.cpp.

664{
665 struct SizeSetter final : public LayoutVisitor
666 {
667 SizeSetter (ToolDock *d) : dock{ d } {}
668
669 void Visit
670 (ToolBar *bar, wxPoint point)
671 override
672 {
673 // Place the toolbar
674 if(bar)
675 bar->SetPosition( point );
676 }
677
678 bool ShouldVisitSpaces() override
679 {
680 return false;
681 }
682
683 virtual void FinalRect
684 (const wxRect &rect, ToolBarConfiguration::Position)
685 override
686 {
687 // Set the final size of the dock window
688 dock->SetMinSize( rect.GetSize() );
689 }
690
691 ToolDock *dock;
692 } sizeSetter {
693 this
694 };
696
697 // Set tab order and layout internal controls.
698 {
699 ToolBar *lt{};
700 for ( const auto &place : GetConfiguration() ) {
701 auto ct = place.pTree->pBar;
702 if( lt ){
703 ct->MoveAfterInTabOrder( lt );
704 }
705 lt = ct;
706 // Bug 1371.
707 // After a dock size change, the toolbars may need relaying inside.
708 lt->Layout();
709 }
710 }
711
712 // Clean things up
713 Refresh( false );
714}
auto Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: MemoryX.h:611
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
ToolBarConfiguration mWrappedConfiguration
Definition: ToolDock.h:341
void VisitLayout(LayoutVisitor &visitor, ToolBarConfiguration *pWrappedConfiguration=nullptr)
Definition: ToolDock.cpp:482
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:309

References GetConfiguration(), mWrappedConfiguration, Visit(), and VisitLayout().

Referenced by ToolManager::LayoutToolBars().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadConfig()

void ToolDock::LoadConfig ( )

Definition at line 443 of file ToolDock.cpp.

444{
445 // Add all ordered toolbars
446 for(const auto &place : GetConfiguration()) {
447 auto bar = place.pTree->pBar;
448 this->Dock(bar, false);
449 // Show it -- hidden bars are not (yet) ever saved as part of a
450 // configuration
451 Expose( bar->GetId(), true );
452 }
453 Updated();
454}
void Updated()
Definition: ToolDock.cpp:853
void Expose(int type, bool show)
Definition: ToolDock.cpp:834
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:415

References Dock(), Expose(), GetConfiguration(), and Updated().

Referenced by ToolManager::ReadConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnErase()

void ToolDock::OnErase ( wxEraseEvent &  event)
protected

Definition at line 883 of file ToolDock.cpp.

884{
885 // Ignore it to prevent flashing
886}

◆ OnGrabber()

void ToolDock::OnGrabber ( GrabberEvent event)
protected

Definition at line 863 of file ToolDock.cpp.

864{
865 // auto pos = event.GetPosition();
866 if (!event.IsEscaping()) {
867 // Pass it on to the manager since it isn't in the handling hierarchy
868 mManager->ProcessEvent( event );
869 }
870}
bool IsEscaping() const
Definition: Grabber.h:74

References GrabberEvent::IsEscaping(), and mManager.

Here is the call graph for this function:

◆ OnMouseEvents()

void ToolDock::OnMouseEvents ( wxMouseEvent &  event)
protected

Definition at line 944 of file ToolDock.cpp.

945{
946 // Do this hack so scrubber can detect mouse drags anywhere
947 event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
948 event.Skip();
949}

◆ OnPaint()

void ToolDock::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 891 of file ToolDock.cpp.

892{
893 // Don't use a wxBufferedPaintDC() here. It produces a bogus
894 // background on Windows and GTK.
895 wxPaintDC dc( this );
896
897 // Start with a clean background
898 //
899 // Under GTK, we don't set the toolbar background to the background
900 // colour in the system theme. Instead we use our own colour.
901
902 dc.SetBackground( wxBrush( theTheme.Colour( clrMedium )));
903 dc.Clear();
904
905 // Set the gap color
906 AColor::Dark( &dc, false );
907
908 // Draw the initial horizontal and vertical gaps
909 wxSize sz = GetClientSize();
910
911 AColor::Line(dc, 0, 0, sz.GetWidth(), 0 );
912 AColor::Line(dc, 0, 0, 0, sz.GetHeight() );
913
914 // Draw the gap between each bar
915 for (const auto &place : GetConfiguration())
916 {
917 auto toolbar = place.pTree->pBar;
918 if (!toolbar)
919 continue;
920
921 wxRect r = toolbar->GetRect();
922
923 // Draw a horizontal line under the bar extending to the right edge of
924 // the dock
925 AColor::Line( dc,
926 r.GetLeft(),
927 r.GetBottom() + 1,
928 sz.GetWidth(),
929 r.GetBottom() + 1 );
930
931 // For all bars but the last...
932 // ...and for bars that aren't the last in a row, draw a
933 // vertical gap line
934 if (!mConfiguration.IsRightmost(toolbar)) {
935 AColor::Line(dc,
936 r.GetRight() + 1,
937 r.GetTop(),
938 r.GetRight() + 1,
939 r.GetBottom() + 1 );
940 }
941 }
942}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:443
bool IsRightmost(const ToolBar *bar) const
Definition: ToolDock.cpp:237

References ThemeBase::Colour(), AColor::Dark(), GetConfiguration(), ToolBarConfiguration::IsRightmost(), AColor::Line(), mConfiguration, and theTheme.

Here is the call graph for this function:

◆ OnSize()

void ToolDock::OnSize ( wxSizeEvent &  event)
protected

Definition at line 875 of file ToolDock.cpp.

876{
877// event.Skip();
878}

◆ PositionBar()

ToolBarConfiguration::Position ToolDock::PositionBar ( ToolBar t,
const wxPoint &  pos,
wxRect &  rect 
)

Definition at line 720 of file ToolDock.cpp.

721{
722 // Set width and size, but we must still find x and y.
723 rect = t->GetRect();
724
725 using Position = ToolBarConfiguration::Position;
727 struct Inserter : public LayoutVisitor
728 {
729 struct Stop {};
730
731 Inserter(Position &p, wxRect &r, const wxPoint &pt, ToolBar *t)
732 : result(p), rect(r), point(pt), tb(t)
733 {}
734
735 void ModifySize
736 (ToolBar *ct,
737 const wxRect &rectIn,
740 wxSize &sz)
741 override
742 {
743 // Maybe insert the NEW bar if it hasn't already been done
744 // and is in the right place.
745
746 // Does the location fall within this bar?
747 if (rectIn.Contains(point))
748 {
749 sz = tb->GetDockedSize();
750 // Choose a position always, if there is a bar to displace.
751 // Else, only if the fit is possible.
752 if (ct || (sz.x <= rectIn.width && sz.y <= rectIn.height)) {
753 // May choose current or previous.
754 if (ct &&
755 (sz.y < rectIn.height ||
756 point.y < (rectIn.GetTop() + rectIn.GetBottom()) / 2))
757 // "Wedge" the bar into a crack alone, not adopting others,
758 // if either a short bar displaces a tall one, or else
759 // the displacing bar is at least at tall, but the pointer is
760 // in the upper half of the box.
761 usedPrev = true, result = prevPosition, result.adopt = false;
762 else
763 result = position;
764 }
765 // Now wait until the other callback below to discover x and y
766 }
767 }
768
769 void Visit
770 (ToolBar *, wxPoint pointIn)
771 override
772 {
774 // If we've placed it, we're done.
775 rect.x = pointIn.x;
776 rect.y = pointIn.y;
777 if (usedPrev)
778 rect.y -= tb->GetDockedSize().GetHeight() / 2;
779
780 throw Stop {};
781 }
782 }
783
784 bool ShouldVisitSpaces() override
785 {
786 return true;
787 }
788
789 void FinalRect
790 (const wxRect &finalRect, ToolBarConfiguration::Position finalPosition)
791 override
792 {
794 // Default of all other placements.
795 result = finalPosition;
796 wxPoint point1 { finalRect.GetLeft(), finalRect.GetBottom() };
797 rect.SetPosition(point1);
798 }
799 }
800
801
802 Position &result;
803 wxRect &rect;
804 const wxPoint point;
805 ToolBar *const tb;
806 bool usedPrev { false };
807 } inserter {
808 result, rect, pos, t
809 };
810
811 try { this->VisitLayout(inserter); } catch (const Inserter::Stop&) {}
812
813 // rect is decided
814 return result;
815}
static const Position UnspecifiedPosition
Definition: ToolDock.h:105

References ToolBarConfiguration::Position::adopt, ToolBarConfiguration::UnspecifiedPosition, Visit(), and VisitLayout().

Referenced by ToolManager::OnMouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RestoreConfiguration()

void ToolDock::RestoreConfiguration ( ToolBarConfiguration backup)

Definition at line 824 of file ToolDock.cpp.

825{
828 mConfiguration.Swap(backup);
829}
void Swap(ToolBarConfiguration &that)
Definition: ToolDock.h:56

References ToolBarConfiguration::Clear(), mConfiguration, mWrappedConfiguration, and ToolBarConfiguration::Swap().

Referenced by ToolManager::HandleEscapeKey(), and ToolManager::OnMouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Undock()

void ToolDock::Undock ( ToolBar bar)

Definition at line 403 of file ToolDock.cpp.

404{
405 if( mConfiguration.Contains( bar ) )
406 {
407 mConfiguration.Remove( bar );
408 }
409 mBars[ bar->GetId() ] = nullptr;
410}
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:212

References ToolBarConfiguration::Contains(), mBars, mConfiguration, and ToolBarConfiguration::Remove().

Referenced by ToolManager::Reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Updated()

void ToolDock::Updated ( )

Definition at line 853 of file ToolDock.cpp.

854{
855 // Queue an update event
856 wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() );
857 GetParent()->GetEventHandler()->AddPendingEvent( e );
858}

Referenced by LoadConfig(), and ToolBar::Updated().

Here is the caller graph for this function:

◆ VisitLayout()

void ToolDock::VisitLayout ( LayoutVisitor visitor,
ToolBarConfiguration pWrappedConfiguration = nullptr 
)
private

Definition at line 482 of file ToolDock.cpp.

484{
485 if (pWrappedConfiguration)
486 pWrappedConfiguration->Clear();
487
488 // Get size of our parent since we haven't been sized yet
489 int width, height;
490 GetParent()->GetClientSize( &width, &height );
491 width -= toolbarGap;
492 height -= toolbarGap;
493
494 // Rectangle of space to allocate
495 wxRect main{ toolbarGap, toolbarGap,
496 // Allow limited width, but arbitrary height, for the root rectangle
497 width, std::numeric_limits<int>::max() };
498
499 // For recording the nested subdivisions of the rectangle
500 struct Item {
501 int myBarID { NoBarID };
502 int parentBarID { NoBarID };
503 ToolBar *lastSib {};
504 ToolBar *lastWrappedChild {};
505 wxRect rect;
506 } layout[ ToolBarCount ];
507
508 ToolBar *lastRoot {};
509 ToolBar *lastWrappedRoot {};
510
511 // Process all docked and visible toolbars
512 for ( const auto &place : this->GetConfiguration() )
513 {
514 // Cache toolbar pointer
515 const auto ct = place.pTree->pBar;
516
517 // set up the chain of ancestors.
518 const auto parent = place.position.rightOf;
519 const auto type = ct->GetType();
520 auto &newItem = layout[ type ];
521 newItem.parentBarID = parent ? parent->GetType() : NoBarID;
522 // Mark the slots that really were visited, for final pass through
523 // the spaces.
524 newItem.myBarID = type;
525
526 const auto parentItem = parent ? &layout[ parent->GetType() ] : nullptr;
527 ToolBar *prevSib;
528 if (!parent) {
529 prevSib = lastRoot;
530 lastRoot = ct;
531 }
532 else {
533 auto &sib = parentItem->lastSib;
534 prevSib = sib;
535 sib = ct;
536 }
537 auto prevPosition = ToolBarConfiguration::Position{ parent, prevSib };
538
539 // Determine the size of the toolbar to fit, with advice from
540 // the visitor object
541 wxSize sz = ct->GetSize();
542 {
543 wxRect temp;
544 temp.SetPosition(ct->GetParent()->ClientToScreen(ct->GetPosition()));
545 temp.SetSize(sz);
546 visitor.ModifySize(ct, temp, prevPosition, place.position, sz);
547 }
548
549 // Inflate the size to leave margins
550 int tw = sz.GetWidth() + toolbarGap;
551 int th = sz.GetHeight() + toolbarGap;
552
553 // Choose the rectangle to subdivide
554 // Find a box that we fit in by going up the tree as needed --
555 // thus when parent space is exhausted, fall back on ancestors --
556 // so if the tree has too much depth for the width of the
557 // window, the toolbars may "wrap."
558 // Can always fall back to the main rectangle even if the bar is too
559 // wide.
560 auto pItem = parentItem;
561 auto pRect = pItem ? &pItem->rect : &main;
562 while (pRect != &main)
563 {
564 // Get out if it will fit
565 bool bTooWide = tw > pRect->GetWidth();
566 // We'd like to be able to add a tall toolbar in at the start of a row,
567 // even if there isn't enough height for it.
568 // If so, we'd have to at least change how we calculate 'bTooHigh'.
569 bool bTooHigh = th > pRect->GetHeight();
570 //bTooHigh &= stack[stkcnt].GetWidth() < (width - toolbarGap);
571 //bTooHigh = false;
572
573 if (!bTooWide && !bTooHigh)
574 break;
575
576 if (pItem->parentBarID == NoBarID) {
577 pItem = nullptr;
578 pRect = &main;
579 }
580 else {
581 pItem = &layout[ pItem->parentBarID ];
582 pRect = &pItem->rect;
583 }
584 }
585
586 // Record where the toolbar wrapped
587 ToolBar *& sib = pItem ? pItem->lastWrappedChild : lastWrappedRoot;
589 pItem ? this->mBars[ pItem->myBarID ] : nullptr,
590 sib
591 };
592 sib = ct;
593 if (pWrappedConfiguration)
594 pWrappedConfiguration->Insert(ct, newPosition);
595
596 // Place the toolbar at the upper left part of the rectangle.
597 const auto cpos = pRect->GetPosition();
598 visitor.Visit(ct, cpos);
599
600 // Allocate an upper portion of the rectangle to this bar.
601 pRect->y += th;
602 pRect->height -= th;
603
604 // A right portion of that upper portion remains available for
605 // descendant bars and is remembered in the layout array.
606 int x = cpos.x + tw;
607 newItem.rect = wxRect{ x, cpos.y, width - x, th };
608 }
609
610 if (visitor.ShouldVisitSpaces()) {
611 // Visit the fringe where NEW leaves of the tree could go
612
613 // Find the items with leftover spaces
614 const auto end = std::remove_if(layout, layout + ToolBarCount,
615 [](const Item &item){
616 return item.myBarID == NoBarID || item.rect.IsEmpty();
617 }
618 );
619 // Sort top to bottom for definiteness, though perhaps not really needed
620 std::sort(layout, end,
621 [](const Item &lhs, const Item &rhs){
622 return lhs.rect.y < rhs.rect.y;
623 }
624 );
625 for (auto iter = layout; iter != end; ++iter) {
626 const auto &item = *iter;
627 const auto &rect = item.rect;
628
629 auto globalRect = rect;
630 globalRect.SetPosition( this->ClientToScreen(rect.GetPosition()) );
631
632 // Let the visitor determine size
633 wxSize sz {};
635 position { this->mBars[ item.myBarID ], item.lastWrappedChild },
636 prevPosition {};
637 visitor.ModifySize(nullptr, globalRect, prevPosition, position, sz);
638 int tw = sz.GetWidth() + toolbarGap;
639 int th = sz.GetHeight() + toolbarGap;
640
641 // Test fit
642 bool bTooWide = tw > rect.GetWidth();
643 bool bTooHigh = th > rect.GetHeight();
644 if (!bTooWide && !bTooHigh) {
645 // Call visitor again to confirm the placement
646 const auto cpos = rect.GetPosition();
647 visitor.Visit(nullptr, cpos);
648 }
649 }
650 }
651
652 // Report the final bounding box of all the bars, and a position where
653 // you can insert a NEW bar at bottom left.
654 ToolBarConfiguration::Position finalPosition { nullptr, lastRoot };
655 visitor.FinalRect(
656 wxRect { toolbarGap, toolbarGap, main.width, main.y }, finalPosition
657 );
658}
IMPLEMENT_WX_THEME_SUPPORT int main(int argc, char *argv[])
#define toolbarGap
Definition: ToolBar.h:64
@ NoBarID
Definition: ToolBar.h:71
@ ToolBarCount
Definition: ToolBar.h:90
int GetType()
Definition: ToolBar.cpp:390
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References ToolBarConfiguration::Clear(), PackedArray::end(), ToolDock::LayoutVisitor::FinalRect(), GetConfiguration(), ToolBar::GetType(), ToolBarConfiguration::Insert(), main(), mBars, ToolDock::LayoutVisitor::ModifySize(), NoBarID, ToolDock::LayoutVisitor::ShouldVisitSpaces(), ToolBarCount, toolbarGap, and ToolDock::LayoutVisitor::Visit().

Referenced by LayoutToolBars(), and PositionBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WrapConfiguration()

void ToolDock::WrapConfiguration ( ToolBarConfiguration backup)

Definition at line 817 of file ToolDock.cpp.

818{
819 backup.Clear();
820 backup.Swap(mConfiguration);
822}

References ToolBarConfiguration::Clear(), mConfiguration, mWrappedConfiguration, and ToolBarConfiguration::Swap().

Referenced by ToolManager::OnGrabber().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mBars

ToolBar* ToolDock::mBars[ToolBarCount]
private

Definition at line 343 of file ToolDock.h.

Referenced by Dock(), Expose(), Undock(), and VisitLayout().

◆ mConfiguration

ToolBarConfiguration ToolDock::mConfiguration
private

◆ mManager

wxEvtHandler* ToolDock::mManager
private

Definition at line 335 of file ToolDock.h.

Referenced by OnGrabber().

◆ mWrappedConfiguration

ToolBarConfiguration ToolDock::mWrappedConfiguration
private

Definition at line 341 of file ToolDock.h.

Referenced by LayoutToolBars(), RestoreConfiguration(), and WrapConfiguration().


The documentation for this class was generated from the following files: