#ifndef WORKING_DAMAGED_SLIDER_H
#define WORKING_DAMAGED_SLIDER_H

#include <QtGui>
#include <climits>
#include <cassert>
#include "softProj\DevicesWidget\sliderULongLong.h"

class WorkingDamagedSlider : public SliderULongLong {
Q_OBJECT
private:
	QString working_;
	QString damaged_;

	QString workingLabel_;
	QString damagedLabel_;
public:
	WorkingDamagedSlider(QWidget * parent) : SliderULongLong(parent) {
		workingLabel_ = QString::fromUtf16(L"Pracující");
		damagedLabel_ = QString::fromUtf16(L"Pokozené");
	}
protected:
	virtual void paintEvent(QPaintEvent * paintEvent) {
		SliderULongLong::paintEvent(paintEvent);

		QPainter painter(this);
		QFont font("tahoma", 8, QFont::Normal);

		painter.setRenderHint(QPainter::Antialiasing, true);
		painter.setPen(QColor::fromRgb(200, 200, 200));
		painter.setFont(font);

		QFontMetrics fm = painter.fontMetrics();
 
		painter.drawText(QRect(3, 3, width() - 6, height() - 6), working_);
		painter.drawText(QRect(3, 3, width() - 6, height() - 6), damaged_, QTextOption(Qt::AlignRight));

		painter.drawText(QRect(3, height() - fm.height() - 3, width() - 6, height() - 6), workingLabel_);
		painter.drawText(QRect(3, height() - fm.height() - 3, width() - 6, height() - 6), damagedLabel_, QTextOption(Qt::AlignRight));
	}
public:
	void setWorkingAndDamaged(unsigned long long working, unsigned long long damaged) {
		SliderULongLong::setMaximum(working + damaged);
		SliderULongLong::setValue(working);

		this->working_ = QString::number(working);
		this->damaged_ = QString::number(damaged);		
	}

	virtual void setValue(int value) {
		setWorkingAndDamaged(value, maximum() - value);
	}

	void drawRotatedText(QPainter * painter, float degrees, int x, int y, const QString &text)
	{
		painter->save();
		painter->translate(x, y);
		painter->rotate(degrees);
		painter->drawText(0, 0, text);
		painter->restore();
	}
};

#endif