#include "scalendarmenuview.h" #include #include #include SCalendarMenuView::SCalendarMenuView(QWidget *parent) : QWidget(parent) { m_strText = ""; m_nID = 0; m_nFontSize = 18; Unselect(); } SCalendarMenuView::~SCalendarMenuView() { } void SCalendarMenuView::paintEvent(QPaintEvent *event) { QPainter painter(this); QSize nSize = size(); int nPaddingLeft = 0; QRect rectDisplay = QRect(nPaddingLeft, 0, nSize.width()-nPaddingLeft, nSize.height()); QColor colorBackground; if(m_bSelected==false) { colorBackground = Qt::white; } else { colorBackground = Qt::gray; } painter.fillRect(rectDisplay, colorBackground); nPaddingLeft = 20; rectDisplay = QRect(nPaddingLeft, 0, nSize.width()-nPaddingLeft, nSize.height()); QFont font("Roboto"); font.setPixelSize(m_nFontSize); painter.setFont(font); painter.setPen(Qt::black); painter.drawText(rectDisplay, Qt::AlignLeft | Qt::AlignVCenter, m_strText); } void SCalendarMenuView::mousePressEvent(QMouseEvent *event) { } void SCalendarMenuView::mouseReleaseEvent(QMouseEvent *event) { Select(); update(); ExecuteMenu(m_nID); } void SCalendarMenuView::SetText(QString strText) { m_strText = strText; } void SCalendarMenuView::SetID(int nID) { m_nID = nID; } void SCalendarMenuView::SetData(int nID, QString strText) { SetText(strText); SetID(nID); } int SCalendarMenuView::GetID() { return m_nID; } void SCalendarMenuView::Select() { m_bSelected = true; } void SCalendarMenuView::Unselect() { m_bSelected = false; } bool SCalendarMenuView::IsSelected() { return m_bSelected; } void SCalendarMenuView::SetFontSize(int nFontSize) { m_nFontSize = nFontSize; }