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 (Identifier 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
 
std::map< Identifier, ToolBar * > mBars
 

Detailed Description

A dynamic panel where a ToolBar can be docked.

Definition at line 291 of file ToolDock.h.

Constructor & Destructor Documentation

◆ ToolDock()

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

Methods for ToolDock.

Definition at line 402 of file ToolDock.cpp.

402 :
403 wxPanelWrapper( parent, dockid, wxDefaultPosition, parent->GetSize() )
404{
405 SetLabel( XO( "ToolDock" ) );
406 SetName( XO( "ToolDock" ) );
407
408 // Init
410 SetBackgroundColour(theTheme.Colour( clrMedium ));
411 SetLayoutDirection(wxLayout_LeftToRight);
412 // Use for testing gaps
413 // SetOwnBackgroundColour( wxColour( 255, 0, 0 ) );
414}
XO("Cut/Copy/Paste")
static const AttachedProjectObjects::RegisteredFactory manager
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)
wxEvtHandler * mManager
Definition: ToolDock.h:337
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 419 of file ToolDock.cpp.

420{
421}

Member Function Documentation

◆ AcceptsFocus()

bool ToolDock::AcceptsFocus ( ) const
inlineoverride

Definition at line 298 of file ToolDock.h.

298{ return false; };

◆ Dock()

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

Definition at line 438 of file ToolDock.cpp.

439{
440#ifndef __WXMAC__
441 // Apply the deflate fix only on Mac, else you introduce the opposite bug on others
442 deflate = false;
443#endif
444
445 // Adopt the toolbar into our family
446 bar->Reparent( this );
447 mBars[ bar->GetSection() ] = bar;
448
449 // Reset size
450 bar->SetSize(
451 // Undo the expansion that was applied when un-docking
452 bar->GetSize().x - (deflate ? 2 * ToolBarFloatMargin : 0),
453 // Don't need to adjust y the same way.
454 bar->GetDockedSize().y
455 );
456
457 // Park the NEW bar in the correct berth
458 if (!mConfiguration.Contains(bar) && bar->IsVisible())
459 mConfiguration.Insert( bar, position );
460
461 // Inform toolbar of change
462 bar->SetDocked( this, false );
463}
@ ToolBarFloatMargin
Definition: ToolBar.h:66
bool Contains(const ToolBar *bar) const
Definition: ToolDock.h:235
void Insert(ToolBar *bar, Position position=UnspecifiedPosition)
Definition: ToolDock.cpp:110
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:661
Identifier GetSection()
Definition: ToolBar.cpp:400
bool IsVisible() const
Definition: ToolBar.cpp:441
virtual wxSize GetDockedSize()
Definition: ToolBar.h:145
std::map< Identifier, ToolBar * > mBars
Definition: ToolDock.h:345
ToolBarConfiguration mConfiguration
Definition: ToolDock.h:340

References ToolBarConfiguration::Contains(), ToolBar::GetDockedSize(), ToolBar::GetSection(), 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 ( Identifier  type,
bool  show 
)

Definition at line 858 of file ToolDock.cpp.

859{
860 ToolBar *t = mBars[ type ];
861
862 // Maintain the docked array
863 const auto shown = mConfiguration.Shows( t );
864 if( show && !shown )
865 mConfiguration.Show( t );
866 else if( !show && shown )
867 mConfiguration.Hide( t );
868
869 // Make it (dis)appear
870 t->Expose( show );
871}
void Show(ToolBar *bar)
Definition: ToolDock.cpp:236
bool Shows(const ToolBar *bar) const
Definition: ToolDock.h:248
void Hide(ToolBar *bar)
Definition: ToolDock.cpp:257
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:73
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:459

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 311 of file ToolDock.h.

312 { 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 687 of file ToolDock.cpp.

688{
689 struct SizeSetter final : public LayoutVisitor
690 {
691 SizeSetter (ToolDock *d) : dock{ d } {}
692
693 void Visit
694 (ToolBar *bar, wxPoint point)
695 override
696 {
697 // Place the toolbar
698 if(bar)
699 bar->SetPosition( point );
700 }
701
702 bool ShouldVisitSpaces() override
703 {
704 return false;
705 }
706
707 virtual void FinalRect
708 (const wxRect &rect, ToolBarConfiguration::Position)
709 override
710 {
711 // Set the final size of the dock window
712 dock->SetMinSize( rect.GetSize() );
713 }
714
715 ToolDock *dock;
716 } sizeSetter {
717 this
718 };
720
721 // Set tab order and layout internal controls.
722 {
723 ToolBar *lt{};
724 for ( const auto &place : GetConfiguration() ) {
725 auto ct = place.pTree->pBar;
726 if( lt ){
727 ct->MoveAfterInTabOrder( lt );
728 }
729 lt = ct;
730 // Bug 1371.
731 // After a dock size change, the toolbars may need relaying inside.
732 lt->Layout();
733 }
734 }
735
736 // Clean things up
737 Refresh( false );
738}
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:292
ToolBarConfiguration mWrappedConfiguration
Definition: ToolDock.h:343
void VisitLayout(LayoutVisitor &visitor, ToolBarConfiguration *pWrappedConfiguration=nullptr)
Definition: ToolDock.cpp:505
ToolBarConfiguration & GetConfiguration()
Definition: ToolDock.h:311
MENUS_API void Visit(Visitor< Traits > &visitor, AudacityProject &project)

References GetConfiguration(), mWrappedConfiguration, MenuRegistry::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 466 of file ToolDock.cpp.

467{
468 // Add all ordered toolbars
469 for(const auto &place : GetConfiguration()) {
470 auto bar = place.pTree->pBar;
471 this->Dock(bar, false);
472 // Show it -- hidden bars are not (yet) ever saved as part of a
473 // configuration
474 Expose( bar->GetSection(), true );
475 }
476 Updated();
477}
void Expose(Identifier type, bool show)
Definition: ToolDock.cpp:858
void Updated()
Definition: ToolDock.cpp:877
void Dock(ToolBar *bar, bool deflate, ToolBarConfiguration::Position ndx=ToolBarConfiguration::UnspecifiedPosition)
Definition: ToolDock.cpp:438

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 907 of file ToolDock.cpp.

908{
909 // Ignore it to prevent flashing
910}

◆ OnGrabber()

void ToolDock::OnGrabber ( GrabberEvent event)
protected

Definition at line 887 of file ToolDock.cpp.

888{
889 // auto pos = event.GetPosition();
890 if (!event.IsEscaping()) {
891 // Pass it on to the manager since it isn't in the handling hierarchy
892 mManager->ProcessEvent( event );
893 }
894}
bool IsEscaping() const
Definition: Grabber.h:75

References GrabberEvent::IsEscaping(), and mManager.

Here is the call graph for this function:

◆ OnMouseEvents()

void ToolDock::OnMouseEvents ( wxMouseEvent &  event)
protected

Definition at line 954 of file ToolDock.cpp.

955{
956 // Do this hack so scrubber can detect mouse drags anywhere
957 event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
958 event.Skip();
959}

◆ OnPaint()

void ToolDock::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 915 of file ToolDock.cpp.

916{
917 // Don't use a wxBufferedPaintDC() here. It produces a bogus
918 // background on Windows and GTK.
919 wxPaintDC dc( this );
920
921 // Start with a clean background
922 //
923 // Under GTK, we don't set the toolbar background to the background
924 // colour in the system theme. Instead we use our own colour.
925
926 dc.SetBackground( wxBrush( theTheme.Colour( clrMedium )));
927 dc.Clear();
928
929 // Set the gap color
930 AColor::Dark( &dc, false );
931
932 // Draw the initial horizontal and vertical gaps
933 wxSize sz = GetClientSize();
934
935 // Draw the gap between each bar
936 for (const auto &place : GetConfiguration())
937 {
938 auto toolbar = place.pTree->pBar;
939 if (!toolbar)
940 continue;
941
942 wxRect r = toolbar->GetRect();
943
944 // Draw a horizontal line under the bar extending to the right edge of
945 // the dock
946 AColor::Line( dc,
947 r.GetLeft(),
948 r.GetBottom() + 1,
949 sz.GetWidth(),
950 r.GetBottom() + 1 );
951 }
952}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:194
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:421

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

Here is the call graph for this function:

◆ OnSize()

void ToolDock::OnSize ( wxSizeEvent &  event)
protected

Definition at line 899 of file ToolDock.cpp.

900{
901// event.Skip();
902}

◆ PositionBar()

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

Definition at line 744 of file ToolDock.cpp.

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

References ToolBarConfiguration::Position::adopt, ToolBarConfiguration::UnspecifiedPosition, MenuRegistry::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 848 of file ToolDock.cpp.

849{
852 mConfiguration.Swap(backup);
853}
void Swap(ToolBarConfiguration &that)
Definition: ToolDock.h:57

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 426 of file ToolDock.cpp.

427{
428 if( mConfiguration.Contains( bar ) )
429 {
430 mConfiguration.Remove( bar );
431 }
432 mBars[ bar->GetSection() ] = nullptr;
433}
void Remove(const ToolBar *bar)
Definition: ToolDock.cpp:224

References ToolBarConfiguration::Contains(), ToolBar::GetSection(), 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 877 of file ToolDock.cpp.

878{
879 // Queue an update event
880 wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() );
881 GetParent()->GetEventHandler()->AddPendingEvent( e );
882}

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 505 of file ToolDock.cpp.

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

References ToolBarConfiguration::Clear(), ToolDock::LayoutVisitor::FinalRect(), GetConfiguration(), ToolBar::GetSection(), ToolBarConfiguration::Insert(), main(), mBars, ToolDock::LayoutVisitor::ModifySize(), ToolDock::LayoutVisitor::ShouldVisitSpaces(), 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 841 of file ToolDock.cpp.

842{
843 backup.Clear();
844 backup.Swap(mConfiguration);
846}

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

std::map<Identifier, ToolBar*> ToolDock::mBars
private

Definition at line 345 of file ToolDock.h.

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

◆ mConfiguration

ToolBarConfiguration ToolDock::mConfiguration
private

◆ mManager

wxEvtHandler* ToolDock::mManager
private

Definition at line 337 of file ToolDock.h.

Referenced by OnGrabber().

◆ mWrappedConfiguration

ToolBarConfiguration ToolDock::mWrappedConfiguration
private

Definition at line 343 of file ToolDock.h.

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


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