reparent.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/x11/reparent.h
  3. // Purpose: Reparenting classes
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 2002-03-09
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_REPARENT_H_
  11. #define _WX_REPARENT_H_
  12. #include "wx/window.h"
  13. /*
  14. * This class helps to reparent a specific window
  15. */
  16. class WXDLLIMPEXP_FWD_CORE wxAdoptedWindow;
  17. class WXDLLIMPEXP_CORE wxReparenter: public wxObject
  18. {
  19. public:
  20. wxReparenter() {}
  21. // We assume that toReparent has had its X window set
  22. // appropriately. toReparent is typically a wxAdoptedWindow.
  23. bool Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent);
  24. // Wait for an appropriate window to be created.
  25. // If exactMatch is FALSE, a substring match is OK.
  26. // If windowName is empty, then wait for the next overrideRedirect window.
  27. bool WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toReparent,
  28. const wxString& windowName = wxEmptyString,
  29. bool exactMatch = TRUE);
  30. protected:
  31. bool ProcessXEvent(WXEvent* event);
  32. WXWindow FindAClientWindow(WXWindow window, const wxString& name);
  33. static bool sm_done;
  34. static wxAdoptedWindow* sm_toReparent;
  35. static wxWindow* sm_newParent;
  36. static wxString sm_name;
  37. static bool sm_exactMatch;
  38. };
  39. /*
  40. * A window that adopts its handle from the native
  41. * toolkit. It has no parent until reparented.
  42. */
  43. class WXDLLIMPEXP_CORE wxAdoptedWindow: public wxWindow
  44. {
  45. public:
  46. wxAdoptedWindow();
  47. wxAdoptedWindow(WXWindow window);
  48. virtual ~wxAdoptedWindow();
  49. void SetHandle(WXWindow window) { m_mainWindow = window; m_clientWindow = window; }
  50. WXWindow GetHandle() const { return X11GetMainWindow(); }
  51. };
  52. #endif
  53. // _WX_REPARENT_H_