#include "formitemselection.h"
#include "ui_formitemselection.h"

#include "mainwindow.h"

#include <QResizeEvent>
#include <QMouseEvent>
#include <QDebug>

FormItemSelection::FormItemSelection(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormItemSelection)
{
    ui->setupUi(this);    
    m_pTableHeader = NULL;

    connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(Clicked()));

    int nDisplayType = MainWindow::GetCommonData()->GetDisplayType();
    int nFontSize = 24;
    int nCellHeight = 80;
    if(nDisplayType==SDISPLAY_1280X1024)
    {
        ui->label_Info->setStyleSheet("QLabel \n"
        "{ \n"
        "    font-family: 'Roboto';\n"
        "    font-size: 18px;\n"
        "    font-weight: normal;\n"
        "    background: transparent;\n"
        "    color:  #202020;\n"
        "}");
    }
    else if(nDisplayType==SDISPLAY_1920X1080)
    {
        ui->label_Info->setStyleSheet("QLabel \n"
        "{ \n"
        "    font-family: 'Roboto';\n"
        "    font-size: 24px;\n"
        "    font-weight: normal;\n"
        "    background: transparent;\n"
        "    color:  #202020;\n"
        "}");
    }
}

FormItemSelection::~FormItemSelection()
{
    delete ui;
}

void FormItemSelection::resizeEvent(QResizeEvent *event)
{
    QSize nSize = size();
    //ui->verticalLayoutWidget->setGeometry(0, 0, nSize.width(), nSize.height());
    //ui->frame_background->setGeometry(0, 0, nSize.width(), nSize.height());

    qDebug() << "x: " << nSize.width() << ", y: "<< nSize.height();
}


void FormItemSelection::SetText(QString strText)
{
    ui->label_Info->setText(strText);
}

void FormItemSelection::SetTableHeader(TableHeader* pTableHeader)
{
    m_pTableHeader = pTableHeader;
    ui->label_Info->setText(m_pTableHeader->m_strText);
    ui->pushButton->setChecked(pTableHeader->m_bSelect);
}

void FormItemSelection::mousePressEvent(QMouseEvent *event)
{

}

void FormItemSelection::mouseReleaseEvent(QMouseEvent *event)
{
    Clicked();
}

void FormItemSelection::mouseMoveEvent(QMouseEvent *event)
{

}

void FormItemSelection::Clicked()
{
    if(m_pTableHeader->m_bSelect==true)
    {
        m_pTableHeader->m_bSelect = false;
    }
    else
    {
        m_pTableHeader->m_bSelect = true;
    }

    ui->pushButton->setChecked(m_pTableHeader->m_bSelect);
}
