overlay.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/overlay.h
  3. // Purpose: wxOverlay class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 2006-10-20
  7. // Copyright: (c) wxWidgets team
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_OVERLAY_H_
  11. #define _WX_OVERLAY_H_
  12. #include "wx/defs.h"
  13. #if defined(__WXMAC__) && wxOSX_USE_CARBON
  14. #define wxHAS_NATIVE_OVERLAY 1
  15. #elif defined(__WXDFB__)
  16. #define wxHAS_NATIVE_OVERLAY 1
  17. #else
  18. // don't define wxHAS_NATIVE_OVERLAY
  19. #endif
  20. // ----------------------------------------------------------------------------
  21. // creates an overlay over an existing window, allowing for manipulations like
  22. // rubberbanding etc. This API is not stable yet, not to be used outside wx
  23. // internal code
  24. // ----------------------------------------------------------------------------
  25. class WXDLLIMPEXP_FWD_CORE wxOverlayImpl;
  26. class WXDLLIMPEXP_FWD_CORE wxDC;
  27. class WXDLLIMPEXP_CORE wxOverlay
  28. {
  29. public:
  30. wxOverlay();
  31. ~wxOverlay();
  32. // clears the overlay without restoring the former state
  33. // to be done eg when the window content has been changed and repainted
  34. void Reset();
  35. // returns (port-specific) implementation of the overlay
  36. wxOverlayImpl *GetImpl() { return m_impl; }
  37. private:
  38. friend class WXDLLIMPEXP_FWD_CORE wxDCOverlay;
  39. // returns true if it has been setup
  40. bool IsOk();
  41. void Init(wxDC* dc, int x , int y , int width , int height);
  42. void BeginDrawing(wxDC* dc);
  43. void EndDrawing(wxDC* dc);
  44. void Clear(wxDC* dc);
  45. wxOverlayImpl* m_impl;
  46. bool m_inDrawing;
  47. wxDECLARE_NO_COPY_CLASS(wxOverlay);
  48. };
  49. class WXDLLIMPEXP_CORE wxDCOverlay
  50. {
  51. public:
  52. // connects this overlay to the corresponding drawing dc, if the overlay is
  53. // not initialized yet this call will do so
  54. wxDCOverlay(wxOverlay &overlay, wxDC *dc, int x , int y , int width , int height);
  55. // convenience wrapper that behaves the same using the entire area of the dc
  56. wxDCOverlay(wxOverlay &overlay, wxDC *dc);
  57. // removes the connection between the overlay and the dc
  58. virtual ~wxDCOverlay();
  59. // clears the layer, restoring the state at the last init
  60. void Clear();
  61. private:
  62. void Init(wxDC *dc, int x , int y , int width , int height);
  63. wxOverlay& m_overlay;
  64. wxDC* m_dc;
  65. wxDECLARE_NO_COPY_CLASS(wxDCOverlay);
  66. };
  67. #endif // _WX_OVERLAY_H_