]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/fl/updatesmgr.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: updatesmgr.cpp
3 // Purpose: cbSimpleUpdatesMgr implementation.
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/fl/updatesmgr.h"
27 static inline bool rect_hits_rect( const wxRect
& r1
, const wxRect
& r2
)
29 if ( ( r2
.x
>= r1
.x
&& r2
.x
<= r1
.x
+ r1
.width
) ||
30 ( r1
.x
>= r2
.x
&& r1
.x
<= r2
.x
+ r2
.width
) )
32 if ( ( r2
.y
>= r1
.y
&& r2
.y
<= r1
.y
+ r1
.height
) ||
33 ( r1
.y
>= r2
.y
&& r1
.y
<= r2
.y
+ r2
.height
) )
40 /***** Implementation for class cbSimpleUpdatesMgr *****/
42 IMPLEMENT_DYNAMIC_CLASS( cbSimpleUpdatesMgr
, cbUpdatesManagerBase
)
44 cbSimpleUpdatesMgr::cbSimpleUpdatesMgr( wxFrameLayout
* pPanel
)
45 : cbUpdatesManagerBase( pPanel
)
48 bool cbSimpleUpdatesMgr::WasChanged( cbUpdateMgrData
& data
, wxRect
& currentBounds
)
50 return ( data
.IsDirty() ||
52 ( data
.mPrevBounds
.x
!= currentBounds
.x
||
53 data
.mPrevBounds
.y
!= currentBounds
.y
||
54 data
.mPrevBounds
.width
!= currentBounds
.width
||
55 data
.mPrevBounds
.height
!= currentBounds
.height
)
59 void cbSimpleUpdatesMgr::OnStartChanges()
61 // memorize states of ALL items in the layout -
62 // this is quite excessive, but OK for the simple
63 // implementation of updates manager
65 mpLayout
->GetPrevClientRect() = mpLayout
->GetClientRect();
67 cbDockPane
** panes
= mpLayout
->GetPanesArray();
69 for( int n
= 0; n
!= MAX_PANES
; ++n
)
71 cbDockPane
& pane
= *panes
[n
];
73 pane
.mUMgrData
.StoreItemState( pane
.mBoundsInParent
);
74 pane
.mUMgrData
.SetDirty( false );
76 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
78 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
81 row
.mUMgrData
.StoreItemState( row
.mBoundsInParent
);
82 row
.mUMgrData
.SetDirty( false );
84 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
86 cbBarInfo
& bar
= *row
.mBars
[ k
];
89 bar
.mUMgrData
.StoreItemState( bar
.mBoundsInParent
);
90 bar
.mUMgrData
.SetDirty( false );
96 void cbSimpleUpdatesMgr::OnFinishChanges()
98 // nothing here, could be overriden by more sophisticated updates-managers
101 void cbSimpleUpdatesMgr::OnRowWillChange( cbRowInfo
* WXUNUSED(pRow
), cbDockPane
* WXUNUSED(pInPane
) )
106 void cbSimpleUpdatesMgr::OnBarWillChange( cbBarInfo
* WXUNUSED(pBar
),
107 cbRowInfo
* WXUNUSED(pInRow
), cbDockPane
* WXUNUSED(pInPane
) )
112 void cbSimpleUpdatesMgr::OnPaneMarginsWillChange( cbDockPane
* WXUNUSED(pPane
) )
117 void cbSimpleUpdatesMgr::OnPaneWillChange( cbDockPane
* WXUNUSED(pPane
) )
122 void cbSimpleUpdatesMgr::UpdateNow()
124 cbDockPane
** panes
= mpLayout
->GetPanesArray();
126 wxRect
& r1
= mpLayout
->GetClientRect();
127 wxRect
& r2
= mpLayout
->GetPrevClientRect();
129 // detect changes in client window's area
131 bool clientWindowChanged
= ( r1
.x
!= r2
.x
||
133 r1
.width
!= r2
.width
||
134 r1
.height
!= r2
.height
);
136 // step #1 - detect changes in each row of each pane,
137 // and repaint decorations around changed windows
139 wxList mBarsToRefresh
;
142 for( int n
= 0; n
!= MAX_PANES
; ++n
)
144 cbDockPane
& pane
= *(panes
[n
]);
146 bool paneChanged
= WasChanged( pane
.mUMgrData
, pane
.mBoundsInParent
);
150 wxClientDC
dc( &mpLayout
->GetParentFrame() );
151 pane
.PaintPaneBackground( dc
);
156 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
158 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
162 bool rowChanged
= false;
164 // FIXME:: the below should not be fixed
165 cbBarInfo
* barsToRepaint
[256];
167 // number of bars, that were changed in the current row
170 if ( WasChanged( row
.mUMgrData
, row
.mBoundsInParent
) )
174 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
176 if ( WasChanged( row
.mBars
[k
]->mUMgrData
,
177 row
.mBars
[k
]->mBoundsInParent
)
180 barsToRepaint
[nBars
++] = row
.mBars
[k
];
182 if ( nBars
|| rowChanged
)
184 realBounds
= row
.mBoundsInParent
;
186 // include 1-pixel thick shades around the row
189 realBounds
.width
+= 2;
190 realBounds
.height
+= 2;
192 pDc
= pane
.StartDrawInArea( realBounds
);
197 // postphone the resizing and refreshing the changed
200 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
202 mBarsToRefresh
.Append( (wxObject
*)row
.mBars
[k
] );
203 mPanesList
.Append( &pane
);
206 // draw only their decorations now
208 pane
.PaintRow( &row
, *pDc
);
213 for( int i
= 0; i
!= nBars
; ++i
)
215 // postphone the resizement and refreshing the changed
218 mBarsToRefresh
.Append( (wxObject
*)barsToRepaint
[i
] );
219 mPanesList
.Append( &pane
);
222 // redraw decorations of entire row, regardless of how much
223 // of the bars were changed
224 pane
.PaintRow( &row
, *pDc
);
229 pane
.FinishDrawInArea( realBounds
);
234 wxClientDC
dc( &mpLayout
->GetParentFrame() );
235 pane
.PaintPaneDecorations( dc
);
240 if ( clientWindowChanged
)
242 mpLayout
->PositionClientWindow();
243 // ptr to client-window object is "marked" as 0
246 // step #2 - do ordered refreshing and resizing of bar window objects now
248 wxNode
* pNode
= mBarsToRefresh
.GetFirst();
249 wxNode
* pPaneNode
= mPanesList
.GetFirst();
253 cbBarInfo
* pBar
= (cbBarInfo
*) pNode
->GetData();
254 cbDockPane
* pPane
= (cbDockPane
*)pPaneNode
->GetData();
256 pPane
->SizeBar( pBar
);
258 pNode
= pNode
->GetNext();
259 pPaneNode
= pPaneNode
->GetNext();
262 pNode
= mBarsToRefresh
.GetFirst();
266 cbBarInfo
* pBar
= (cbBarInfo
*)pNode
->GetData();
268 if ( pBar
->mpBarWnd
)
270 pBar
->mpBarWnd
->Refresh();
273 //info.mpBarWnd->Show(false);
274 //info.mpBarWnd->Show(true);
277 pNode
= pNode
->GetNext();
280 if ( clientWindowChanged
)
282 // FIXME:: excessive?
284 mpLayout
->GetFrameClient()->Refresh();