Nachricht.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "Nachricht.h"
  2. #include <Schrift.h>
  3. #include <Text.h>
  4. #include <MausEreignis.h>
  5. #include <TastaturEreignis.h>
  6. #include <TextFeld.h>
  7. #include "../../../Initialisierung/Initialisierung.h"
  8. // Inhalt der Fehler Klasse aus Fehler.h
  9. // Konstruktor
  10. // tr: Die zu verwendende Schrift
  11. // nachricht: Der Fehler, der angezeigt werden soll
  12. // maxSize: Die Bildschirmgröße in Pixeln
  13. Nachricht::Nachricht( TextRenderer *tr, char *nachricht, Punkt maxSize, std::function< void() > onClose )
  14. : Dialog( tr )
  15. {
  16. Text *tmp = new Text( nachricht );
  17. tr->setSchriftSize( 12 );
  18. tr->textFormatieren( tmp, 300 );
  19. int br = tr->getTextBreite( tmp->getText() );
  20. int hö = tr->getTextHeight( tmp->getText() );
  21. setSize( br + 12, hö + 63 );
  22. setPosition( maxSize / 2 - getSize() / 2 );
  23. TextFeld *text = initTextFeld( 5, 5, br, hö, tr->zSchrift(), TextFeld::Style::Text, tmp->getText() );
  24. addMember( text );
  25. tmp->release();
  26. Knopf *ok = initKnopf( br - 94, hö + 12, 100, 20, tr->zSchrift(), Knopf::Style::Normal, "Ok" );
  27. addMember( ok );
  28. bool *verl = &verlassen;
  29. auto me = [ verl, onClose ]( void *param, void *obj, MausEreignis me ) -> bool
  30. {
  31. if( me.id == ME_RLinks && !me.verarbeitet )
  32. {
  33. *verl = 1;
  34. if( onClose )
  35. onClose();
  36. }
  37. return 1;
  38. };
  39. ok->setMausEreignis( me );
  40. setClosingMe( me );
  41. }
  42. // Destruktor
  43. Nachricht::~Nachricht()
  44. {}