Rahmen.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "Rahmen.h"
  2. #include "Punkt.h"
  3. #include "Bild.h"
  4. #include "Scroll.h"
  5. #include "ToolTip.h"
  6. #include "Text.h"
  7. using namespace Framework;
  8. // Inhalt der LRahmen Klasse aus Rahmen.h
  9. // Konstruktor
  10. LRahmen::LRahmen()
  11. : Zeichnung(),
  12. br( 1 ),
  13. farbe( 0xFF000000 ),
  14. alpha( 0 ),
  15. ref( 1 )
  16. {}
  17. // Destruktor
  18. LRahmen::~LRahmen()
  19. {}
  20. // nicht constant
  21. void LRahmen::setRamenBreite( int br ) // setzt die Breite des Rahmens
  22. {
  23. this->br = br;
  24. rend = 1;
  25. }
  26. void LRahmen::setAlpha( bool a ) // Legt fest, ob der Alphawert der Farbe berücksichtigt werden soll
  27. {
  28. alpha = a;
  29. rend = 1;
  30. }
  31. void LRahmen::setFarbe( int f ) // Legt die Farbe des Rahmens fest
  32. {
  33. farbe = f;
  34. rend = 1;
  35. }
  36. void LRahmen::render( Bild &Obj ) // Zeichnet den Rahmen in das RenderZeichnung
  37. {
  38. Zeichnung::render( Obj );
  39. int x = pos.x;
  40. int y = pos.y;
  41. int b = x + gr.x - 1;
  42. int h = y + gr.y - 1;
  43. if( alpha )
  44. {
  45. for( int i = 0; i < br; ++i )
  46. {
  47. Obj.drawLinieHAlpha( x + i + 1, y + i, gr.x - i * 2 - 1, farbe );
  48. Obj.drawLinieVAlpha( b - i, y + i + 1, gr.y - i * 2 - 2, farbe );
  49. Obj.drawLinieHAlpha( x + i + 1, h - i, gr.x - i * 2 - 1, farbe );
  50. Obj.drawLinieVAlpha( x + i, y + i, gr.y - i * 2, farbe );
  51. }
  52. }
  53. else
  54. {
  55. for( int i = 0; i < br; ++i )
  56. {
  57. Obj.drawLinieH( x + i + 1, y + i, gr.x - i * 2 - 1, farbe );
  58. Obj.drawLinieV( b - i, y + i + 1, gr.y - i * 2 - 2, farbe );
  59. Obj.drawLinieH( x + i + 1, h - i, gr.x - i * 2 - 1, farbe );
  60. Obj.drawLinieV( x + i, y + i, gr.y - i * 2, farbe );
  61. }
  62. }
  63. }
  64. // constant
  65. int LRahmen::getRBreite() const // Gibt die Breite des Rahmens zurück
  66. {
  67. return br;
  68. }
  69. int LRahmen::getFarbe() const // Gibt die Farbe des Ramens zurück
  70. {
  71. return farbe;
  72. }
  73. bool LRahmen::hatAlpha() const // Gibt zurück, ob der Alphawert der Farbe beachtet wird
  74. {
  75. return alpha;
  76. }
  77. Zeichnung *LRahmen::dublizieren() const // Kopiert das Zeichnung
  78. {
  79. LRahmen *obj = new LRahmen();
  80. obj->setPosition( pos );
  81. obj->setSize( gr );
  82. obj->setMausEreignisParameter( makParam );
  83. obj->setTastaturEreignisParameter( takParam );
  84. obj->setMausEreignis( Mak );
  85. obj->setTastaturEreignis( Tak );
  86. if( toolTip )
  87. obj->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
  88. obj->setAlpha( alpha );
  89. obj->setFarbe( farbe );
  90. obj->setRamenBreite( br );
  91. return obj;
  92. }
  93. // Reference Counting
  94. LRahmen *LRahmen::getThis()
  95. {
  96. ++ref;
  97. return this;
  98. }
  99. LRahmen *LRahmen::release()
  100. {
  101. --ref;
  102. if( ref == 0 )
  103. delete this;
  104. return 0;
  105. }