-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwxStaticRotaryEncoder.h
83 lines (66 loc) · 2.46 KB
/
wxStaticRotaryEncoder.h
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
77
78
79
80
81
82
83
/***************************************************************
* Name: wxStaticRotaryEncoder.h
* Purpose: Rotary encoder widgets for wxWidgets applications
* Author: Benoit BOUCHEZ (BEB)
* Created: 2020-04-11
* Copyright: (c) Benoit BOUCHEZ
* License: wxWidgets license
**************************************************************/
#ifndef __STATICROTARYENCODER_H__
#define __STATICROTARYENCODER_H__
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
// Event generated by this control
const int wxEVT_ENCODER_FIRST = wxEVT_FIRST + 5402;
const wxEventType wxEVT_ENCODER_CHANGE = wxEVT_ENCODER_FIRST + 1;
#define EVT_ROTARYENCODER_CHANGE(id, fn) \
DECLARE_EVENT_TABLE_ENTRY(wxEVT_ENCODER_CHANGE, id, -1, \
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&fn, \
(wxObject*)NULL ),
class WXDLLIMPEXP_CORE wxStaticRotaryEncoder : public wxControl
{
public:
wxStaticRotaryEncoder () { Init(); }
wxStaticRotaryEncoder(wxWindow *parent,
wxWindowID id,
wxBitmap& backgroundBitmap,
int MinimumValue,
int MaximumValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
// Nothing allocated dynamically by the class : keep the default destructor
// virtual ~wxStaticRotaryEncoder();
int GetValue() { return mValue ; };
void SetValue(int value);
void SetMinValue (int Value);
void SetMaxValue (int Value);
protected:
void Init(void);
private:
DECLARE_DYNAMIC_CLASS(wxStaticRotaryEncoder)
DECLARE_EVENT_TABLE()
void OnPaint(wxPaintEvent& event);
void OnMouse(wxMouseEvent& event);
void Moved(void); // Called when encoder is moved
wxWindowID mId;
int mValue;
wxBitmap* mBackBitmap; // Background bitmap
bool MouseInControl; // Mouse cursor is on the control surface
wxSize mSize;
unsigned int PulseDivider; // Mouse ticks / value change ticks
int LastTouchX;
int LastTouchY;
bool EncoderActive; // Touch started in encoder area
int OneThirdX, TwoThirdX; // Control is splitted in 9 zones (quadrants)
int OneThirdY, TwoThirdY;
int mMin, mMax; // Minimum and maximum value
};
#endif // __STATICROTARYENCODER_H__