예제 #1
0
파일: VolumeDial.cpp 프로젝트: g4klx/uWSDR
bool CVolumeDial::Enable(bool enable)
{
	bool ret = wxPanel::Enable(enable);

	drawDial();

	return ret;
}
예제 #2
0
void qmidictlDialStyle::drawComplexControl (
	ComplexControl cc, const QStyleOptionComplex *optc,
	QPainter *painter, const QWidget *widget) const
{
	if (cc == QStyle::CC_Dial) {
		const QStyleOptionSlider *option
			= qstyleoption_cast<const QStyleOptionSlider *> (optc);
		if (option) {
			drawDial(option, painter);
			return;
		}
	}

	QCommonStyle::drawComplexControl(cc, optc, painter, widget);
}
예제 #3
0
파일: VolumeDial.cpp 프로젝트: g4klx/uWSDR
void CVolumeDial::onMouse(wxMouseEvent& event)
{
	if (!event.LeftIsDown())
		return;

	long diffX = event.GetX() - m_width / 2;
	long diffY = m_height / 2 - event.GetY();
	int   dist = int(::sqrt(double(diffX * diffX + diffY * diffY)) + 0.5);

	if (dist > (m_width - 2) / 2) {
		if (event.LeftDown())
			event.Skip();

		return;
	}

	double angle = 180.0 * ::atan2(double(diffY), double(-diffX)) / M_PI;

	if (angle < -90.0)
		angle += 450.0;
	else
		angle += 90.0;

	if (angle < 45.0 || angle > 315.0) {
		if (event.LeftDown())
			event.Skip();

		return;
	}

	angle -= 45.0;

	int value = m_min + int((angle / 270.0) * double(m_max - m_min));

	if (value != m_value) {
		m_value = value;

		m_callback->dialMoved(GetId(), m_value);

		drawDial();
	}

	if (event.LeftDown())
		event.Skip();
}
예제 #4
0
파일: VolumeDial.cpp 프로젝트: g4klx/uWSDR
CVolumeDial::CVolumeDial(wxWindow* parent, int id, int min, int max, int value, IDialCallback* callback, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
wxPanel(parent, id, pos, size, style, name),
m_width(size.GetWidth()),
m_height(size.GetHeight()),
m_callback(callback),
m_bitmap(NULL),
m_min(min),
m_max(max),
m_value(value)
{
	wxASSERT(m_max > m_min);
	wxASSERT(m_value >= m_min && value < m_max);
	wxASSERT(m_width == m_height);
	wxASSERT(m_callback != NULL);

	m_bitmap = new wxBitmap(m_width, m_height);

	drawDial();
}
예제 #5
0
CFreqDial::CFreqDial(wxWindow* parent, int id, IDialCallback* callback, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
wxPanel(parent, id, pos, size, style, name),
m_menu(NULL),
m_width(size.GetWidth()),
m_height(size.GetHeight()),
m_callback(callback),
m_bitmap(NULL),
m_angle(0.0),
m_mult(9)
{
	wxASSERT(m_height == m_width);
	wxASSERT(m_callback != NULL);

	m_bitmap = new wxBitmap(m_width, m_height);

	m_menu = new wxMenu();
	m_menu->AppendRadioItem(MENU_1X,  _("1x"));
	m_menu->AppendRadioItem(MENU_4X,  _("4x"));
	m_menu->AppendRadioItem(MENU_9X,  _("9x"));
	m_menu->AppendRadioItem(MENU_16X, _("16x"));
	m_menu->AppendRadioItem(MENU_25X, _("25x"));

	drawDial();
}
예제 #6
0
void CFreqDial::onMouse(wxMouseEvent& event)
{
	if (!event.LeftIsDown())
		return;

	long diffX = event.GetX() - m_width / 2;
	long diffY = m_height / 2 - event.GetY();
	int   dist = int(::sqrt(double(diffX * diffX + diffY * diffY)) + 0.5);

	if (dist > (m_width - 2) / 2) {
		if (event.LeftDown())
			event.Skip();

		return;
	}

	double angle = 180.0 * ::atan2(double(diffY), double(-diffX)) / M_PI;

	if (angle < -90.0)
		angle += 450.0;
	else
		angle += 90.0;

	if (angle != m_angle) {
		int value = (angle > m_angle) ? 1 : -1;

		m_angle = angle;

		m_callback->dialMoved(GetId(), value * m_mult);

		drawDial();
	}

	if (event.LeftDown())
		event.Skip();
}
예제 #7
0
파일: VolumeDial.cpp 프로젝트: g4klx/uWSDR
void CVolumeDial::setValue(unsigned int value)
{
	m_value = value;

	drawDial();
}