Audio plugin host https://kx.studio/carla
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.

Widget.hpp 2.6KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 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. #ifndef DGL_WIDGET_HPP_INCLUDED
  17. #define DGL_WIDGET_HPP_INCLUDED
  18. #include "Geometry.hpp"
  19. #ifdef PROPER_CPP11_SUPPORT
  20. # include <cstdint>
  21. #else
  22. # include <stdint.h>
  23. #endif
  24. START_NAMESPACE_DGL
  25. // -----------------------------------------------------------------------
  26. class App;
  27. class Window;
  28. class Widget
  29. {
  30. public:
  31. Widget(Window& parent);
  32. virtual ~Widget();
  33. bool isVisible() const noexcept;
  34. void setVisible(bool yesNo);
  35. void show();
  36. void hide();
  37. int getX() const noexcept;
  38. int getY() const noexcept;
  39. const Point<int>& getPos() const noexcept;
  40. void setX(int x);
  41. void setY(int y);
  42. void setPos(int x, int y);
  43. void setPos(const Point<int>& pos);
  44. void move(int x, int y);
  45. void move(const Point<int>& pos);
  46. int getWidth() const noexcept;
  47. int getHeight() const noexcept;
  48. const Size<int>& getSize() const noexcept;
  49. void setWidth(int width);
  50. void setHeight(int height);
  51. void setSize(int width, int height);
  52. void setSize(const Size<int>& size);
  53. const Rectangle<int>& getArea() const noexcept;
  54. uint32_t getEventTimestamp();
  55. int getModifiers();
  56. App& getParentApp() const noexcept;
  57. Window& getParentWindow() const noexcept;
  58. void repaint();
  59. protected:
  60. virtual void onDisplay() = 0;
  61. virtual bool onKeyboard(bool press, uint32_t key);
  62. virtual bool onMouse(int button, bool press, int x, int y);
  63. virtual bool onMotion(int x, int y);
  64. virtual bool onScroll(float dx, float dy);
  65. virtual bool onSpecial(bool press, Key key);
  66. virtual void onReshape(int width, int height);
  67. virtual void onClose();
  68. private:
  69. Window& fParent;
  70. bool fVisible;
  71. Rectangle<int> fArea;
  72. friend class Window;
  73. };
  74. // -----------------------------------------------------------------------
  75. END_NAMESPACE_DGL
  76. #endif // DGL_WIDGET_HPP_INCLUDED