nonownedwnd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/nonownedwnd.h
  3. // Purpose: declares wxNonTopLevelWindow class
  4. // Author: Vaclav Slavik
  5. // Modified by:
  6. // Created: 2006-12-24
  7. // Copyright: (c) 2006 TT-Solutions
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_NONOWNEDWND_H_
  11. #define _WX_NONOWNEDWND_H_
  12. #include "wx/window.h"
  13. // Styles that can be used with any wxNonOwnedWindow:
  14. #define wxFRAME_SHAPED 0x0010 // Create a window that is able to be shaped
  15. class WXDLLIMPEXP_FWD_CORE wxGraphicsPath;
  16. // ----------------------------------------------------------------------------
  17. // wxNonOwnedWindow: a window that is not a child window of another one.
  18. // ----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxNonOwnedWindowBase : public wxWindow
  20. {
  21. public:
  22. // Set the shape of the window to the given region.
  23. // Returns true if the platform supports this feature (and the
  24. // operation is successful.)
  25. bool SetShape(const wxRegion& region)
  26. {
  27. // This style is in fact only needed by wxOSX/Carbon so once we don't
  28. // use this port any more, we could get rid of this requirement, but
  29. // for now you must specify wxFRAME_SHAPED for SetShape() to work on
  30. // all platforms.
  31. wxCHECK_MSG
  32. (
  33. HasFlag(wxFRAME_SHAPED), false,
  34. wxS("Shaped windows must be created with the wxFRAME_SHAPED style.")
  35. );
  36. return region.IsEmpty() ? DoClearShape() : DoSetRegionShape(region);
  37. }
  38. #if wxUSE_GRAPHICS_CONTEXT
  39. // Set the shape using the specified path.
  40. bool SetShape(const wxGraphicsPath& path)
  41. {
  42. wxCHECK_MSG
  43. (
  44. HasFlag(wxFRAME_SHAPED), false,
  45. wxS("Shaped windows must be created with the wxFRAME_SHAPED style.")
  46. );
  47. return DoSetPathShape(path);
  48. }
  49. #endif // wxUSE_GRAPHICS_CONTEXT
  50. // Overridden base class methods.
  51. // ------------------------------
  52. virtual void AdjustForParentClientOrigin(int& WXUNUSED(x), int& WXUNUSED(y),
  53. int WXUNUSED(sizeFlags) = 0) const
  54. {
  55. // Non owned windows positions don't need to be adjusted for parent
  56. // client area origin so simply do nothing here.
  57. }
  58. virtual void InheritAttributes()
  59. {
  60. // Non owned windows don't inherit attributes from their parent window
  61. // (if the parent frame is red, it doesn't mean that all dialogs shown
  62. // by it should be red as well), so don't do anything here neither.
  63. }
  64. protected:
  65. virtual bool DoClearShape()
  66. {
  67. return false;
  68. }
  69. virtual bool DoSetRegionShape(const wxRegion& WXUNUSED(region))
  70. {
  71. return false;
  72. }
  73. #if wxUSE_GRAPHICS_CONTEXT
  74. virtual bool DoSetPathShape(const wxGraphicsPath& WXUNUSED(path))
  75. {
  76. return false;
  77. }
  78. #endif // wxUSE_GRAPHICS_CONTEXT
  79. };
  80. #if defined(__WXDFB__)
  81. #include "wx/dfb/nonownedwnd.h"
  82. #elif defined(__WXGTK20__)
  83. #include "wx/gtk/nonownedwnd.h"
  84. #elif defined(__WXMAC__)
  85. #include "wx/osx/nonownedwnd.h"
  86. #elif defined(__WXMSW__) && !defined(__WXWINCE__)
  87. #include "wx/msw/nonownedwnd.h"
  88. #else
  89. // No special class needed in other ports, they can derive both wxTLW and
  90. // wxPopupWindow directly from wxWindow and don't implement SetShape().
  91. class wxNonOwnedWindow : public wxNonOwnedWindowBase
  92. {
  93. };
  94. #endif
  95. #endif // _WX_NONOWNEDWND_H_