Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cloud::audiocom::UserImage Class Referencefinal

#include <UserImage.h>

Inheritance diagram for cloud::audiocom::UserImage:
[legend]
Collaboration diagram for cloud::audiocom::UserImage:
[legend]

Public Member Functions

 UserImage (wxWindow *parent, const wxSize &size)
 
void SetBitmap (const wxBitmap &bitmap)
 
void SetBitmap (const wxString &path)
 
- 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 Member Functions

void OnPaint ()
 

Private Attributes

wxBitmap mBitmap
 

Detailed Description

Definition at line 19 of file UserImage.h.

Constructor & Destructor Documentation

◆ UserImage()

cloud::audiocom::UserImage::UserImage ( wxWindow *  parent,
const wxSize &  size 
)

Definition at line 21 of file UserImage.cpp.

22 : wxPanelWrapper(parent, wxID_ANY, wxDefaultPosition, size, wxBORDER_NONE)
23{
24 SetBackgroundStyle(wxBG_STYLE_PAINT);
25
26 SetMinSize(size);
27 SetMaxSize(size);
28
29 Bind(wxEVT_PAINT, [this](auto&) { OnPaint(); });
30}

References OnPaint(), and size.

Here is the call graph for this function:

Member Function Documentation

◆ OnPaint()

void cloud::audiocom::UserImage::OnPaint ( )
private

Definition at line 49 of file UserImage.cpp.

50{
51 wxAutoBufferedPaintDC dc(this);
52 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
53
54 gc->SetInterpolationQuality(wxINTERPOLATION_BEST);
55
56 const wxSize size = GetSize();
57
58 gc->SetBrush(wxBrush(GetBackgroundColour()));
59 gc->DrawRectangle(0, 0, size.x, size.y);
60
61 if (!mBitmap.IsOk())
62 {
63 gc->SetBrush(wxBrush(wxColour(255, 255, 255, 255)));
64 gc->DrawEllipse(0, 0, size.x, size.y);
65 }
66 else
67 {
68 const wxSize resultingImageSize { std::min(size.x, mBitmap.GetWidth()),
69 std::min(size.y, mBitmap.GetHeight()) };
70
71 gc->DrawBitmap(
72 mBitmap,
73 (size.x - resultingImageSize.x) / 2,
74 (size.y - resultingImageSize.y) / 2,
75 resultingImageSize.x,
76 resultingImageSize.y);
77
78 auto path = gc->CreatePath();
79
80 path.MoveToPoint(0, 0);
81 path.AddLineToPoint(size.x / 2, 0);
82 path.AddArc(size.x / 2, size.y / 2, size.x / 2, 3 * M_PI_2, M_PI, false);
83 path.CloseSubpath();
84
85 path.MoveToPoint(size.x, 0);
86 path.AddLineToPoint(size.x, size.y / 2);
87 path.AddArc(size.x / 2, size.y / 2, size.x / 2, 0, 3 * M_PI_2, false);
88 path.CloseSubpath();
89
90 path.MoveToPoint(size.x, size.y);
91 path.AddLineToPoint(size.x / 2, size.y);
92 path.AddArc(size.x / 2, size.y / 2, size.x / 2, M_PI_2, 0, false);
93 path.CloseSubpath();
94
95 path.MoveToPoint(0, size.y);
96 path.AddLineToPoint(0, size.y / 2);
97 path.AddArc(size.x / 2, size.y / 2, size.x / 2, M_PI, M_PI_2, false);
98 path.CloseSubpath();
99
100 gc->DrawPath(path);
101 }
102}
int min(int a, int b)
#define M_PI_2
Definition: Distortion.cpp:33
#define M_PI
Definition: Distortion.cpp:30

References M_PI, M_PI_2, mBitmap, min(), and size.

Referenced by UserImage().

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

◆ SetBitmap() [1/2]

void cloud::audiocom::UserImage::SetBitmap ( const wxBitmap &  bitmap)

Definition at line 32 of file UserImage.cpp.

33{
34 mBitmap = bitmap;
35 Refresh(true);
36}

References mBitmap.

◆ SetBitmap() [2/2]

void cloud::audiocom::UserImage::SetBitmap ( const wxString &  path)

Definition at line 38 of file UserImage.cpp.

39{
40 wxImage image(path);
41
42 if (image.IsOk())
43 {
44 mBitmap = wxBitmap(image);
45 Refresh(true);
46 }
47}
wxImage(22, 22)

References mBitmap, and wxImage().

Here is the call graph for this function:

Member Data Documentation

◆ mBitmap

wxBitmap cloud::audiocom::UserImage::mBitmap
private

Definition at line 30 of file UserImage.h.

Referenced by OnPaint(), and SetBitmap().


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