Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ToolBarResizer Class Referencefinal

a wxWindow that provides the resizer for a toolbar on the right hand side. Responsible for drawing the resizer appearance, resizing mouse events and constraining the resizing. More...

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

Public Member Functions

 ToolBarResizer (ToolBar *mBar)
 
virtual ~ToolBarResizer ()
 
bool AcceptsFocusFromKeyboard () const override
 

Private Member Functions

void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnLeftDown (wxMouseEvent &event)
 
void OnLeftUp (wxMouseEvent &event)
 
void OnEnter (wxMouseEvent &event)
 
void OnLeave (wxMouseEvent &event)
 
void OnMotion (wxMouseEvent &event)
 
void ResizeBar (const wxSize &size)
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 

Private Attributes

ToolBarmBar
 
wxPoint mResizeOffset
 
wxSize mOrigSize
 
wxWindowRef mOrigFocus {}
 

Detailed Description

a wxWindow that provides the resizer for a toolbar on the right hand side. Responsible for drawing the resizer appearance, resizing mouse events and constraining the resizing.

Definition at line 70 of file ToolBar.cpp.

Constructor & Destructor Documentation

◆ ToolBarResizer()

ToolBarResizer::ToolBarResizer ( ToolBar mBar)

Definition at line 117 of file ToolBar.cpp.

118 : wxWindow(bar, wxID_ANY, wxDefaultPosition, wxSize(RWIDTH, -1))
119 {
120  mBar = bar;
121  SetCursor( wxCURSOR_SIZEWE );
122 }

◆ ~ToolBarResizer()

ToolBarResizer::~ToolBarResizer ( )
virtual

Definition at line 124 of file ToolBar.cpp.

125 {
126  if(HasCapture())
127  ReleaseMouse();
128 }

Member Function Documentation

◆ AcceptsFocusFromKeyboard()

bool ToolBarResizer::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 79 of file ToolBar.cpp.

79 {return false;}

◆ OnCaptureLost()

void ToolBarResizer::OnCaptureLost ( wxMouseCaptureLostEvent &  event)
private

Definition at line 281 of file ToolBar.cpp.

282 {
283  if( HasCapture() )
284  {
285  ReleaseMouse();
286  if (mOrigFocus)
287  mOrigFocus->SetFocus();
288  mOrigFocus = nullptr;
289  }
290 }

References mOrigFocus.

◆ OnEnter()

void ToolBarResizer::OnEnter ( wxMouseEvent &  event)
private

Definition at line 198 of file ToolBar.cpp.

199 {
200  // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed
201  // to make it pop up when we want it.
202  const auto text = GetToolTipText();
203  UnsetToolTip();
204  SetToolTip(text);
205  if (!mOrigFocus)
206  mOrigFocus = FindFocus();
207 }

References mOrigFocus.

◆ OnErase()

void ToolBarResizer::OnErase ( wxEraseEvent &  event)
private

Definition at line 133 of file ToolBar.cpp.

134 {
135  // Ignore it to prevent flashing
136 }

◆ OnKeyDown()

void ToolBarResizer::OnKeyDown ( wxKeyEvent &  event)
private

Definition at line 292 of file ToolBar.cpp.

293 {
294  event.Skip();
295  if (HasCapture() && WXK_ESCAPE == event.GetKeyCode()) {
296  ResizeBar( mOrigSize );
297  ReleaseMouse();
298  if (mOrigFocus)
299  mOrigFocus->SetFocus();
300  mOrigFocus = nullptr;
301  }
302 }

References mOrigFocus, mOrigSize, and ResizeBar().

Here is the call graph for this function:

◆ OnLeave()

void ToolBarResizer::OnLeave ( wxMouseEvent &  event)
private

Definition at line 209 of file ToolBar.cpp.

210 {
211  if (!GetCapture())
212  mOrigFocus = nullptr;
213 }

References mOrigFocus.

◆ OnLeftDown()

void ToolBarResizer::OnLeftDown ( wxMouseEvent &  event)
private

Definition at line 165 of file ToolBar.cpp.

166 {
167  // Go ahead and set the event to propagate
168  event.Skip();
169 
170  // Retrieve the mouse position
171  // Bug 1896: This is at time of processing the event, rather than at time
172  // of generation of event. Works around event.GetPosition() giving
173  // incorrect values if position of resizer is changing.
174  mResizeOffset = wxGetMousePosition()-mBar->GetRect().GetBottomRight();
175 
176  mOrigSize = mBar->GetSize();
177 
178  // We want all of the mouse events
179  if( !HasCapture() )
180  CaptureMouse();
181 }

References mBar, mOrigSize, and mResizeOffset.

◆ OnLeftUp()

void ToolBarResizer::OnLeftUp ( wxMouseEvent &  event)
private

Definition at line 183 of file ToolBar.cpp.

184 {
185  // Go ahead and set the event to propagate
186  event.Skip();
187 
188  if( HasCapture() )
189  {
190  ReleaseMouse();
191  if (mOrigFocus)
192  mOrigFocus->SetFocus();
193  mOrigFocus = nullptr;
194  mBar->ResizingDone();
195  }
196 }

References mBar, mOrigFocus, and ToolBar::ResizingDone().

Here is the call graph for this function:

◆ OnMotion()

void ToolBarResizer::OnMotion ( wxMouseEvent &  event)
private

Definition at line 215 of file ToolBar.cpp.

216 {
217  // Go ahead and set the event to propagate
218  event.Skip();
219 
220  if( HasCapture() && event.Dragging() )
221  {
222  // Retrieve the mouse position
223  // Bug 1896: This is at time of processing the event, rather than at time
224  // of generation of event. Works around event.GetPosition() giving
225  // incorrect values if position of resizer is changing.
226  wxPoint pos = wxGetMousePosition();
227 
228  wxRect r = mBar->GetRect();
229  wxSize minsz = mBar->GetMinSize();
230  wxSize maxsz = mBar->GetMaxSize();
231  wxSize psz = mBar->GetParent()->GetClientSize();
232 
233  // Adjust the size based on updated mouse position.
234  r.width = ( pos.x - mResizeOffset.x ) - r.x;
235 
236  // Keep it within max size, if specified
237  if( maxsz != wxDefaultSize )
238  {
239  if( r.width > maxsz.x )
240  {
241  r.width = maxsz.x;
242  }
243  if( r.height > maxsz.y )
244  {
245  r.height = maxsz.y;
246  }
247  }
248 
249  // Constrain
250  if( r.width < minsz.x )
251  {
252  // Don't allow resizing to go too small
253  r.width = minsz.x;
254  }
255  else if( r.GetRight() > psz.x - 3 )
256  {
257  // Don't allow resizing to go too large
258  //
259  // The 3 magic pixels are because I'm too chicken to change the
260  // calculations in ToolDock::LayoutToolBars() even though I'm
261  // the one that set them up. :-)
262  r.SetRight( psz.x - 3 );
263  }
264 
265  ResizeBar( r.GetSize() );
266  }
267 }

References mBar, mResizeOffset, and ResizeBar().

Here is the call graph for this function:

◆ OnPaint()

void ToolBarResizer::OnPaint ( wxPaintEvent &  event)
private

Definition at line 141 of file ToolBar.cpp.

142 {
143  wxPaintDC dc( (wxWindow *) event.GetEventObject() );
144 
145  // Start with a clean background
146  //
147  // Under GTK, we specifically set the toolbar background to the background
148  // colour in the system theme.
149 #if defined( __WXGTK__ )
150 // dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
151 #endif
152  dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
153  dc.Clear();
154 
155  wxSize sz = GetSize();
156 
157  AColor::Dark( &dc, false );
158  AColor::Line(dc, sz.x - 4, 0, sz.x - 4, sz.y );
159  AColor::Line(dc, sz.x - 1, 0, sz.x - 1, sz.y );
160 }

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

Here is the call graph for this function:

◆ ResizeBar()

void ToolBarResizer::ResizeBar ( const wxSize &  size)
private

Definition at line 269 of file ToolBar.cpp.

270 {
271  mBar->SetSize( size );
272 
273  // Tell everyone we've changed sizes
274  mBar->Updated();
275 
276  // Refresh our world
277  mBar->GetParent()->Refresh();
278  mBar->GetParent()->Update();
279 }

References mBar, size, and ToolBar::Updated().

Referenced by OnKeyDown(), and OnMotion().

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

Member Data Documentation

◆ mBar

ToolBar* ToolBarResizer::mBar
private

Definition at line 94 of file ToolBar.cpp.

Referenced by OnLeftDown(), OnLeftUp(), OnMotion(), and ResizeBar().

◆ mOrigFocus

wxWindowRef ToolBarResizer::mOrigFocus {}
private

Definition at line 97 of file ToolBar.cpp.

Referenced by OnCaptureLost(), OnEnter(), OnKeyDown(), OnLeave(), and OnLeftUp().

◆ mOrigSize

wxSize ToolBarResizer::mOrigSize
private

Definition at line 96 of file ToolBar.cpp.

Referenced by OnKeyDown(), and OnLeftDown().

◆ mResizeOffset

wxPoint ToolBarResizer::mResizeOffset
private

Definition at line 95 of file ToolBar.cpp.

Referenced by OnLeftDown(), and OnMotion().


The documentation for this class was generated from the following file:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ToolBar::ResizingDone
virtual void ResizingDone()
Definition: ToolBar.h:186
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
ToolBarResizer::mOrigSize
wxSize mOrigSize
Definition: ToolBar.cpp:96
ToolBarResizer::ResizeBar
void ResizeBar(const wxSize &size)
Definition: ToolBar.cpp:269
RWIDTH
#define RWIDTH
ToolBarResizer.
Definition: ToolBar.cpp:65
ToolBarResizer::mBar
ToolBar * mBar
Definition: ToolBar.cpp:94
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:82
ToolBarResizer::mOrigFocus
wxWindowRef mOrigFocus
Definition: ToolBar.cpp:97
AColor::Dark
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:351
ToolBarResizer::mResizeOffset
wxPoint mResizeOffset
Definition: ToolBar.cpp:95
ToolBar::Updated
void Updated()
Definition: ToolBar.cpp:661
ThemeBase::Colour
wxColour & Colour(int iIndex)