Audacity 3.2.0
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 68 of file ToolBar.cpp.

Constructor & Destructor Documentation

◆ ToolBarResizer()

ToolBarResizer::ToolBarResizer ( ToolBar mBar)

Definition at line 115 of file ToolBar.cpp.

116: wxWindow(bar, wxID_ANY, wxDefaultPosition, wxSize(RWIDTH, -1))
117{
118 mBar = bar;
119 SetCursor( wxCURSOR_SIZEWE );
120}
#define RWIDTH
ToolBarResizer.
Definition: ToolBar.cpp:63
ToolBar * mBar
Definition: ToolBar.cpp:92

◆ ~ToolBarResizer()

ToolBarResizer::~ToolBarResizer ( )
virtual

Definition at line 122 of file ToolBar.cpp.

123{
124 if(HasCapture())
125 ReleaseMouse();
126}

Member Function Documentation

◆ AcceptsFocusFromKeyboard()

bool ToolBarResizer::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 77 of file ToolBar.cpp.

77{return false;}

◆ OnCaptureLost()

void ToolBarResizer::OnCaptureLost ( wxMouseCaptureLostEvent &  event)
private

Definition at line 279 of file ToolBar.cpp.

280{
281 if( HasCapture() )
282 {
283 ReleaseMouse();
284 if (mOrigFocus)
285 mOrigFocus->SetFocus();
286 mOrigFocus = nullptr;
287 }
288}
wxWindowRef mOrigFocus
Definition: ToolBar.cpp:95

References mOrigFocus.

◆ OnEnter()

void ToolBarResizer::OnEnter ( wxMouseEvent &  event)
private

Definition at line 196 of file ToolBar.cpp.

197{
198 // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed
199 // to make it pop up when we want it.
200 const auto text = GetToolTipText();
201 UnsetToolTip();
202 SetToolTip(text);
203 if (!mOrigFocus)
205}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:383

References BasicUI::FindFocus(), and mOrigFocus.

Here is the call graph for this function:

◆ OnErase()

void ToolBarResizer::OnErase ( wxEraseEvent &  event)
private

Definition at line 131 of file ToolBar.cpp.

132{
133 // Ignore it to prevent flashing
134}

◆ OnKeyDown()

void ToolBarResizer::OnKeyDown ( wxKeyEvent &  event)
private

Definition at line 290 of file ToolBar.cpp.

291{
292 event.Skip();
293 if (HasCapture() && WXK_ESCAPE == event.GetKeyCode()) {
295 ReleaseMouse();
296 if (mOrigFocus)
297 mOrigFocus->SetFocus();
298 mOrigFocus = nullptr;
299 }
300}
wxSize mOrigSize
Definition: ToolBar.cpp:94
void ResizeBar(const wxSize &size)
Definition: ToolBar.cpp:267

References mOrigFocus, mOrigSize, and ResizeBar().

Here is the call graph for this function:

◆ OnLeave()

void ToolBarResizer::OnLeave ( wxMouseEvent &  event)
private

Definition at line 207 of file ToolBar.cpp.

208{
209 if (!GetCapture())
210 mOrigFocus = nullptr;
211}

References mOrigFocus.

◆ OnLeftDown()

void ToolBarResizer::OnLeftDown ( wxMouseEvent &  event)
private

Definition at line 163 of file ToolBar.cpp.

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

References mBar, mOrigSize, and mResizeOffset.

◆ OnLeftUp()

void ToolBarResizer::OnLeftUp ( wxMouseEvent &  event)
private

Definition at line 181 of file ToolBar.cpp.

182{
183 // Go ahead and set the event to propagate
184 event.Skip();
185
186 if( HasCapture() )
187 {
188 ReleaseMouse();
189 if (mOrigFocus)
190 mOrigFocus->SetFocus();
191 mOrigFocus = nullptr;
193 }
194}
virtual void ResizingDone()
Definition: ToolBar.h: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 213 of file ToolBar.cpp.

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

References mBar, mResizeOffset, and ResizeBar().

Here is the call graph for this function:

◆ OnPaint()

void ToolBarResizer::OnPaint ( wxPaintEvent &  event)
private

Definition at line 139 of file ToolBar.cpp.

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

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 267 of file ToolBar.cpp.

268{
269 mBar->SetSize( size );
270
271 // Tell everyone we've changed sizes
272 mBar->Updated();
273
274 // Refresh our world
275 mBar->GetParent()->Refresh();
276 mBar->GetParent()->Update();
277}
void Updated()
Definition: ToolBar.cpp:684

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 92 of file ToolBar.cpp.

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

◆ mOrigFocus

wxWindowRef ToolBarResizer::mOrigFocus {}
private

Definition at line 95 of file ToolBar.cpp.

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

◆ mOrigSize

wxSize ToolBarResizer::mOrigSize
private

Definition at line 94 of file ToolBar.cpp.

Referenced by OnKeyDown(), and OnLeftDown().

◆ mResizeOffset

wxPoint ToolBarResizer::mResizeOffset
private

Definition at line 93 of file ToolBar.cpp.

Referenced by OnLeftDown(), and OnMotion().


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