No Description

bird.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef BIRD_H
  2. #define BIRD_H
  3. #include <QWidget>
  4. #include <QPainter>
  5. /// A class to represent birds.
  6. ///
  7. /// Bird is a subclass of QWidget. This means that the following QWidget functions
  8. /// are also available for objects of the class Bird:
  9. /// * move(int x, int y): to move the bird to position (x,y)
  10. /// * x(), y(): get the x position, get the y() position
  11. /// * hide(): to hide a bird that has been painted
  12. class Bird : public QWidget
  13. {
  14. Q_OBJECT
  15. public:
  16. ///
  17. /// Enum type for the EyeBrow
  18. ///
  19. enum EyeBrowType {
  20. UNI, /**< enum value 0 */
  21. ANGRY, /**< enum value 1 */
  22. UPSET, /**< enum value 2 */
  23. BUSHY /**< enum value 3 */
  24. };
  25. /// \fn Bird::Bird(QWidget *parent)
  26. /// \~English
  27. /// \brief Default constructor. The properties of the bird are set as follows:
  28. /// size: set to random value of either 50, 100, 150 or 200
  29. /// * eyeBrow: set randomly to one of the five possible values
  30. /// * color and eColor: set randomly to one of the five possible colors:
  31. /// "green", "blue", "red", "yellow", "white"
  32. /// \~Spanish
  33. /// \brief Constructor por defecto. Las propiedades de el pajaron son ajustados como sigue:
  34. /// * eyeBrow: ajustado aleatoriamente a uno de los 5 posibles valores
  35. /// * color y eColor: ajustao aleatoriamente a uno de los 5 posibles colores:
  36. /// "verde", "azul", "rojo", "amarillo", "blanco"
  37. ///
  38. explicit Bird(QWidget *parent = 0);
  39. /// \fn Bird::Bird(int s, EyeBrowType eb, QString col, QString eye, QWidget *parent)
  40. /// \~English
  41. /// \brief Constructor which accepts specification of the attributes of the bird
  42. /// \param s size
  43. /// \param eb eyeBrow
  44. /// \param col (faceColor)
  45. /// \param eye (eyeColor)
  46. /// \~Spanish
  47. /// \brief Constructor que acepta especificaciones de los atributos del pajaro
  48. /// \param s tamaño
  49. /// \param eb cejas
  50. /// \param col color de la cara
  51. /// \param eye color del ojo
  52. Bird(int , EyeBrowType , QString , QString, QWidget *parent = 0) ;
  53. /// \fn QString Bird::getEyeColor()
  54. /// \~English
  55. /// \brief Getter for the eyeColor.
  56. /// \~Spanish
  57. /// \brief Devuelve el color del ojo.
  58. QString getEyeColor() const;
  59. /// \fn QString Bird::getFaceColor()
  60. /// \~English
  61. /// \brief Getter for the faceColor.
  62. /// \~Spanish
  63. /// \brief Devuelve el color de la cara.
  64. QString getFaceColor() const;
  65. /// \fn void Bird::setEyeColor(QString eye)
  66. /// \~English
  67. /// \brief Setter for the eyeColor.
  68. /// \param eye eyeColor
  69. /// \~Spanish
  70. /// \brief Ajusta el color del ojo
  71. /// \param eje color del ojo
  72. ///
  73. void setEyeColor(QString) ;
  74. /// \fn void Bird::setFaceColor(QString col)
  75. /// \~English
  76. /// \brief Setter for the face color.
  77. /// \param col face Color
  78. /// \~Spanish
  79. /// \brief Ajusta el color de la cara
  80. /// \param col color de la cara
  81. void setFaceColor(QString) ;
  82. /// \fn int Bird::getSize()
  83. /// \~English
  84. /// \brief Getter for the bird size.
  85. /// \~Spanish
  86. /// \brief Devuelve el tamano del pajaro.
  87. int getSize() const ;
  88. /// \fn int Bird::getEyeBrow()
  89. /// \~English
  90. /// \brief Getter for the bird eyeBrow type
  91. /// \~Spanish
  92. /// \brief Devuelve el tipo de ceja
  93. EyeBrowType getEyebrow() const;
  94. /// \fn void Bird::setSize(int s)
  95. /// \~English
  96. /// \brief Setter for the bird size.
  97. /// \param s bird size
  98. /// \~Spanish
  99. /// \brief Ajusta el tamano del pajaro
  100. /// \param s tamano del pajaro
  101. void setSize(int) ;
  102. /// \fn void Bird::setEyebrow(QString eye)
  103. /// \~English
  104. /// \brief Setter for the eyebrow type.
  105. /// \param eb eyebrow type
  106. /// \~Spanish
  107. /// \brief Ajusta el tipo de cejas
  108. /// \param eb tipo de ceja
  109. void setEyebrow(EyeBrowType) ;
  110. /// \fn Qt::GlobalColor Bird::getColor(QString color)
  111. /// \~English
  112. /// \brief Converts a color specified as string to a Qt::GlobalColor
  113. /// \param color string with a color
  114. /// \~Spanish
  115. /// \brief Convierte un color especificado como un string a un Qt::GlobalColor
  116. /// \param color cadena de caracteres de un color
  117. Qt::GlobalColor getColor(QString) const;
  118. signals:
  119. public slots:
  120. protected:
  121. /// \fn void Bird::paintEvent(QPaintEvent *event)
  122. /// \~English
  123. /// \brief This function is automatically invoked each time the widget or
  124. /// its parent receives a repaint signal.
  125. /// \~Spanish
  126. /// \brief Esta funcion es invocada automaticamente cada ves que el widget
  127. /// o su padre recive una senal de repintar.
  128. void paintEvent(QPaintEvent *);
  129. private:
  130. int size ; /**< size of the bird*/
  131. EyeBrowType eyeBrow ; /**< eyebrow type (ceja)*/
  132. QString color ; /**< face color (cara)*/
  133. QString eColor ; /**< eye color (ojos)*/
  134. /// \fn int Bird::randInt(int min, int max)
  135. /// \~English
  136. /// \brief Generates a random integer in the range [min, max]
  137. /// \param min minimum random value
  138. /// \param max maximum random value
  139. /// \~Spanish
  140. /// \brief Genera un entero aleatorio en el rango [min, max]
  141. /// \param min valor aleatorio minimo
  142. /// \param max valor aleatorio maximo
  143. ///
  144. int randInt(int min, int max) ;
  145. };
  146. #endif // BIRD_H