VideoEnde.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "VideoEnde.h"
  2. #include <Bild.h>
  3. #include <MausEreignis.h>
  4. #include <Rahmen.h>
  5. #include <Schrift.h>
  6. #include <Text.h>
  7. // Inhalt der VideoEnde Klasse aus VideoEnde.h
  8. // Konstruktor
  9. VideoEnde::VideoEnde( Schrift *zSchrift )
  10. {
  11. text = new TextFeld();
  12. text->setStyle( TextFeld::Style::Text | TextFeld::Style::Center | TextFeld::Style::Rahmen | TextFeld::Style::Hintergrund | TextFeld::Style::HAlpha );
  13. text->removeStyle( TextFeld::Style::Sichtbar );
  14. text->setSchriftZ( dynamic_cast<Schrift *>( zSchrift->getThis() ) );
  15. text->setText( "" );
  16. text->setSchriftFarbe( 0xFFFFFFFF );
  17. text->setSize( 220, 70 );
  18. text->setRahmenBreite( 2 );
  19. text->setRahmenFarbe( 0xFFFFFFFF );
  20. text->setHintergrundFarbe( 0xA0000000 );
  21. ref = 1;
  22. }
  23. // Destruktor
  24. VideoEnde::~VideoEnde()
  25. {
  26. text->release();
  27. }
  28. // nicht constant
  29. void VideoEnde::setSichtbar( bool b )
  30. {
  31. text->setStyle( TextFeld::Style::Sichtbar, b );
  32. }
  33. void VideoEnde::setText( const char *txt )
  34. {
  35. text->zTextRenderer()->setSchriftSize( 12 );
  36. Text t = txt;
  37. text->setSize( 10 + text->zTextRenderer()->getTextBreite( t ), 10 + text->zTextRenderer()->getTextHeight( t ) );
  38. text->setText( txt );
  39. }
  40. void VideoEnde::render( Bild &zRObj )
  41. {
  42. text->setPosition( zRObj.getBreite() / 2 - text->getBreite() / 2, zRObj.getHeight() / 2 - text->getHeight() / 2 );
  43. text->render( zRObj );
  44. }
  45. // constant
  46. bool VideoEnde::istSichtbar() const
  47. {
  48. return text->hatStyle( TextFeld::Style::Sichtbar );
  49. }
  50. // Reference Counting
  51. VideoEnde *VideoEnde::getThis()
  52. {
  53. ref++;
  54. return this;
  55. }
  56. VideoEnde *VideoEnde::release()
  57. {
  58. ref--;
  59. if( !ref )
  60. delete this;
  61. return 0;
  62. }