custombgwin.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/custombgwin.h
  3. // Purpose: Documentation of wxCustomBackgroundWindow.
  4. // Author: Vadim Zeitlin
  5. // Created: 2011-10-10
  6. // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. /**
  10. A helper class making it possible to use custom background for any window.
  11. wxWindow itself only provides SetBackgroundColour() method taking a (solid)
  12. wxColour. This class extends it by allowing to use custom bitmap
  13. backgrounds with any window, provided that you inherit from it. Notice that
  14. the usual rule of not interfering with event handling or painting of native
  15. controls still applies, so you shouldn't try to use custom backgrounds with
  16. classes such as wxButton (even if this might work on some platforms, it's
  17. not guaranteed to work in general). But you can use this class in
  18. conjunction with wxWindow, wxPanel, wxFrame and other similar classes, e.g.
  19. the erase sample shows how to use it with wxScrolledWindow:
  20. @code
  21. #include "wx/custombgwin.h"
  22. class MyCanvas : public wxCustomBackgroundWindow<wxScrolledWindow>
  23. {
  24. public:
  25. MyCanvas(wxWindow* parent)
  26. {
  27. // Notice that we must explicitly call base class Create()
  28. // instead of using its ctor as wxCustomBackgroundWindow
  29. // doesn't define any non-default ctors.
  30. Create(parent, wxID_ANY);
  31. ...
  32. SetBackgroundBitmap(bitmap);
  33. }
  34. };
  35. @endcode
  36. @category{miscwnd}
  37. @since 2.9.3
  38. */
  39. template <class W>
  40. class wxCustomBackgroundWindow : public W
  41. {
  42. public:
  43. /// Trivial default constructor.
  44. wxCustomBackgroundWindow();
  45. /**
  46. Set the background bitmap for this window.
  47. If @a bmp is a valid bitmap, this bitmap will be tiled over the panel
  48. background and show through any of its transparent children. Passing an
  49. invalid bitmap reverts to the default background appearance.
  50. Notice that you must not prevent the base class EVT_ERASE_BACKGROUND
  51. handler from running (i.e. not to handle this event yourself) for this
  52. to work.
  53. */
  54. void SetBackgroundBitmap(const wxBitmap& bmp);
  55. };