display_impl.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/display_impl.h
  3. // Purpose: wxDisplayImpl class declaration
  4. // Author: Vadim Zeitlin
  5. // Created: 2006-03-15
  6. // Copyright: (c) 2002-2006 Vadim Zeitlin <vadim@wxwindows.org>
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DISPLAY_IMPL_H_BASE_
  10. #define _WX_DISPLAY_IMPL_H_BASE_
  11. #include "wx/gdicmn.h" // for wxRect
  12. // ----------------------------------------------------------------------------
  13. // wxDisplayFactory: allows to create wxDisplay objects
  14. // ----------------------------------------------------------------------------
  15. class WXDLLIMPEXP_CORE wxDisplayFactory
  16. {
  17. public:
  18. wxDisplayFactory() { }
  19. virtual ~wxDisplayFactory() { }
  20. // create a new display object
  21. //
  22. // it can return a NULL pointer if the display creation failed
  23. virtual wxDisplayImpl *CreateDisplay(unsigned n) = 0;
  24. // get the total number of displays
  25. virtual unsigned GetCount() = 0;
  26. // return the display for the given point or wxNOT_FOUND
  27. virtual int GetFromPoint(const wxPoint& pt) = 0;
  28. // return the display for the given window or wxNOT_FOUND
  29. //
  30. // the window pointer must not be NULL (i.e. caller should check it)
  31. virtual int GetFromWindow(const wxWindow *window);
  32. };
  33. // ----------------------------------------------------------------------------
  34. // wxDisplayImpl: base class for all wxDisplay implementations
  35. // ----------------------------------------------------------------------------
  36. class WXDLLIMPEXP_CORE wxDisplayImpl
  37. {
  38. public:
  39. // virtual dtor for this base class
  40. virtual ~wxDisplayImpl() { }
  41. // return the full area of this display
  42. virtual wxRect GetGeometry() const = 0;
  43. // return the area of the display available for normal windows
  44. virtual wxRect GetClientArea() const { return GetGeometry(); }
  45. // return the name (may be empty)
  46. virtual wxString GetName() const = 0;
  47. // return the index of this display
  48. unsigned GetIndex() const { return m_index; }
  49. // return true if this is the primary monitor (usually one with index 0)
  50. virtual bool IsPrimary() const { return GetIndex() == 0; }
  51. #if wxUSE_DISPLAY
  52. // implements wxDisplay::GetModes()
  53. virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const = 0;
  54. // get current video mode
  55. virtual wxVideoMode GetCurrentMode() const = 0;
  56. // change current mode, return true if succeeded, false otherwise
  57. virtual bool ChangeMode(const wxVideoMode& mode) = 0;
  58. #endif // wxUSE_DISPLAY
  59. protected:
  60. // create the object providing access to the display with the given index
  61. wxDisplayImpl(unsigned n) : m_index(n) { }
  62. // the index of this display (0 is always the primary one)
  63. const unsigned m_index;
  64. friend class wxDisplayFactory;
  65. wxDECLARE_NO_COPY_CLASS(wxDisplayImpl);
  66. };
  67. // ----------------------------------------------------------------------------
  68. // wxDisplayFactorySingle
  69. // ----------------------------------------------------------------------------
  70. // this is a stub implementation using single/main display only, it is
  71. // available even if wxUSE_DISPLAY == 0
  72. class WXDLLIMPEXP_CORE wxDisplayFactorySingle : public wxDisplayFactory
  73. {
  74. public:
  75. virtual wxDisplayImpl *CreateDisplay(unsigned n);
  76. virtual unsigned GetCount() { return 1; }
  77. virtual int GetFromPoint(const wxPoint& pt);
  78. };
  79. #endif // _WX_DISPLAY_IMPL_H_BASE_