]>
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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "updatesmgr.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/fl/updatesmgr.h"
31 static inline bool rect_hits_rect( const wxRect
& r1
, const wxRect
& r2
)
33 if ( ( r2
.x
>= r1
.x
&& r2
.x
<= r1
.x
+ r1
.width
) ||
34 ( r1
.x
>= r2
.x
&& r1
.x
<= r2
.x
+ r2
.width
) )
36 if ( ( r2
.y
>= r1
.y
&& r2
.y
<= r1
.y
+ r1
.height
) ||
37 ( r1
.y
>= r2
.y
&& r1
.y
<= r2
.y
+ r2
.height
) )
44 /***** Implementation for class cbSimpleUpdatesMgr *****/
46 IMPLEMENT_DYNAMIC_CLASS( cbSimpleUpdatesMgr
, cbUpdatesManagerBase
)
48 cbSimpleUpdatesMgr::cbSimpleUpdatesMgr( wxFrameLayout
* pPanel
)
49 : cbUpdatesManagerBase( pPanel
)
52 bool cbSimpleUpdatesMgr::WasChanged( cbUpdateMgrData
& data
, wxRect
& currentBounds
)
54 return ( data
.IsDirty() ||
56 ( data
.mPrevBounds
.x
!= currentBounds
.x
||
57 data
.mPrevBounds
.y
!= currentBounds
.y
||
58 data
.mPrevBounds
.width
!= currentBounds
.width
||
59 data
.mPrevBounds
.height
!= currentBounds
.height
)
63 void cbSimpleUpdatesMgr::OnStartChanges()
65 // memorize states of ALL items in the layout -
66 // this is quite excessive, but OK for the simple
67 // implementation of updates manager
69 mpLayout
->GetPrevClientRect() = mpLayout
->GetClientRect();
71 cbDockPane
** panes
= mpLayout
->GetPanesArray();
73 for( int n
= 0; n
!= MAX_PANES
; ++n
)
75 cbDockPane
& pane
= *panes
[n
];
77 pane
.mUMgrData
.StoreItemState( pane
.mBoundsInParent
);
78 pane
.mUMgrData
.SetDirty( FALSE
);
80 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
82 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
85 row
.mUMgrData
.StoreItemState( row
.mBoundsInParent
);
86 row
.mUMgrData
.SetDirty( FALSE
);
88 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
90 cbBarInfo
& bar
= *row
.mBars
[ k
];
93 bar
.mUMgrData
.StoreItemState( bar
.mBoundsInParent
);
94 bar
.mUMgrData
.SetDirty( FALSE
);
100 void cbSimpleUpdatesMgr::OnFinishChanges()
102 // nothing here, could be overriden by more sophisticated updates-managers
105 void cbSimpleUpdatesMgr::OnRowWillChange( cbRowInfo
* WXUNUSED(pRow
), cbDockPane
* WXUNUSED(pInPane
) )
110 void cbSimpleUpdatesMgr::OnBarWillChange( cbBarInfo
* WXUNUSED(pBar
),
111 cbRowInfo
* WXUNUSED(pInRow
), cbDockPane
* WXUNUSED(pInPane
) )
116 void cbSimpleUpdatesMgr::OnPaneMarginsWillChange( cbDockPane
* WXUNUSED(pPane
) )
121 void cbSimpleUpdatesMgr::OnPaneWillChange( cbDockPane
* WXUNUSED(pPane
) )
126 void cbSimpleUpdatesMgr::UpdateNow()
128 cbDockPane
** panes
= mpLayout
->GetPanesArray();
130 wxRect
& r1
= mpLayout
->GetClientRect();
131 wxRect
& r2
= mpLayout
->GetPrevClientRect();
133 // detect changes in client window's area
135 bool clientWindowChanged
= ( r1
.x
!= r2
.x
||
137 r1
.width
!= r2
.width
||
138 r1
.height
!= r2
.height
);
140 // step #1 - detect changes in each row of each pane,
141 // and repaint decorations around changed windows
143 wxList mBarsToRefresh
;
146 for( int n
= 0; n
!= MAX_PANES
; ++n
)
148 cbDockPane
& pane
= *(panes
[n
]);
150 bool paneChanged
= WasChanged( pane
.mUMgrData
, pane
.mBoundsInParent
);
154 wxClientDC
dc( &mpLayout
->GetParentFrame() );
155 pane
.PaintPaneBackground( dc
);
160 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
162 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
166 bool rowChanged
= FALSE
;
168 // FIXME:: the below should not be fixed
169 cbBarInfo
* barsToRepaint
[256];
171 // number of bars, that were changed in the current row
174 if ( WasChanged( row
.mUMgrData
, row
.mBoundsInParent
) )
178 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
180 if ( WasChanged( row
.mBars
[k
]->mUMgrData
,
181 row
.mBars
[k
]->mBoundsInParent
)
184 barsToRepaint
[nBars
++] = row
.mBars
[k
];
186 if ( nBars
|| rowChanged
)
188 realBounds
= row
.mBoundsInParent
;
190 // include 1-pixel thick shades around the row
193 realBounds
.width
+= 2;
194 realBounds
.height
+= 2;
196 pDc
= pane
.StartDrawInArea( realBounds
);
201 // postphone the resizing and refreshing the changed
204 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
206 mBarsToRefresh
.Append( (wxObject
*)row
.mBars
[k
] );
207 mPanesList
.Append( &pane
);
210 // draw only their decorations now
212 pane
.PaintRow( &row
, *pDc
);
217 for( int i
= 0; i
!= nBars
; ++i
)
219 // postphone the resizement and refreshing the changed
222 mBarsToRefresh
.Append( (wxObject
*)barsToRepaint
[i
] );
223 mPanesList
.Append( &pane
);
226 // redraw decorations of entire row, regardless of how much
227 // of the bars were changed
228 pane
.PaintRow( &row
, *pDc
);
233 pane
.FinishDrawInArea( realBounds
);
238 wxClientDC
dc( &mpLayout
->GetParentFrame() );
239 pane
.PaintPaneDecorations( dc
);
244 if ( clientWindowChanged
)
246 mpLayout
->PositionClientWindow();
247 // ptr to client-window object is "marked" as 0
250 // step #2 - do ordered refreshing and resizing of bar window objects now
252 wxNode
* pNode
= mBarsToRefresh
.GetFirst();
253 wxNode
* pPaneNode
= mPanesList
.GetFirst();
257 cbBarInfo
* pBar
= (cbBarInfo
*) pNode
->GetData();
258 cbDockPane
* pPane
= (cbDockPane
*)pPaneNode
->GetData();
260 pPane
->SizeBar( pBar
);
262 pNode
= pNode
->GetNext();
263 pPaneNode
= pPaneNode
->GetNext();
266 pNode
= mBarsToRefresh
.GetFirst();
270 cbBarInfo
* pBar
= (cbBarInfo
*)pNode
->GetData();
272 if ( pBar
->mpBarWnd
)
274 pBar
->mpBarWnd
->Refresh();
277 //info.mpBarWnd->Show(FALSE);
278 //info.mpBarWnd->Show(TRUE);
281 pNode
= pNode
->GetNext();
284 if ( clientWindowChanged
)
286 // FIXME:: excessive?
288 mpLayout
->GetFrameClient()->Refresh();