Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
BackedPanel Class Reference

BackedPanel is for a panel that consists of a bitmap with something drawn over it. It supports efficient repainting when the overlays change and recreation of the bitmap when the panel size is changed. More...

#include <BackedPanel.h>

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

Public Member Functions

 BackedPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
 
 ~BackedPanel ()
 
wxDC & GetBackingDC ()
 
wxDC & GetBackingDCForRepaint ()
 
void ResizeBacking ()
 
void RepairBitmap (wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
void DisplayBitmap (wxDC &dc)
 
void OnSize (wxSizeEvent &event)
 
- 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
 

Private Attributes

std::unique_ptr< wxBitmap > mBacking
 
wxMemoryDC mBackingDC
 
bool mResizeBacking {}
 

Detailed Description

BackedPanel is for a panel that consists of a bitmap with something drawn over it. It supports efficient repainting when the overlays change and recreation of the bitmap when the panel size is changed.

Definition at line 19 of file BackedPanel.h.

Constructor & Destructor Documentation

◆ BackedPanel()

BackedPanel::BackedPanel ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
long  style 
)

Definition at line 12 of file BackedPanel.cpp.

16: wxPanelWrapper(parent, id, pos, size, style)
17, mBacking{ std::make_unique<wxBitmap>(1, 1, 24) }
18{
19 // Preinit the backing DC and bitmap so routines that require it will
20 // not cause a crash if they run before the panel is fully initialized.
21 mBackingDC.SelectObject(*mBacking);
22}
wxMemoryDC mBackingDC
Definition: BackedPanel.h:37
std::unique_ptr< wxBitmap > mBacking
Definition: BackedPanel.h:36

References mBacking, and mBackingDC.

◆ ~BackedPanel()

BackedPanel::~BackedPanel ( )

Definition at line 24 of file BackedPanel.cpp.

25{
26 if (mBacking)
27 mBackingDC.SelectObject( wxNullBitmap );
28}

References mBacking, and mBackingDC.

Member Function Documentation

◆ DisplayBitmap()

void BackedPanel::DisplayBitmap ( wxDC &  dc)

Definition at line 65 of file BackedPanel.cpp.

66{
67 if( mBacking )
68 RepairBitmap(dc, 0, 0, mBacking->GetWidth(), mBacking->GetHeight());
69}
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition: BackedPanel.cpp:60

References mBacking, and RepairBitmap().

Referenced by TrackPanel::OnPaint(), and AdornedRulerPanel::OnPaint().

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

◆ GetBackingDC()

wxDC & BackedPanel::GetBackingDC ( )

Definition at line 30 of file BackedPanel.cpp.

31{
32 return mBackingDC;
33}

References mBackingDC.

Referenced by OverlayPanel::DrawOverlays().

Here is the caller graph for this function:

◆ GetBackingDCForRepaint()

wxDC & BackedPanel::GetBackingDCForRepaint ( )

Definition at line 35 of file BackedPanel.cpp.

36{
38 {
39 // Reset
40 mResizeBacking = false;
41
43 }
44
45 return mBackingDC;
46}
void ResizeBacking()
Definition: BackedPanel.cpp:48
bool mResizeBacking
Definition: BackedPanel.h:38

References mBackingDC, mResizeBacking, and ResizeBacking().

Referenced by TrackPanel::OnPaint(), and AdornedRulerPanel::OnPaint().

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

◆ OnSize()

void BackedPanel::OnSize ( wxSizeEvent &  event)

Definition at line 71 of file BackedPanel.cpp.

72{
73 // Tell OnPaint() to recreate the backing bitmap
74 mResizeBacking = true;
75 event.Skip();
76 // Refresh the entire area. Really only need to refresh when
77 // expanding...is it worth the trouble?
78 Refresh();
79}

References mResizeBacking.

Referenced by AdornedRulerPanel::OnSize().

Here is the caller graph for this function:

◆ RepairBitmap()

void BackedPanel::RepairBitmap ( wxDC &  dc,
wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height 
)

Definition at line 60 of file BackedPanel.cpp.

61{
62 dc.Blit(x, y, width, height, &mBackingDC, x, y);
63}

References mBackingDC.

Referenced by DisplayBitmap(), and TrackPanel::OnPaint().

Here is the caller graph for this function:

◆ ResizeBacking()

void BackedPanel::ResizeBacking ( )

Definition at line 48 of file BackedPanel.cpp.

49{
50 if (mBacking)
51 mBackingDC.SelectObject(wxNullBitmap);
52
53 wxSize sz = GetClientSize();
54 mBacking = std::make_unique<wxBitmap>();
55 // Bug 2040 - Avoid 0 x 0 bitmap when minimized.
56 mBacking->Create(std::max(sz.x,1), std::max(sz.y,1),24); //, *dc);
57 mBackingDC.SelectObject(*mBacking);
58}

References mBacking, and mBackingDC.

Referenced by GetBackingDCForRepaint().

Here is the caller graph for this function:

Member Data Documentation

◆ mBacking

std::unique_ptr<wxBitmap> BackedPanel::mBacking
private

Definition at line 36 of file BackedPanel.h.

Referenced by BackedPanel(), DisplayBitmap(), ResizeBacking(), and ~BackedPanel().

◆ mBackingDC

wxMemoryDC BackedPanel::mBackingDC
private

◆ mResizeBacking

bool BackedPanel::mResizeBacking {}
private

Definition at line 38 of file BackedPanel.h.

Referenced by GetBackingDCForRepaint(), and OnSize().


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