/***************************************************************************
 *   Copyright (C) 2007 by Arnold Kraschinski                              *
 *   arnold.kra67@gmx.de                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/

#ifndef CHARBUTTONSH_H_
#define CHARBUTTONSH_H_

#include <QWidget>
#include <QRect>

class Trainer;

class QSvgRenderer;

/**
 * This widget provides buttons for the special characters ñ, á, é, í, ó, ú.
 * of the Spanish language.
 *
 * @short provides the character buttons for the program
 * @author Kraschinski Arnold <arnold.kra67@gmx.de>
 * @version 2.00.00
 */
class CharButtonsH : public QWidget
{
    Q_OBJECT
public:
    /** The constructor of the class
     */
    CharButtonsH(QWidget* parent = 0);

    /** Does the painting
     */
    void paintEvent(QPaintEvent *pe);

    /** called whenever the window is resized
      * update all svg elements calculated positions based on the new window size
      */
    void resizeEvent(QResizeEvent *);

    /** called when the mouse is moved
      * checks the mouse position against any svg elements that trigger an action
      * or have a hover state, and sets/resets those states
      */
    void mouseMoveEvent(QMouseEvent *e);

    /** called whenever a mouse click occurs
      * checks the mouse position against svg element positions
      * and reacts accordingly
      */
    void mousePressEvent(QMouseEvent *e);

    /** Connects the buttons to the kverbos object.
     */
    void connectButtons(Trainer* trainer);

signals:
    /** Connect the character buttons to the slot of kverbos */
    void signalChar(QString ch);

private:
    /** sets or clears flag based on whether p is in rect, and set changed if flag changes */
    void CheckRect(const QRect &rect, const QPoint &p, bool &flag, bool &changed);

    /** renderer used to render gui elements */
    QSvgRenderer * m_renderer;

    /** rectangles to use for detecting hover with the mouse position */
    QRect m_nRect;
    QRect m_aRect;
    QRect m_eRect;
    QRect m_iRect;
    QRect m_oRect;
    QRect m_uRect;

    /** states to use for drawing hover elements, or regular elements */
    bool m_overN; 
    bool m_overA; 
    bool m_overE;
    bool m_overI; 
    bool m_overO; 
    bool m_overU;

    /** ratios to use for drawing elements scaled.
      * based on the current size of the window
      * updated in the resize event and paint event
      */
    double m_xRatio;
    double m_yRatio;

    /** width and height of the .svg graphics
      */
    static const double svgWidth;
    static const double svgHeight;

    /** width and height of the buttons and the ratio
      * between the svg dimensions and the button dimensions
      */
    static const double buttonWidth;
    static const double buttonHeight;
    static const double buttonScaleX;
    static const double buttonScaleY;

    /** positions of the buttons in horizontal and vertical direction
      */
    static const double xPosN;
    static const double xPosA;
    static const double xPosE;
    static const double xPosI;
    static const double xPosO;
    static const double xPosU;
    static const double yPos;
};



#endif    // CHARBUTTONSH_H_
