display.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/display.h
  3. // Purpose: wxDisplay class
  4. // Author: Royce Mitchell III, Vadim Zeitlin
  5. // Created: 06/21/02
  6. // Copyright: (c) 2002-2006 wxWidgets team
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DISPLAY_H_BASE_
  10. #define _WX_DISPLAY_H_BASE_
  11. // NB: no #if wxUSE_DISPLAY here, the display geometry part of this class (but
  12. // not the video mode stuff) is always available but if wxUSE_DISPLAY == 0
  13. // it becomes just a trivial wrapper around the old wxDisplayXXX() functions
  14. #if wxUSE_DISPLAY
  15. #include "wx/dynarray.h"
  16. #include "wx/vidmode.h"
  17. WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
  18. // default, uninitialized, video mode object
  19. extern WXDLLIMPEXP_DATA_CORE(const wxVideoMode) wxDefaultVideoMode;
  20. #endif // wxUSE_DISPLAY
  21. class WXDLLIMPEXP_FWD_CORE wxWindow;
  22. class WXDLLIMPEXP_FWD_CORE wxPoint;
  23. class WXDLLIMPEXP_FWD_CORE wxRect;
  24. class WXDLLIMPEXP_FWD_BASE wxString;
  25. class WXDLLIMPEXP_FWD_CORE wxDisplayFactory;
  26. class WXDLLIMPEXP_FWD_CORE wxDisplayImpl;
  27. // ----------------------------------------------------------------------------
  28. // wxDisplay: represents a display/monitor attached to the system
  29. // ----------------------------------------------------------------------------
  30. class WXDLLIMPEXP_CORE wxDisplay
  31. {
  32. public:
  33. // initialize the object containing all information about the given
  34. // display
  35. //
  36. // the displays are numbered from 0 to GetCount() - 1, 0 is always the
  37. // primary display and the only one which is always supported
  38. wxDisplay(unsigned n = 0);
  39. // dtor is not virtual as this is a concrete class not meant to be derived
  40. // from
  41. ~wxDisplay();
  42. // return the number of available displays, valid parameters to
  43. // wxDisplay ctor are from 0 up to this number
  44. static unsigned GetCount();
  45. // find the display where the given point lies, return wxNOT_FOUND if
  46. // it doesn't belong to any display
  47. static int GetFromPoint(const wxPoint& pt);
  48. // find the display where the given window lies, return wxNOT_FOUND if it
  49. // is not shown at all
  50. static int GetFromWindow(const wxWindow *window);
  51. // return true if the object was initialized successfully
  52. bool IsOk() const { return m_impl != NULL; }
  53. // get the full display size
  54. wxRect GetGeometry() const;
  55. // get the client area of the display, i.e. without taskbars and such
  56. wxRect GetClientArea() const;
  57. // name may be empty
  58. wxString GetName() const;
  59. // display 0 is usually the primary display
  60. bool IsPrimary() const;
  61. #if wxUSE_DISPLAY
  62. // enumerate all video modes supported by this display matching the given
  63. // one (in the sense of wxVideoMode::Match())
  64. //
  65. // as any mode matches the default value of the argument and there is
  66. // always at least one video mode supported by display, the returned array
  67. // is only empty for the default value of the argument if this function is
  68. // not supported at all on this platform
  69. wxArrayVideoModes
  70. GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const;
  71. // get current video mode
  72. wxVideoMode GetCurrentMode() const;
  73. // change current mode, return true if succeeded, false otherwise
  74. //
  75. // for the default value of the argument restores the video mode to default
  76. bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode);
  77. // restore the default video mode (just a more readable synonym)
  78. void ResetMode() { (void)ChangeMode(); }
  79. #endif // wxUSE_DISPLAY
  80. private:
  81. // returns the factory used to implement our static methods and create new
  82. // displays
  83. static wxDisplayFactory& Factory();
  84. // creates the factory object, called by Factory() when it is called for
  85. // the first time and should return a pointer allocated with new (the
  86. // caller will delete it)
  87. //
  88. // this method must be implemented in platform-specific code if
  89. // wxUSE_DISPLAY == 1 (if it is 0 we provide the stub in common code)
  90. static wxDisplayFactory *CreateFactory();
  91. // the real implementation
  92. wxDisplayImpl *m_impl;
  93. wxDECLARE_NO_COPY_CLASS(wxDisplay);
  94. };
  95. #endif // _WX_DISPLAY_H_BASE_