panel.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Flexlay - A Generic 2D Game Editor
  2. // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include <ClanLib/Display/display.h>
  17. #include "box.hpp"
  18. #include "panel.hpp"
  19. class PanelImpl
  20. {
  21. public:
  22. std::vector<CL_Slot> slots;
  23. CL_Component* parent;
  24. void draw();
  25. };
  26. Panel::Panel(const CL_Rect& rect, CL_Component* parent)
  27. : CL_Component(rect, parent), impl(new PanelImpl())
  28. {
  29. impl->parent = this;
  30. impl->slots.push_back(sig_paint().connect(impl.get(), &PanelImpl::draw));
  31. }
  32. void
  33. PanelImpl::draw()
  34. {
  35. CL_Display::push_translate(parent->get_screen_x(), parent->get_screen_y());
  36. CL_Rect rect = parent->get_position();
  37. Box::draw_panel(CL_Rect(CL_Point(0, 0), CL_Size(rect.get_width()-1, rect.get_height()-1)));
  38. CL_Display::pop_modelview();
  39. }
  40. /* EOF */