home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / contrib / include / wx / fl / gcupdatesmgr.h < prev    next >
C/C++ Source or Header  |  2002-09-08  |  4KB  |  130 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        gcupdatesmgr.h
  3. // Purpose:     Header for cbGCUpdatesMgr class.
  4. // Author:      Aleksandras Gluchovas
  5. // Modified by:
  6. // Created:     19/10/98
  7. // RCS-ID:      $Id: gcupdatesmgr.h,v 1.3 2002/09/07 12:10:19 GD Exp $
  8. // Copyright:   (c) Aleksandras Gluchovas
  9. // Licence:     wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef __GCUPDATESMGR_G__
  13. #define __GCUPDATESMGR_G__
  14.  
  15. #if defined(__GNUG__) && !defined(__APPLE__)
  16.     #pragma interface "gcupdatesmgr.h"
  17. #endif
  18.  
  19. #include "wx/fl/controlbar.h"
  20. #include "wx/fl/updatesmgr.h"
  21.  
  22. #include "wx/fl/garbagec.h"
  23.  
  24. /*
  25. This class implements optimized logic for refreshing
  26. the areas of frame layout that actually need to be updated.
  27. It is used as the default updates manager by wxFrameLayout.
  28.  
  29. It is called 'Garbage Collecting' updates manager because
  30. its implementation tries to find out dependencies between bars,
  31. and to order them into a 'hierarchy'. This hierarchical sorting resembles
  32. the implementation of heap-garbage collectors, which resolve
  33. dependencies between references.
  34.  
  35. Example: there are situations where the order in which the user
  36. moves windows does matter.
  37.  
  38. \begin{verbatim}
  39.   case 1)
  40.      ------            ---
  41.      | A     |             |B|
  42.         ------     --->      | |
  43.             ---               --- ------
  44.             |B|                   | A  |
  45.             | |                   ------
  46.             ---
  47.                         (future)
  48.        (past)
  49. \end{verbatim}
  50.  
  51. Past/future positions of A and B windows completely overlap, i.e.
  52. depend on each other, and there is no solution for
  53. moving the windows without refreshing both of them
  54. -- we have a cyclic dependency here. The garbage collection algorithm will
  55. find this cyclic dependecy and will force refresh after movement.
  56.  
  57. \begin{verbatim}
  58.   case 2)
  59.  
  60.      ------
  61.      | A     |
  62.         ------     --->
  63.             ---
  64.             |B|                              ------
  65.             | |                              | A  |
  66.             ---                              ------
  67.                          ---
  68.                          |B|
  69.                          | |
  70.                          ---
  71.  
  72.                         (future)
  73.        (past)
  74. \end{verbatim}
  75.  
  76. In this case past/future positions do not overlap, so
  77. it is enough only to move windows without refreshing them.
  78. Garbage collection will 'notice' this.
  79.  
  80. There is also a third case, when overlapping is partial.
  81. In this case the refreshing can also be avoided by
  82. moving windows in the order of 'most-dependant' towards the
  83. 'least-dependent'. GC handles this automatically, by
  84. sorting windows by their dependency-level (or 'hierarchy').
  85.  
  86. See garbagec.h for more details of this method; garbagec.h/cpp
  87. implement sorting of generic dependencies and does not deal
  88. with graphical objects directly.
  89.  
  90. Summary: garbage collection improves performance when complex or large
  91. windows are moved around, by reducing the number of repaints. It also helps
  92. to avoid dirty non-client areas of moved windows
  93. in some special cases of 'overlapping anomalies'.
  94. */
  95.  
  96. class cbGCUpdatesMgr : public cbSimpleUpdatesMgr
  97. {
  98.     DECLARE_DYNAMIC_CLASS( cbGCUpdatesMgr )
  99. protected:
  100.  
  101.     GarbageCollector mGC;
  102.  
  103.         // Internal function for repositioning items.
  104.     void DoRepositionItems( wxList& items );
  105.  
  106.         // Internal function for repositioning items.
  107.     void AddItem( wxList&     itemList,
  108.                   cbBarInfo*  pBar,
  109.                   cbDockPane* pPane,
  110.                   wxRect&     curBounds,
  111.                   wxRect&     prevBounds );
  112.  
  113. public:
  114.  
  115.         // Default constructor.
  116.     cbGCUpdatesMgr(void) {}
  117.  
  118.         // Constructor, taking a frame layout.
  119.     cbGCUpdatesMgr( wxFrameLayout* pPanel );
  120.  
  121.         // Receives notifications from the frame layout.
  122.     virtual void OnStartChanges();
  123.  
  124.         // Refreshes the parts of the frame layout which need an update.
  125.     virtual void UpdateNow();
  126. };
  127.  
  128. #endif /* __GCUPDATESMGR_G__ */
  129.  
  130.