OptionsWindow.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include "OptionsWindow.h"
  2. #include <DateiSystem.h>
  3. #include "Globals.h"
  4. #include "Initialisierung.h"
  5. OptionsWindow::OptionsWindow(std::function<void()> onOptionsOpen)
  6. : Fenster(),
  7. onOptionsOpen(onOptionsOpen)
  8. {
  9. LTDBDatei iconsDat;
  10. iconsDat.setDatei(new Text("data/images/gui_icons.ltdb"));
  11. iconsDat.leseDaten(0);
  12. setStyle(Style::Erlaubt | Style::Rahmen | Style::BodyHAlpha | Style::Titel
  13. | Style::TitelHAlpha | Style::Closable | Style::ClosingHAlpha
  14. | Style::CustomTitle | Style::ClosingBuffer
  15. | Style::ClosingKlickBuffer | Style::ClosingHBild
  16. | Style::TitelHintergrund | Style::BodyHintergrund
  17. | Style::ClosingHintergrund | Style::MEIgnoreInside
  18. | Style::HeightChangeable | Style::BreiteChangeable
  19. | Style::BodyMinBr | Style::BodyMinHi | Style::Beweglich);
  20. removeStyle(Style::Sichtbar);
  21. setMausEreignis(Framework::_ret1ME);
  22. setTastaturEreignis(Framework::_ret1TE);
  23. setRBreite(1);
  24. setRFarbe(0xFF52525E);
  25. setKBgFarbe(0xA0000000);
  26. setTBgFarbe(0xA0000000);
  27. setSBgFarbe(0xA0000000);
  28. setTSchriftZ(
  29. dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
  30. zTTextFeld()->setSize(0, 20);
  31. zTTextFeld()->addStyle(TextFeld::Style::Center);
  32. setSAfStrength(10);
  33. setSAfFarbe(0x5F9C0A0A);
  34. setSBgBildZ(iconsDat.laden(0, new Text("close.png")));
  35. setSKAfFarbe(0xFF9C0A0A);
  36. setSKAfStrength(10);
  37. optionsButton = initKnopf(0,
  38. 0,
  39. 20,
  40. 20,
  41. Framework::Knopf::Style::HBild | Framework::Knopf::Style::HAlpha
  42. | Framework::Knopf::Style::Hintergrund,
  43. "");
  44. optionsButton->setAlphaFeldFarbe(0x5F337AB7);
  45. optionsButton->setToolTipText(
  46. "Options", uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
  47. optionsButton->setHintergrundBildZ(
  48. iconsDat.laden(0, new Text("options.png")));
  49. optionsButton->setMausEreignis([this](void* p, void* o, MausEreignis me) {
  50. if (me.id == ME_RLinks)
  51. {
  52. this->onOptionsOpen();
  53. }
  54. return 1;
  55. });
  56. }
  57. OptionsWindow::~OptionsWindow()
  58. {
  59. optionsButton->release();
  60. }
  61. void OptionsWindow::doMausEreignis(Framework::MausEreignis& me, bool userRet)
  62. {
  63. optionsButton->doPublicMausEreignis(me);
  64. Fenster::doMausEreignis(me, userRet);
  65. }
  66. bool OptionsWindow::tick(double time)
  67. {
  68. rend |= optionsButton->tick(time);
  69. return Fenster::tick(time);
  70. }
  71. void OptionsWindow::render(Framework::Bild& rObj)
  72. {
  73. if (!hatStyle(Style::Sichtbar)) return;
  74. int titleHeight = zTTextFeld()->getHeight();
  75. zTTextFeld()->setPosition(titleHeight, 0);
  76. int closingWidth = 0;
  77. if (hatStyle(Style::Closable)) closingWidth = titleHeight;
  78. zTTextFeld()->setWidth(getInnenBreite() - titleHeight - closingWidth);
  79. Fenster::render(rObj);
  80. optionsButton->setSize(titleHeight, titleHeight);
  81. int rbr = getRBreite();
  82. if (!rObj.setDrawOptions(
  83. pos.x + rbr, pos.y + rbr, gr.x - rbr * 2, titleHeight))
  84. {
  85. return;
  86. }
  87. optionsButton->render(rObj);
  88. rObj.releaseDrawOptions();
  89. }