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

#include <BackedPanel.h>

Inheritance diagram for BackedPanel:
wxPanelWrapper wxTabTraversalWrapper< wxPanel > OverlayPanel AdornedRulerPanel TrackPanel

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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

Private Attributes

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

Detailed Description

Definition at line 16 of file BackedPanel.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file BackedPanel.cpp.

References mBacking, and mBackingDC.

16 : wxPanelWrapper(parent, id, pos, size, style)
17 , mBacking{ std::make_unique<wxBitmap>(1, 1) }
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:39
std::unique_ptr< wxBitmap > mBacking
Definition: BackedPanel.h:38
BackedPanel::~BackedPanel ( )

Definition at line 24 of file BackedPanel.cpp.

References mBacking, and mBackingDC.

25 {
26  if (mBacking)
27  mBackingDC.SelectObject( wxNullBitmap );
28 }
wxMemoryDC mBackingDC
Definition: BackedPanel.h:39
std::unique_ptr< wxBitmap > mBacking
Definition: BackedPanel.h:38

Member Function Documentation

void BackedPanel::DisplayBitmap ( wxDC &  dc)

Definition at line 65 of file BackedPanel.cpp.

References mBacking, and RepairBitmap().

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

66 {
67  RepairBitmap(dc, 0, 0, mBacking->GetWidth(), mBacking->GetHeight());
68 }
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition: BackedPanel.cpp:60
std::unique_ptr< wxBitmap > mBacking
Definition: BackedPanel.h:38
wxDC & BackedPanel::GetBackingDC ( )

Definition at line 30 of file BackedPanel.cpp.

References mBackingDC.

Referenced by OverlayPanel::DrawOverlays().

31 {
32  return mBackingDC;
33 }
wxMemoryDC mBackingDC
Definition: BackedPanel.h:39
wxDC & BackedPanel::GetBackingDCForRepaint ( )

Definition at line 35 of file BackedPanel.cpp.

References mBackingDC, mResizeBacking, and ResizeBacking().

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

36 {
37  if (mResizeBacking)
38  {
39  // Reset
40  mResizeBacking = false;
41 
42  ResizeBacking();
43  }
44 
45  return mBackingDC;
46 }
void ResizeBacking()
Definition: BackedPanel.cpp:48
wxMemoryDC mBackingDC
Definition: BackedPanel.h:39
bool mResizeBacking
Definition: BackedPanel.h:40
void BackedPanel::OnSize ( wxSizeEvent &  event)

Definition at line 70 of file BackedPanel.cpp.

References mResizeBacking.

Referenced by AdornedRulerPanel::OnSize().

71 {
72  // Tell OnPaint() to recreate the backing bitmap
73  mResizeBacking = true;
74 
75  // Refresh the entire area. Really only need to refresh when
76  // expanding...is it worth the trouble?
77  Refresh();
78 }
bool mResizeBacking
Definition: BackedPanel.h:40
void BackedPanel::RepairBitmap ( wxDC &  dc,
wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height 
)

Definition at line 60 of file BackedPanel.cpp.

References mBackingDC.

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

61 {
62  dc.Blit(x, y, width, height, &mBackingDC, x, y);
63 }
wxMemoryDC mBackingDC
Definition: BackedPanel.h:39
void BackedPanel::ResizeBacking ( )

Definition at line 48 of file BackedPanel.cpp.

References mBacking, and mBackingDC.

Referenced by GetBackingDCForRepaint().

49 {
50  // Delete the backing bitmap
51  if (mBacking)
52  mBackingDC.SelectObject(wxNullBitmap);
53 
54  wxSize sz = GetClientSize();
55  mBacking = std::make_unique<wxBitmap>();
56  mBacking->Create(sz.x, sz.y); //, *dc);
57  mBackingDC.SelectObject(*mBacking);
58 }
wxMemoryDC mBackingDC
Definition: BackedPanel.h:39
std::unique_ptr< wxBitmap > mBacking
Definition: BackedPanel.h:38

Member Data Documentation

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

Definition at line 38 of file BackedPanel.h.

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

wxMemoryDC BackedPanel::mBackingDC
private
bool BackedPanel::mResizeBacking {}
private

Definition at line 40 of file BackedPanel.h.

Referenced by GetBackingDCForRepaint(), and OnSize().


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