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.

Fl_Monitor_Arrangement.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright 2021 Hugo Lundin <huglu@cendio.se> for Cendio AB.
  2. * Copyright 2021 Pierre Ossman for Cendio AB
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifndef __FL_MONITOR_ARRANGEMENT_H__
  25. #define __FL_MONITOR_ARRANGEMENT_H__
  26. #include <string>
  27. #include <map>
  28. #include <set>
  29. #include <FL/Fl_Group.H>
  30. class Fl_Button;
  31. class Fl_Monitor_Arrangement: public Fl_Group {
  32. public:
  33. Fl_Monitor_Arrangement(int x, int y, int w, int h);
  34. ~Fl_Monitor_Arrangement();
  35. // Get selected indices.
  36. std::set<int> value() const;
  37. // Set selected indices.
  38. int value(std::set<int> indices);
  39. protected:
  40. virtual void draw();
  41. private:
  42. const Fl_Color AVAILABLE_COLOR;
  43. typedef std::map<int, Fl_Button *> MonitorMap;
  44. MonitorMap monitors;
  45. // Layout the monitor arrangement.
  46. void layout();
  47. // Refresh the monitor arrangement.
  48. void refresh();
  49. // Return true if the given monitor is required to be part of the configuration
  50. // for it to be valid. A configuration is only valid if the framebuffer created
  51. // from is rectangular.
  52. bool is_required(int m);
  53. // Calculate the scale of the monitor arrangement.
  54. double scale();
  55. // Return the size of the monitor arrangement.
  56. std::pair<int, int> size();
  57. // Return the offset required for centering the monitor
  58. // arrangement in the given bounding area.
  59. std::pair<int, int> offset();
  60. // Return the origin of the monitor arrangement (top left corner).
  61. std::pair<int, int> origin();
  62. // Get a textual description of the given monitor.
  63. std::string description(int m);
  64. std::string get_monitor_name(int m);
  65. static int fltk_event_handler(int event);
  66. static void monitor_pressed(Fl_Widget *widget, void *user_data);
  67. static void checkered_pattern_draw(
  68. int x, int y, int width, int height, Fl_Color color);
  69. };
  70. #endif