-
Notifications
You must be signed in to change notification settings - Fork 1
/
wxBitmapSpinButton.cpp
76 lines (67 loc) · 1.64 KB
/
wxBitmapSpinButton.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "wxBitmapSpinButton.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
BEGIN_EVENT_TABLE(wxBitmapSpinButton, wxSpinButton)
EVT_KEY_DOWN(wxBitmapSpinButton::OnKeyDown)
EVT_KEY_UP(wxBitmapSpinButton::OnKeyUp)
EVT_PAINT(wxBitmapSpinButton::OnPaint)
END_EVENT_TABLE()
void wxBitmapSpinButton::Create(wxWindow* parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
{
wxSpinButton::Create( parent, id, pos, size, style );
}
void wxBitmapSpinButton::OnPaint( wxPaintEvent& event )
{
// Draw the image if we have one, otherwise draw a default graphic.
if( _image.Ok() )
{
wxPaintDC dc(this);
wxBitmap buttonBitmap( _image );
dc.DrawBitmap( buttonBitmap, 0, 0, true );
}
event.Skip(false);
}
void wxBitmapSpinButton::OnKeyDown( wxKeyEvent& event )
{
wxWindow* parent = this->GetParent();
if( parent )
{
parent->GetEventHandler()->ProcessEvent( event );
}
//event.Skip(true);
}
void wxBitmapSpinButton::OnKeyUp( wxKeyEvent& event )
{
wxWindow* parent = this->GetParent();
if( parent )
{
parent->GetEventHandler()->ProcessEvent( event );
}
//event.Skip(true);
}
/**
@brief Set bitmap for drawing button.
*/
void wxBitmapSpinButton::SetBitmap( wxImage * image)
{
if( !image )
{
return;
}
//_lightLock.lock();
_image = *image;
//_lightLock.unlock();
}
/**
@brief Set bitmap for drawing button.
*/
void wxBitmapSpinButton::SetBitmap( wxBitmap * image)
{
if( !image )
{
return;
}
//_lightLock.lock();
_image = image->ConvertToImage();
//_lightLock.unlock();
}