DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.5KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "../ImageAboutWindow.hpp"
  17. START_NAMESPACE_DGL
  18. // -----------------------------------------------------------------------
  19. ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image)
  20. : Window(parent.getApp(), parent),
  21. Widget((Window&)*this),
  22. fImgBackground(image),
  23. leakDetector_ImageAboutWindow()
  24. {
  25. Window::setResizable(false);
  26. Window::setSize(static_cast<uint>(image.getWidth()), static_cast<uint>(image.getHeight()));
  27. Window::setTitle("About");
  28. }
  29. ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image)
  30. : Window(widget->getParentApp(), widget->getParentWindow()),
  31. Widget((Window&)*this),
  32. fImgBackground(image),
  33. leakDetector_ImageAboutWindow()
  34. {
  35. Window::setResizable(false);
  36. Window::setSize(static_cast<uint>(image.getWidth()), static_cast<uint>(image.getHeight()));
  37. Window::setTitle("About");
  38. }
  39. void ImageAboutWindow::setImage(const Image& image)
  40. {
  41. if (fImgBackground == image)
  42. return;
  43. fImgBackground = image;
  44. Window::setSize(static_cast<uint>(image.getWidth()), static_cast<uint>(image.getHeight()));
  45. }
  46. void ImageAboutWindow::onDisplay()
  47. {
  48. fImgBackground.draw();
  49. }
  50. bool ImageAboutWindow::onKeyboard(const KeyboardEvent& ev)
  51. {
  52. if (ev.press && ev.key == CHAR_ESCAPE)
  53. {
  54. Window::close();
  55. return true;
  56. }
  57. return false;
  58. }
  59. bool ImageAboutWindow::onMouse(const MouseEvent& ev)
  60. {
  61. if (ev.press)
  62. {
  63. Window::close();
  64. return true;
  65. }
  66. return false;
  67. }
  68. void ImageAboutWindow::onReshape(uint width, uint height)
  69. {
  70. Widget::setSize(width, height);
  71. Window::onReshape(width, height);
  72. }
  73. // -----------------------------------------------------------------------
  74. END_NAMESPACE_DGL