123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #include "RecipieGroup.h"
- #include <Bild.h>
- #include <Schrift.h>
- #include "Globals.h"
- RecipieGroup::RecipieGroup()
- : Framework::ZeichnungHintergrund()
- {
- setStyle(Framework::Zeichnung::Style::Erlaubt
- | Framework::Zeichnung::Style::Sichtbar);
- icon = 0;
- previousPage = uiFactory.createKnopf(uiFactory.initParam);
- previousPage->setText("<");
- previousPage->setToolTipText("Previous Page",
- uiFactory.initParam.bildschirm,
- uiFactory.initParam.schrift);
- previousPage->setSize(20, 20);
- previousPage->setPosition(0, 0);
- previousPage->setStyle(
- Framework::Knopf::Style::Normal & ~Framework::Knopf::Style::Sichtbar);
- previousPage->setMausEreignis([this](void* p, void* z, MausEreignis me) {
- if (me.id == ME_RLinks)
- {
- currentPage--;
- }
- return 1;
- });
- nextPage = uiFactory.createKnopf(uiFactory.initParam);
- nextPage->setText(">");
- nextPage->setToolTipText("Next Page",
- uiFactory.initParam.bildschirm,
- uiFactory.initParam.schrift);
- nextPage->setSize(20, 20);
- nextPage->setPosition(0, 0);
- nextPage->setStyle(
- Framework::Knopf::Style::Normal & ~Framework::Knopf::Style::Sichtbar);
- nextPage->setMausEreignis([this](void* p, void* z, MausEreignis me) {
- if (me.id == ME_RLinks)
- {
- currentPage++;
- }
- return 1;
- });
- }
- RecipieGroup::~RecipieGroup()
- {
- if (icon) icon->release();
- previousPage->release();
- nextPage->release();
- }
- void RecipieGroup::addRecipie(Framework::Zeichnung* recipie)
- {
- recipies.add(recipie);
- }
- void RecipieGroup::setIcon(Framework::Bild* icon)
- {
- if (this->icon) this->icon->release();
- this->icon = icon;
- }
- void RecipieGroup::setToolTip(Framework::Text toolTip)
- {
- this->toolTip = toolTip;
- }
- bool RecipieGroup::tick(double tickVal)
- {
- int pi = 1;
- int y = 20;
- bool first = 1;
- for (Zeichnung* recipie : recipies)
- {
- if (recipie->getHeight() + y > getHeight() && !first)
- {
- pi++;
- y = 20;
- }
- recipie->setStyle(Zeichnung::Style::Sichtbar, pi == currentPage);
- recipie->setX(getBreite() / 2 - recipie->getBreite() / 2);
- recipie->setY(y);
- y += recipie->getHeight() + 50;
- first = 0;
- rend |= recipie->tick(tickVal);
- }
- nextPage->setX(getBreite() - 20);
- maxPage = pi;
- currentPage = MAX(1, MIN(pi, currentPage));
- previousPage->setStyle(Knopf::Style::Sichtbar, currentPage > 1);
- nextPage->setStyle(Knopf::Style::Sichtbar, currentPage < maxPage);
- rend |= previousPage->tick(tickVal);
- rend |= nextPage->tick(tickVal);
- return ZeichnungHintergrund::tick(tickVal);
- }
- void RecipieGroup::render(Framework::Bild& rObj)
- {
- if (!hatStyle(Zeichnung::Style::Sichtbar)) return;
- ZeichnungHintergrund::render(rObj);
- if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return;
- Framework::TextRenderer tr(dynamic_cast<Framework::Schrift*>(uiFactory.initParam.schrift->getThis()));
- tr.setSchriftSize(12);
- Text t = Text("Recipie page ") + Text(currentPage) + Text(" of ") + Text(maxPage);
- int tbr = tr.getTextBreite(t);
- tr.renderText(getBreite() / 2 - tbr / 2, 4, t, rObj, 0xFFFFFFFF);
- for (Framework::Zeichnung* recipie : recipies)
- {
- recipie->render(rObj);
- }
- previousPage->render(rObj);
- nextPage->render(rObj);
- rObj.releaseDrawOptions();
- }
- void RecipieGroup::doMausEreignis(Framework::MausEreignis& me, bool userRet)
- {
- previousPage->doPublicMausEreignis(me);
- nextPage->doPublicMausEreignis(me);
- for (Zeichnung* recipie : recipies)
- {
- recipie->doPublicMausEreignis(me);
- }
- }
- Framework::Bild* RecipieGroup::zIcon() const
- {
- return icon;
- }
- Framework::Text RecipieGroup::getToolTip() const
- {
- return toolTip;
- }
|