Audacity  3.0.3
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ExpandingToolBar Class Referencefinal

A smart ToolBar class that has a "MainPanel" which is always displayed, and an "ExtraPanel" that can be hidden to save space. More...

#include <ExpandingToolBar.h>

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

Public Member Functions

 ExpandingToolBar (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
virtual ~ExpandingToolBar ()
 
wxPanel * GetMainPanel ()
 
wxPanel * GetExtraPanel ()
 
void SetAutoExpand (bool enabled)
 
bool GetAutoExpand ()
 
void Expand ()
 
void Collapse (bool now=false)
 
bool IsExpanded ()
 
void OnSize (wxSizeEvent &evt)
 
void OnToggle (wxCommandEvent &evt)
 
void OnTimer (wxTimerEvent &evt)
 
void StartMoving ()
 
void UpdateMoving ()
 
void FinishMoving ()
 
bool Layout () override
 
void Fit () override
 
- 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 RecursivelyPushEventHandlers (wxWindow *win)
 
bool IsCursorInWindow ()
 
void ReparentExtraPanel ()
 
void MoveDrawer (wxSize prevSize)
 
wxBitmap GetToolbarBitmap ()
 
void TryAutoExpand ()
 
void TryAutoCollapse ()
 

Protected Attributes

wxPanel * mMainPanel
 
wxPanel * mExtraPanel
 
ToolBarGrabbermGrabber
 
AButtonmToggleButton
 
bool mIsAutoExpanded
 
bool mIsManualExpanded
 
bool mIsExpanded
 
bool mAutoExpand
 
bool mFirstTime
 
wxSize mMainSize
 
wxSize mExtraSize
 
wxSize mButtonSize
 
wxSize mGrabberSize
 
wxSize mCurrentDrawerSize
 
wxSize mTargetDrawerSize
 
wxSize mCurrentTotalSize
 
WindowHash mWindowHash
 
wxTimer mTimer
 
ToolBarFramemFrameParent
 
ToolBarDialogmDialogParent
 
ToolBarAreamAreaParent
 
std::unique_ptr< ToolBarArrangementmSavedArrangement
 
ImageRollPanelmTargetPanel
 
std::unique_ptr< wxDragImage > mDragImage
 
wxWindow * mTopLevelParent
 
std::vector< wxRect > mDropTargets
 
wxRect mDropTarget
 
std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > mHandlers
 

Static Protected Attributes

static int msNoAutoExpandStack = 0
 

Friends

class ExpandingToolBarEvtHandler
 

Detailed Description

A smart ToolBar class that has a "MainPanel" which is always displayed, and an "ExtraPanel" that can be hidden to save space.

Can be docked into a ToolBarArea or floated in an ToolBarFrame;

If auto-expanding is off, behavior is very simple: clicking the toggle button expands, clicking it again collapses.

If auto-expanding is on, behavior is a little more complicated. When the mouse movers over a toolbar and it is collapsed, it gets auto-expanded, and it gets auto-collapsed as soon as the mouse leaves. However, if they manually toggle it collapsed while it was auto-expanded, it will stay collapsed until you move the mouse completely away and then back again later. If you manually expand it, it will stay manually expanded until you manually collapse it.

Definition at line 45 of file ExpandingToolBar.h.

Constructor & Destructor Documentation

◆ ExpandingToolBar()

ExpandingToolBar::ExpandingToolBar ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
Todo:
check whether this is a memory leak (and check similar code)

Definition at line 115 of file ExpandingToolBar.cpp.

118  :
119  wxPanelWrapper(parent, id, pos, size),
120  mIsAutoExpanded(false),
121  mIsManualExpanded(false),
122  mIsExpanded(false),
123  mAutoExpand(true),
124  mFirstTime(true),
125  mFrameParent(NULL),
126  mDialogParent(NULL),
127  mAreaParent(NULL),
129  mTopLevelParent(NULL)
130 {
131  mMainPanel = safenew wxPanelWrapper(this, -1,
132  wxDefaultPosition, wxSize(1, 1));
134  wxDefaultPosition, wxSize(1, 1));
135 
136  mGrabber = NULL;
137 
138  ToolBarArea *toolBarParent =
139  dynamic_cast<ToolBarArea *>(GetParent());
140  if (toolBarParent)
141  mGrabber = safenew ToolBarGrabber(this, -1, this);
142 
144  //wxImage hbar = theTheme.Image(bmpToolBarToggle);
145  //wxColour magicColor = wxColour(0, 255, 255);
146  //ImageArray fourStates = ImageRoll::SplitV(hbar, magicColor);
147 /*
148  mToggleButton = safenew AButton(this, kToggleButtonID,
149  wxDefaultPosition, wxDefaultSize,
150  ImageRoll(ImageRoll::HorizontalRoll,
151  fourStates[0], magicColor),
152  ImageRoll(ImageRoll::HorizontalRoll,
153  fourStates[1], magicColor),
154  ImageRoll(ImageRoll::HorizontalRoll,
155  fourStates[2], magicColor),
156  ImageRoll(ImageRoll::HorizontalRoll,
157  fourStates[3], magicColor),
158  true);
159  mToggleButton->UseDisabledAsDownHiliteImage(true);
160 */
161  SetAutoLayout(true);
162  mTimer.SetOwner(this, kTimerID);
163 }

◆ ~ExpandingToolBar()

ExpandingToolBar::~ExpandingToolBar ( )
virtual

Definition at line 165 of file ExpandingToolBar.cpp.

166 {
167 }

Member Function Documentation

◆ Collapse()

void ExpandingToolBar::Collapse ( bool  now = false)

Definition at line 231 of file ExpandingToolBar.cpp.

232 {
233  // After being manually collapsed, we set mIsAutoExpanded back to
234  // true, which prevents it from being immediately auto-expanded
235  // again until after the mouse actually moves away and then
236  // back again later.
237 
238  mToggleButton->PopUp();
239  mIsManualExpanded = false;
240  mIsAutoExpanded = false;
241  Fit();
242  mIsAutoExpanded = true;
243 
244  if (now) {
246 
247  MoveDrawer(wxSize(0, 0));
248  }
249 }

References Fit(), mCurrentDrawerSize, mIsAutoExpanded, mIsManualExpanded, MoveDrawer(), mTargetDrawerSize, mToggleButton, and AButton::PopUp().

Referenced by OnToggle().

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

◆ Expand()

void ExpandingToolBar::Expand ( )

Definition at line 217 of file ExpandingToolBar.cpp.

218 {
219  // We set both mIsManualExpanded and mIsAutoExpanded to true;
220  // that way if the user manually collapses the toolbar we set
221  // mIsManualExpanded to false but keep mIsAutoExpanded to true
222  // to prevent it from being auto-expanded again until the user
223  // actually moves the mouse completely away and back again later.
224 
226  mIsManualExpanded = true;
227  mIsAutoExpanded = true;
228  Fit();
229 }

References Fit(), mIsAutoExpanded, mIsManualExpanded, mToggleButton, and AButton::PushDown().

Referenced by OnToggle().

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

◆ FinishMoving()

void ExpandingToolBar::FinishMoving ( )

Definition at line 622 of file ExpandingToolBar.cpp.

623 {
625  return;
626 
627  // DELETE mTargetPanel; // I think this is not needed, but unreachable anyway -- PRL
628 
630 
631  mDragImage->Hide();
632  mDragImage->EndDrag();
633 
635 
636  if (mDropTarget == kDummyRect) {
638  }
639  else {
640  mSavedArrangement.reset();
642  }
643 
644  // Keep all drawers closed until the user moves specifically to a
645  // different window
647 
648  mTopLevelParent->Refresh(true);
649 
650  mTimer.Start(kMyTimerInterval);
651 }

References ToolBarArea::CollapseAll(), kDummyRect, kMyTimerInterval, mAreaParent, mDragImage, mDropTarget, ToolBarArea::MoveChild(), mSavedArrangement, msNoAutoExpandStack, mTimer, mTopLevelParent, ToolBarArea::RestoreArrangement(), and ToolBarArea::SetCapturedChild().

Referenced by ToolBarArea::OnMouse().

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

◆ Fit()

void ExpandingToolBar::Fit ( )
override

Definition at line 352 of file ExpandingToolBar.cpp.

353 {
354 #ifdef EXPERIMENTAL_ROLL_UP_DIALOG
356 #else
357  mIsExpanded = true;// JKC - Wedge it open at all times.
358 #endif
359 
360  int width = mButtonSize.x + mGrabberSize.x;
361 
362  wxSize baseWindowSize = wxSize(width,
363  mMainSize.y + mButtonSize.y);
364 
365  mTargetDrawerSize = wxSize(mButtonSize.x, 0);
366 
367  if (mIsExpanded)
369 
371 
372  // The first time, we always update the size. Otherwise, we set
373  // a target size, and the actual size changes during a timer
374  // event.
375 
376  if (mFirstTime) {
377  mFirstTime = false;
378  mCurrentDrawerSize = wxSize(mExtraSize.x, 0);
379  mCurrentTotalSize = baseWindowSize;
380 
381  SetMinSize(mCurrentTotalSize);
382  SetMaxSize(mCurrentTotalSize);
383  SetSize(mCurrentTotalSize);
384  }
385 
386  // wxTimers seem to be a little unreliable - sometimes they stop for
387  // no good reason, so this "primes" it every now and then...
388  mTimer.Stop();
389  mTimer.Start(kMyTimerInterval);
390 }

References kMyTimerInterval, mButtonSize, mCurrentDrawerSize, mCurrentTotalSize, mExtraSize, mFirstTime, mGrabberSize, mIsAutoExpanded, mIsExpanded, mIsManualExpanded, mMainSize, mTargetDrawerSize, and mTimer.

Referenced by Collapse(), Expand(), TryAutoCollapse(), and TryAutoExpand().

Here is the caller graph for this function:

◆ GetAutoExpand()

bool ExpandingToolBar::GetAutoExpand ( )
inline

Definition at line 60 of file ExpandingToolBar.h.

60 { return mAutoExpand; }

References mAutoExpand.

◆ GetExtraPanel()

wxPanel* ExpandingToolBar::GetExtraPanel ( )
inline

Definition at line 57 of file ExpandingToolBar.h.

57 { return mExtraPanel; }

References mExtraPanel.

◆ GetMainPanel()

wxPanel* ExpandingToolBar::GetMainPanel ( )
inline

Definition at line 56 of file ExpandingToolBar.h.

56 { return mMainPanel; }

References mMainPanel.

◆ GetToolbarBitmap()

wxBitmap ExpandingToolBar::GetToolbarBitmap ( )
protected

Definition at line 494 of file ExpandingToolBar.cpp.

495 {
496  wxSize size = GetClientSize();
497  wxBitmap bitmap(size.x, size.y);
498  wxClientDC winDC(this);
499  wxMemoryDC memDC;
500  memDC.SelectObject(bitmap);
501  memDC.Blit(0, 0, size.x, size.y,
502  &winDC, 0, 0);
503  return bitmap;
504 }

References size.

Referenced by StartMoving().

Here is the caller graph for this function:

◆ IsCursorInWindow()

bool ExpandingToolBar::IsCursorInWindow ( )
protected

Definition at line 392 of file ExpandingToolBar.cpp.

393 {
394  wxPoint globalMouse = ::wxGetMousePosition();
395  wxPoint localMouse = ScreenToClient(globalMouse);
396 
397  bool result = (localMouse.x >= 0 && localMouse.y >= 0 &&
398  localMouse.x < mCurrentTotalSize.x &&
399  localMouse.y < mCurrentTotalSize.y);
400 
401  // The grabber doesn't count!
402  if (mGrabber && mGrabber->GetRect().Contains(localMouse))
403  result = false;
404 
405  return result;
406 }

References mCurrentTotalSize, and mGrabber.

Referenced by OnTimer().

Here is the caller graph for this function:

◆ IsExpanded()

bool ExpandingToolBar::IsExpanded ( )
inline

Definition at line 65 of file ExpandingToolBar.h.

65 { return mIsExpanded; }

References mIsExpanded.

◆ Layout()

bool ExpandingToolBar::Layout ( )
override

Definition at line 322 of file ExpandingToolBar.cpp.

323 {
324  mMainSize = mMainPanel->GetBestSize();
325  mExtraSize = mExtraPanel->GetBestSize();
326  mButtonSize = wxSize(wxMax(mMainSize.x, mExtraSize.x),
328 
329  int left = 0;
330 
331  if (mGrabber) {
332  mGrabberSize = mGrabber->GetMinSize();
333  left += mGrabberSize.x;
334  }
335  else
336  mGrabberSize = wxSize(0, 0);
337 
338  mMainPanel->SetSize(left, 0, mMainSize.x, mMainSize.y);
339  mToggleButton->SetSize(left, mMainSize.y, mButtonSize.x, mButtonSize.y);
340  mExtraPanel->SetSize(left, mMainSize.y + mButtonSize.y,
341  mExtraSize.x, mExtraSize.y);
342 
343  if (mGrabber)
344  mGrabber->SetSize(0, 0, left, mMainSize.y + mButtonSize.y);
345 
346  // Add event handlers to all children
347  //RecursivelyPushEventHandlers(this);
348 
349  return true;
350 }

References kToggleButtonHeight, mButtonSize, mExtraPanel, mExtraSize, mGrabber, mGrabberSize, mMainPanel, mMainSize, and mToggleButton.

◆ MoveDrawer()

void ExpandingToolBar::MoveDrawer ( wxSize  prevSize)
protected

Definition at line 426 of file ExpandingToolBar.cpp.

427 {
428  mCurrentTotalSize = wxSize(mButtonSize.x,
429  mMainSize.y +
430  mButtonSize.y +
432 
433  if (mFrameParent) {
434  // If we're in a tool window
435 
436  SetMinSize(mCurrentTotalSize);
437  SetMaxSize(mCurrentTotalSize);
438  SetSize(mCurrentTotalSize);
439 
440  GetParent()->Fit();
441  }
442 
443  if (mDialogParent) {
444  // If we're in a dialog
445 
446  SetMinSize(mCurrentTotalSize);
447  SetMaxSize(mCurrentTotalSize);
448  SetSize(mCurrentTotalSize);
449 
450  GetParent()->Fit();
451  }
452 
453  if (mAreaParent) {
454  // If we're in a tool area
455 
456  if (mCurrentDrawerSize.y > 0 && prevSize.y == 0) {
458  mExtraPanel->Show();
459  }
460 
461  mExtraPanel->SetMinSize(mCurrentDrawerSize);
462  mExtraPanel->SetMaxSize(mCurrentDrawerSize);
464 
465  if (mCurrentDrawerSize.y == 0)
466  mExtraPanel->Hide();
467  }
468 }

References mAreaParent, mButtonSize, mCurrentDrawerSize, mCurrentTotalSize, mDialogParent, mExtraPanel, mFrameParent, mMainSize, and ReparentExtraPanel().

Referenced by Collapse(), and OnTimer().

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

◆ OnSize()

void ExpandingToolBar::OnSize ( wxSizeEvent &  evt)

Definition at line 169 of file ExpandingToolBar.cpp.

170 {
172  return;
173 
174  // At the time of construction, it wasn't "safe" to tell
175  // our parent that we've just joined the window, so we check
176  // for it during our first OnSize event.
177 
178  if (!mFrameParent) {
179  ToolBarFrame *toolBarParent =
180  dynamic_cast<ToolBarFrame *>(GetParent());
181  if (toolBarParent) {
182  // We were placed into a floating window
183  mFrameParent = toolBarParent;
184  toolBarParent->SetChild(this);
185  }
186  }
187 
188  if (!mDialogParent) {
189  ToolBarDialog *toolBarParent =
190  dynamic_cast<ToolBarDialog *>(GetParent());
191  if (toolBarParent) {
192  // We were placed into a dialog
193  mDialogParent = toolBarParent;
194  toolBarParent->SetChild(this);
195  }
196  }
197 
198  if (!mAreaParent) {
199  ToolBarArea *toolBarParent =
200  dynamic_cast<ToolBarArea *>(GetParent());
201  if (toolBarParent) {
202  // We were placed into an area full of other toolbars
203  mAreaParent = toolBarParent;
204  toolBarParent->AddChild(this);
205  }
206  }
207 }

References ToolBarArea::AddChild(), mAreaParent, mDialogParent, mFrameParent, ToolBarDialog::SetChild(), and ToolBarFrame::SetChild().

Here is the call graph for this function:

◆ OnTimer()

void ExpandingToolBar::OnTimer ( wxTimerEvent &  evt)

Definition at line 470 of file ExpandingToolBar.cpp.

471 {
472  if (mAutoExpand && msNoAutoExpandStack==0 &&
474  TryAutoExpand();
475  else if (!IsCursorInWindow())
476  TryAutoCollapse();
477 
479  return;
480 
481  // This accelerates the current size towards the target size;
482  // it's a neat way for the window to roll open, but in such a
483  // way that it
484 
485  wxSize prevSize = mCurrentDrawerSize;
487  if (abs((mCurrentDrawerSize-mTargetDrawerSize).x)<2 &&
490 
491  MoveDrawer(prevSize);
492 }

References IsCursorInWindow(), mAutoExpand, mCurrentDrawerSize, MoveDrawer(), msNoAutoExpandStack, mTargetDrawerSize, TryAutoCollapse(), and TryAutoExpand().

Here is the call graph for this function:

◆ OnToggle()

void ExpandingToolBar::OnToggle ( wxCommandEvent &  evt)

Definition at line 209 of file ExpandingToolBar.cpp.

210 {
211  if (mIsExpanded)
212  Collapse();
213  else
214  Expand();
215 }

References Collapse(), Expand(), and mIsExpanded.

Here is the call graph for this function:

◆ RecursivelyPushEventHandlers()

void ExpandingToolBar::RecursivelyPushEventHandlers ( wxWindow *  win)
protected

Definition at line 309 of file ExpandingToolBar.cpp.

310 {
311  if (!mWindowHash[win]) {
312  mHandlers.push_back(std::make_unique<ExpandingToolBarEvtHandler>
313  (this, win, win->GetEventHandler()));
314  mWindowHash[win] = 1;
315  }
316 
317  wxWindowList children = win->GetChildren();
318  for(auto child : children)
320 }

References mHandlers, and mWindowHash.

◆ ReparentExtraPanel()

void ExpandingToolBar::ReparentExtraPanel ( )
protected

Definition at line 408 of file ExpandingToolBar.cpp.

409 {
410  // This is how we make sure the extra panel, which slides out
411  // like a drawer, appears on top of everything else in the window...
412 
413  wxPoint pos;
414  pos.x = mGrabberSize.x;
415  pos.y = mMainSize.y + mButtonSize.y;
416  wxWindow *frame = this;
417  while(!frame->IsTopLevel()) {
418  pos += frame->GetPosition();
419  frame = frame->GetParent();
420  }
421 
422  mExtraPanel->Reparent(frame);
423  mExtraPanel->SetPosition(pos);
424 }

References mButtonSize, mExtraPanel, mGrabberSize, and mMainSize.

Referenced by MoveDrawer().

Here is the caller graph for this function:

◆ SetAutoExpand()

void ExpandingToolBar::SetAutoExpand ( bool  enabled)
inline

Definition at line 59 of file ExpandingToolBar.h.

59 { mAutoExpand = enabled; }

References mAutoExpand.

◆ StartMoving()

void ExpandingToolBar::StartMoving ( )

Definition at line 506 of file ExpandingToolBar.cpp.

507 {
508  if (!mAreaParent)
509  return;
510 
511  int j;
512 
513  mAreaParent->CollapseAll(true);
514 
515  mTimer.Stop();
516 
517  // This gives time for wx to finish redrawing the window that way.
518  // HACK: why do we need to do it so many times???
519  for(j=0; j<500; j++)
520  ::wxSafeYield();
521 
522  wxBitmap toolbarBitmap = GetToolbarBitmap();
523 
526  mAreaParent->RemoveChild(this);
527 
528  mAreaParent->Refresh(true);
529 
530  mTopLevelParent = this;
531  while(!mTopLevelParent->IsTopLevel())
532  mTopLevelParent = mTopLevelParent->GetParent();
533 
534  wxPoint hotSpot = ScreenToClient(wxGetMousePosition());
535 
536  hotSpot -= (ClientToScreen(wxPoint(0, 0)) -
537  mAreaParent->ClientToScreen(wxPoint(0, 0)));
538 
541 
542  wxColour magicColor = wxColour(0, 255, 255);
543 // wxImage tgtImage = theTheme.Image(bmpToolBarTarget);
544 // ImageRoll tgtImageRoll = ImageRoll(ImageRoll::VerticalRoll,
545 // tgtImage,
546 // magicColor);
547  mTargetPanel = safenew ImageRollPanel(mAreaParent, -1, //tgtImageRoll,
548  wxDefaultPosition,
549  wxDefaultSize,
550  wxTRANSPARENT_WINDOW);
552  mTargetPanel->SetSize(mDropTarget);
553 
554  // This gives time for wx to finish redrawing the window that way.
555  // HACK: why do we need to do it several times???
556  for(j=0; j<500; j++)
557  ::wxSafeYield();
558 
560 
561  mDragImage = std::make_unique<wxDragImage>(toolbarBitmap);
562  mDragImage->BeginDrag(hotSpot, mAreaParent, mTopLevelParent);
563  mDragImage->Show();
564  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
565 }

References ToolBarArea::CollapseAll(), ToolBarArea::GetDropTargets(), GetToolbarBitmap(), kDummyRect, mAreaParent, mDragImage, mDropTarget, mDropTargets, mSavedArrangement, msNoAutoExpandStack, mTargetPanel, mTimer, mTopLevelParent, ToolBarArea::RemoveChild(), safenew, ToolBarArea::SaveArrangement(), ToolBarArea::SetCapturedChild(), and ImageRollPanel::SetLogicalFunction().

Referenced by ToolBarGrabber::OnMouse().

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

◆ TryAutoCollapse()

void ExpandingToolBar::TryAutoCollapse ( )
protected

Definition at line 261 of file ExpandingToolBar.cpp.

262 {
263 #ifdef EXPERIMENTAL_ROLL_UP_DIALOG
264  if (mIsAutoExpanded == true && mIsManualExpanded == false) {
265  mToggleButton->PopUp();
266  mIsAutoExpanded = false;
267  Fit();
268  }
269 #endif
270 }

References Fit(), mIsAutoExpanded, mIsManualExpanded, mToggleButton, and AButton::PopUp().

Referenced by OnTimer().

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

◆ TryAutoExpand()

void ExpandingToolBar::TryAutoExpand ( )
protected

Definition at line 251 of file ExpandingToolBar.cpp.

252 {
253  if (mAutoExpand && msNoAutoExpandStack==0 &&
254  mIsManualExpanded == false && mIsAutoExpanded == false) {
256  mIsAutoExpanded = true;
257  Fit();
258  }
259 }

References Fit(), mAutoExpand, mIsAutoExpanded, mIsManualExpanded, msNoAutoExpandStack, mToggleButton, and AButton::PushDown().

Referenced by OnTimer(), and ExpandingToolBarEvtHandler::ProcessEvent().

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

◆ UpdateMoving()

void ExpandingToolBar::UpdateMoving ( )

Definition at line 567 of file ExpandingToolBar.cpp.

568 {
570  return;
571 
572  wxPoint cursorPos = mAreaParent->ScreenToClient(wxGetMousePosition());
573  wxRect prevTarget = mDropTarget;
574  int best_dist_sq = 99999;
575  int i;
576 
577  for(i = 0; i < (int)mDropTargets.size(); i++) {
578  int x = (mDropTargets[i].x + (mDropTargets[i].width/2))-cursorPos.x;
579  int y = (mDropTargets[i].y + (mDropTargets[i].height/2))-cursorPos.y;
580  int dist_sq = (x*x) + (y*y);
581 
582  if (dist_sq < best_dist_sq) {
583  best_dist_sq = dist_sq;
585  }
586  }
587 
588  if (!mAreaParent->GetRect().Contains(cursorPos))
590 
591  if (mDropTarget != prevTarget) {
592  mDragImage->Hide();
593 
594  wxRect r = mDropTarget;
595  r.Inflate(4, 4);
596  mTargetPanel->SetSize(r);
597 
598  #if 0
599  wxClientDC dc(mAreaParent);
600  dc.DestroyClippingRegion();
601  dc.SetLogicalFunction(wxINVERT);
602  wxRect r = prevTarget;
603  r.Inflate(4, 4);
604  dc.DrawRectangle(r);
605  r = mDropTarget;
606  r.Inflate(4, 4);
607  dc.DrawRectangle(r);
608  #endif
609 
610  // This gives time for wx to finish redrawing the window that way.
611  // HACK: why do we need to do it so many times???
612  for(i=0; i<500; i++)
613  ::wxSafeYield();
614 
615  mDragImage->Show();
616  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
617  }
618  else
619  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
620 }

References kDummyRect, mAreaParent, mDragImage, mDropTarget, mDropTargets, mSavedArrangement, and mTargetPanel.

Referenced by ToolBarArea::OnMouse().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ExpandingToolBarEvtHandler

friend class ExpandingToolBarEvtHandler
friend

Definition at line 120 of file ExpandingToolBar.h.

Member Data Documentation

◆ mAreaParent

ToolBarArea* ExpandingToolBar::mAreaParent
protected

Definition at line 108 of file ExpandingToolBar.h.

Referenced by FinishMoving(), MoveDrawer(), OnSize(), StartMoving(), and UpdateMoving().

◆ mAutoExpand

bool ExpandingToolBar::mAutoExpand
protected

Definition at line 95 of file ExpandingToolBar.h.

Referenced by GetAutoExpand(), OnTimer(), SetAutoExpand(), and TryAutoExpand().

◆ mButtonSize

wxSize ExpandingToolBar::mButtonSize
protected

Definition at line 99 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), MoveDrawer(), and ReparentExtraPanel().

◆ mCurrentDrawerSize

wxSize ExpandingToolBar::mCurrentDrawerSize
protected

Definition at line 101 of file ExpandingToolBar.h.

Referenced by Collapse(), Fit(), MoveDrawer(), and OnTimer().

◆ mCurrentTotalSize

wxSize ExpandingToolBar::mCurrentTotalSize
protected

Definition at line 103 of file ExpandingToolBar.h.

Referenced by Fit(), IsCursorInWindow(), and MoveDrawer().

◆ mDialogParent

ToolBarDialog* ExpandingToolBar::mDialogParent
protected

Definition at line 107 of file ExpandingToolBar.h.

Referenced by MoveDrawer(), and OnSize().

◆ mDragImage

std::unique_ptr<wxDragImage> ExpandingToolBar::mDragImage
protected

Definition at line 111 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

◆ mDropTarget

wxRect ExpandingToolBar::mDropTarget
protected

Definition at line 114 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

◆ mDropTargets

std::vector<wxRect> ExpandingToolBar::mDropTargets
protected

Definition at line 113 of file ExpandingToolBar.h.

Referenced by StartMoving(), and UpdateMoving().

◆ mExtraPanel

wxPanel* ExpandingToolBar::mExtraPanel
protected

Definition at line 89 of file ExpandingToolBar.h.

Referenced by GetExtraPanel(), Layout(), MoveDrawer(), and ReparentExtraPanel().

◆ mExtraSize

wxSize ExpandingToolBar::mExtraSize
protected

Definition at line 98 of file ExpandingToolBar.h.

Referenced by Fit(), and Layout().

◆ mFirstTime

bool ExpandingToolBar::mFirstTime
protected

Definition at line 96 of file ExpandingToolBar.h.

Referenced by Fit().

◆ mFrameParent

ToolBarFrame* ExpandingToolBar::mFrameParent
protected

Definition at line 106 of file ExpandingToolBar.h.

Referenced by MoveDrawer(), and OnSize().

◆ mGrabber

ToolBarGrabber* ExpandingToolBar::mGrabber
protected

Definition at line 90 of file ExpandingToolBar.h.

Referenced by IsCursorInWindow(), and Layout().

◆ mGrabberSize

wxSize ExpandingToolBar::mGrabberSize
protected

Definition at line 100 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), and ReparentExtraPanel().

◆ mHandlers

std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > ExpandingToolBar::mHandlers
protected

Definition at line 121 of file ExpandingToolBar.h.

Referenced by RecursivelyPushEventHandlers().

◆ mIsAutoExpanded

bool ExpandingToolBar::mIsAutoExpanded
protected

Definition at line 92 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Fit(), TryAutoCollapse(), and TryAutoExpand().

◆ mIsExpanded

bool ExpandingToolBar::mIsExpanded
protected

Definition at line 94 of file ExpandingToolBar.h.

Referenced by Fit(), IsExpanded(), and OnToggle().

◆ mIsManualExpanded

bool ExpandingToolBar::mIsManualExpanded
protected

Definition at line 93 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Fit(), TryAutoCollapse(), and TryAutoExpand().

◆ mMainPanel

wxPanel* ExpandingToolBar::mMainPanel
protected

Definition at line 88 of file ExpandingToolBar.h.

Referenced by GetMainPanel(), and Layout().

◆ mMainSize

wxSize ExpandingToolBar::mMainSize
protected

Definition at line 97 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), MoveDrawer(), and ReparentExtraPanel().

◆ mSavedArrangement

std::unique_ptr<ToolBarArrangement> ExpandingToolBar::mSavedArrangement
protected

Definition at line 109 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

◆ msNoAutoExpandStack

int ExpandingToolBar::msNoAutoExpandStack = 0
staticprotected

Definition at line 116 of file ExpandingToolBar.h.

Referenced by FinishMoving(), OnTimer(), StartMoving(), and TryAutoExpand().

◆ mTargetDrawerSize

wxSize ExpandingToolBar::mTargetDrawerSize
protected

Definition at line 102 of file ExpandingToolBar.h.

Referenced by Collapse(), Fit(), and OnTimer().

◆ mTargetPanel

ImageRollPanel* ExpandingToolBar::mTargetPanel
protected

Definition at line 110 of file ExpandingToolBar.h.

Referenced by StartMoving(), and UpdateMoving().

◆ mTimer

wxTimer ExpandingToolBar::mTimer
protected

Definition at line 105 of file ExpandingToolBar.h.

Referenced by FinishMoving(), Fit(), and StartMoving().

◆ mToggleButton

AButton* ExpandingToolBar::mToggleButton
protected

Definition at line 91 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Layout(), TryAutoCollapse(), and TryAutoExpand().

◆ mTopLevelParent

wxWindow* ExpandingToolBar::mTopLevelParent
protected

Definition at line 112 of file ExpandingToolBar.h.

Referenced by FinishMoving(), and StartMoving().

◆ mWindowHash

WindowHash ExpandingToolBar::mWindowHash
protected

Definition at line 104 of file ExpandingToolBar.h.

Referenced by RecursivelyPushEventHandlers().


The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ExpandingToolBar::mToggleButton
AButton * mToggleButton
Definition: ExpandingToolBar.h:91
ExpandingToolBar::mIsManualExpanded
bool mIsManualExpanded
Definition: ExpandingToolBar.h:93
ExpandingToolBar::mMainSize
wxSize mMainSize
Definition: ExpandingToolBar.h:97
ToolBarGrabber
Draws the grabber for an ExpandingToolBar.
Definition: ExpandingToolBar.h:125
ToolBarArea
An alternative to ToolBarFrame which can contain an ExpandingToolBar. ToolBarArea is used for a 'dock...
Definition: ExpandingToolBar.h:197
ExpandingToolBar::mCurrentTotalSize
wxSize mCurrentTotalSize
Definition: ExpandingToolBar.h:103
ExpandingToolBar::mIsExpanded
bool mIsExpanded
Definition: ExpandingToolBar.h:94
ExpandingToolBar::Fit
void Fit() override
Definition: ExpandingToolBar.cpp:352
ExpandingToolBar::mDropTargets
std::vector< wxRect > mDropTargets
Definition: ExpandingToolBar.h:113
AButton::PopUp
void PopUp()
Definition: AButton.cpp:605
ExpandingToolBar::Expand
void Expand()
Definition: ExpandingToolBar.cpp:217
ExpandingToolBar::Collapse
void Collapse(bool now=false)
Definition: ExpandingToolBar.cpp:231
ToolBarFrame::SetChild
void SetChild(ExpandingToolBar *child)
Definition: ExpandingToolBar.cpp:809
ExpandingToolBar::mWindowHash
WindowHash mWindowHash
Definition: ExpandingToolBar.h:104
ExpandingToolBar::mAreaParent
ToolBarArea * mAreaParent
Definition: ExpandingToolBar.h:108
ToolBarFrame
A miniframe based container for ExpandingToolBars providing modeless presentation.
Definition: ExpandingToolBar.h:170
kDummyRect
const wxRect kDummyRect
Definition: ExpandingToolBar.cpp:85
ToolBarArea::SetCapturedChild
void SetCapturedChild(ExpandingToolBar *child)
Definition: ExpandingToolBar.cpp:1282
ExpandingToolBar::mMainPanel
wxPanel * mMainPanel
Definition: ExpandingToolBar.h:88
kToggleButtonHeight
const int kToggleButtonHeight
Definition: ExpandingToolBar.cpp:83
ExpandingToolBar::mGrabberSize
wxSize mGrabberSize
Definition: ExpandingToolBar.h:100
ExpandingToolBar::mCurrentDrawerSize
wxSize mCurrentDrawerSize
Definition: ExpandingToolBar.h:101
ExpandingToolBar::mFrameParent
ToolBarFrame * mFrameParent
Definition: ExpandingToolBar.h:106
ExpandingToolBar::TryAutoCollapse
void TryAutoCollapse()
Definition: ExpandingToolBar.cpp:261
ExpandingToolBar::mTimer
wxTimer mTimer
Definition: ExpandingToolBar.h:105
ToolBarArea::RestoreArrangement
void RestoreArrangement(std::unique_ptr< ToolBarArrangement > &&arrangement)
Definition: ExpandingToolBar.cpp:1200
ExpandingToolBar::ReparentExtraPanel
void ReparentExtraPanel()
Definition: ExpandingToolBar.cpp:408
ToolBarArea::SaveArrangement
std::unique_ptr< ToolBarArrangement > SaveArrangement()
Definition: ExpandingToolBar.cpp:1186
ToolBarArea::RemoveChild
void RemoveChild(ExpandingToolBar *child)
Definition: ExpandingToolBar.cpp:1164
ExpandingToolBar::mAutoExpand
bool mAutoExpand
Definition: ExpandingToolBar.h:95
kTimerID
@ kTimerID
Definition: ExpandingToolBar.cpp:89
kMyTimerInterval
const int kMyTimerInterval
Definition: ExpandingToolBar.cpp:84
ExpandingToolBar::mDialogParent
ToolBarDialog * mDialogParent
Definition: ExpandingToolBar.h:107
ToolBarArea::MoveChild
void MoveChild(ExpandingToolBar *child, wxRect dropTarget)
Definition: ExpandingToolBar.cpp:1253
ExpandingToolBar::IsCursorInWindow
bool IsCursorInWindow()
Definition: ExpandingToolBar.cpp:392
ExpandingToolBar::mTopLevelParent
wxWindow * mTopLevelParent
Definition: ExpandingToolBar.h:112
ToolBarDialog::SetChild
void SetChild(ExpandingToolBar *child)
Definition: ExpandingToolBar.cpp:757
AButton::PushDown
void PushDown()
Definition: AButton.cpp:597
ExpandingToolBar::mHandlers
std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > mHandlers
Definition: ExpandingToolBar.h:121
ToolBarArea::CollapseAll
void CollapseAll(bool now=false)
Definition: ExpandingToolBar.cpp:1148
ExpandingToolBar::mSavedArrangement
std::unique_ptr< ToolBarArrangement > mSavedArrangement
Definition: ExpandingToolBar.h:109
ExpandingToolBar::GetToolbarBitmap
wxBitmap GetToolbarBitmap()
Definition: ExpandingToolBar.cpp:494
ExpandingToolBar::mDragImage
std::unique_ptr< wxDragImage > mDragImage
Definition: ExpandingToolBar.h:111
ExpandingToolBar::mTargetPanel
ImageRollPanel * mTargetPanel
Definition: ExpandingToolBar.h:110
ExpandingToolBar::mFirstTime
bool mFirstTime
Definition: ExpandingToolBar.h:96
ExpandingToolBar::mIsAutoExpanded
bool mIsAutoExpanded
Definition: ExpandingToolBar.h:92
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
ExpandingToolBar::mGrabber
ToolBarGrabber * mGrabber
Definition: ExpandingToolBar.h:90
ExpandingToolBar::MoveDrawer
void MoveDrawer(wxSize prevSize)
Definition: ExpandingToolBar.cpp:426
ExpandingToolBar::RecursivelyPushEventHandlers
void RecursivelyPushEventHandlers(wxWindow *win)
Definition: ExpandingToolBar.cpp:309
ImageRollPanel::SetLogicalFunction
void SetLogicalFunction(int func)
Definition: ImageRoll.cpp:446
ExpandingToolBar::msNoAutoExpandStack
static int msNoAutoExpandStack
Definition: ExpandingToolBar.h:116
ExpandingToolBar::mExtraSize
wxSize mExtraSize
Definition: ExpandingToolBar.h:98
safenew
#define safenew
Definition: MemoryX.h:10
ExpandingToolBar::mExtraPanel
wxPanel * mExtraPanel
Definition: ExpandingToolBar.h:89
ExpandingToolBar::TryAutoExpand
void TryAutoExpand()
Definition: ExpandingToolBar.cpp:251
ExpandingToolBar::mTargetDrawerSize
wxSize mTargetDrawerSize
Definition: ExpandingToolBar.h:102
ExpandingToolBar::mButtonSize
wxSize mButtonSize
Definition: ExpandingToolBar.h:99
ToolBarDialog
A dialog based container for ExpandingToolBars providing modal based operations.
Definition: ExpandingToolBar.h:148
ImageRollPanel
A wxPanel which displays an ImageRoll.
Definition: ImageRoll.h:75
ToolBarArea::GetDropTargets
std::vector< wxRect > GetDropTargets()
Definition: ExpandingToolBar.cpp:1217
ToolBarArea::AddChild
void AddChild(ExpandingToolBar *child)
Definition: ExpandingToolBar.cpp:1156
ExpandingToolBar::mDropTarget
wxRect mDropTarget
Definition: ExpandingToolBar.h:114