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.

MonitorArrangement.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright 2021 Hugo Lundin <huglu@cendio.se> for Cendio AB.
  2. * Copyright 2021 Pierre Ossman for Cendio AB
  3. *
  4. * This 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 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software 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 software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. #ifndef __MONITOR_ARRANGEMENT_H__
  20. #define __MONITOR_ARRANGEMENT_H__
  21. #include <string>
  22. #include <map>
  23. #include <set>
  24. class Fl_Group;
  25. class Fl_Button;
  26. class MonitorArrangement: public Fl_Group {
  27. public:
  28. MonitorArrangement(int x, int y, int w, int h);
  29. ~MonitorArrangement();
  30. // Get selected indices.
  31. std::set<int> get();
  32. // Set selected indices.
  33. void set(std::set<int> indices);
  34. protected:
  35. virtual void draw();
  36. private:
  37. const Fl_Color SELECTION_COLOR;
  38. const Fl_Color AVAILABLE_COLOR;
  39. typedef std::map<int, Fl_Button *> MonitorMap;
  40. MonitorMap monitors;
  41. // Layout the monitor arrangement.
  42. void layout();
  43. // Refresh the monitor arrangement.
  44. void refresh();
  45. // Return true if the given monitor is required to be part of the configuration
  46. // for it to be valid. A configuration is only valid if the framebuffer created
  47. // from is rectangular.
  48. bool is_required(int m);
  49. // Calculate the scale of the monitor arrangement.
  50. double scale();
  51. // Return the size of the monitor arrangement.
  52. std::pair<int, int> size();
  53. // Return the offset required for centering the monitor
  54. // arrangement in the given bounding area.
  55. std::pair<int, int> offset();
  56. // Return the origin of the monitor arrangement (top left corner).
  57. std::pair<int, int> origin();
  58. // Get a textual description of the given monitor.
  59. std::string description(int m);
  60. int get_monitor_name(int m, char name[], size_t name_len);
  61. static int fltk_event_handler(int event);
  62. static void monitor_pressed(Fl_Widget *widget, void *user_data);
  63. static void checkered_pattern_draw(
  64. int x, int y, int width, int height, Fl_Color color);
  65. };
  66. #endif