]>
git.saurik.com Git - wxWidgets.git/blob - utils/framelayout/src/updatesmgr.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "updatesmgr.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
28 #include "updatesmgr.h"
32 static inline bool rect_hits_rect( const wxRect
& r1
, const wxRect
& r2
)
34 if ( ( r2
.x
>= r1
.x
&& r2
.x
<= r1
.x
+ r1
.width
) ||
35 ( r1
.x
>= r2
.x
&& r1
.x
<= r2
.x
+ r2
.width
) )
37 if ( ( r2
.y
>= r1
.y
&& r2
.y
<= r1
.y
+ r1
.height
) ||
38 ( r1
.y
>= r2
.y
&& r1
.y
<= r2
.y
+ r2
.height
) )
45 /***** Implementation for class cbSimpleUpdatesMgr *****/
47 IMPLEMENT_DYNAMIC_CLASS( cbSimpleUpdatesMgr
, cbUpdatesManagerBase
)
49 cbSimpleUpdatesMgr::cbSimpleUpdatesMgr( wxFrameLayout
* pPanel
)
50 : cbUpdatesManagerBase( pPanel
)
53 bool cbSimpleUpdatesMgr::WasChanged( cbUpdateMgrData
& data
, wxRect
& currentBounds
)
55 return ( data
.IsDirty() ||
57 ( data
.mPrevBounds
.x
!= currentBounds
.x
||
58 data
.mPrevBounds
.y
!= currentBounds
.y
||
59 data
.mPrevBounds
.width
!= currentBounds
.width
||
60 data
.mPrevBounds
.height
!= currentBounds
.height
)
64 void cbSimpleUpdatesMgr::OnStartChanges()
66 // memorize states of ALL items in the layout -
67 // this is quite excessive, but OK for the simple
68 // implementation of updates manager
70 mpLayout
->GetPrevClientRect() = mpLayout
->GetClientRect();
72 cbDockPane
** panes
= mpLayout
->GetPanesArray();
74 for( int n
= 0; n
!= MAX_PANES
; ++n
)
76 cbDockPane
& pane
= *panes
[n
];
78 pane
.mUMgrData
.StoreItemState( pane
.mBoundsInParent
);
79 pane
.mUMgrData
.SetDirty( FALSE
);
81 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
83 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
86 row
.mUMgrData
.StoreItemState( row
.mBoundsInParent
);
87 row
.mUMgrData
.SetDirty( FALSE
);
89 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
91 cbBarInfo
& bar
= *row
.mBars
[ k
];
94 bar
.mUMgrData
.StoreItemState( bar
.mBoundsInParent
);
95 bar
.mUMgrData
.SetDirty( FALSE
);
101 void cbSimpleUpdatesMgr::OnFinishChanges()
103 // nothing here, could be overriden by more sophisticated updates-managers
106 void cbSimpleUpdatesMgr::OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
)
111 void cbSimpleUpdatesMgr::OnBarWillChange( cbBarInfo
* pBar
,
112 cbRowInfo
* pInRow
, cbDockPane
* pInPane
)
117 void cbSimpleUpdatesMgr::OnPaneMarginsWillChange( cbDockPane
* pPane
)
122 void cbSimpleUpdatesMgr::OnPaneWillChange( cbDockPane
* pPane
)
127 void cbSimpleUpdatesMgr::UpdateNow()
129 cbDockPane
** panes
= mpLayout
->GetPanesArray();
131 wxRect
& r1
= mpLayout
->GetClientRect();
132 wxRect
& r2
= mpLayout
->GetPrevClientRect();
134 // detect changes in client window's area
136 bool clientWindowChanged
= ( r1
.x
!= r2
.x
||
138 r1
.width
!= r2
.width
||
139 r1
.height
!= r2
.height
);
141 // step #1 - detect changes in each row of each pane,
142 // and repaint decorations around changed windows
144 wxList mBarsToRefresh
;
147 for( int n
= 0; n
!= MAX_PANES
; ++n
)
149 cbDockPane
& pane
= *(panes
[n
]);
151 bool paneChanged
= WasChanged( pane
.mUMgrData
, pane
.mBoundsInParent
);
155 wxClientDC
dc( &mpLayout
->GetParentFrame() );
156 pane
.PaintPaneBackground( dc
);
161 for( size_t i
= 0; i
!= pane
.GetRowList().Count(); ++i
)
163 cbRowInfo
& row
= *pane
.GetRowList()[ i
];
167 bool rowChanged
= FALSE
;
168 bool rowBkPainted
= FALSE
;
170 // FIXME:: the below should not be fixed
171 cbBarInfo
* barsToRepaint
[256];
173 // number of bars, that were changed in the current row
176 if ( WasChanged( row
.mUMgrData
, row
.mBoundsInParent
) )
180 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
182 if ( WasChanged( row
.mBars
[k
]->mUMgrData
,
183 row
.mBars
[k
]->mBoundsInParent
)
186 barsToRepaint
[nBars
++] = row
.mBars
[k
];
188 if ( nBars
|| rowChanged
)
190 realBounds
= row
.mBoundsInParent
;
192 // include 1-pixel thick shades around the row
195 realBounds
.width
+= 2;
196 realBounds
.height
+= 2;
198 pDc
= pane
.StartDrawInArea( realBounds
);
203 // postphone the resizing and refreshing the changed
206 for( size_t k
= 0; k
!= row
.mBars
.Count(); ++k
)
208 mBarsToRefresh
.Append( (wxObject
*)row
.mBars
[k
] );
209 mPanesList
.Append( &pane
);
212 // draw only their decorations now
214 pane
.PaintRow( &row
, *pDc
);
219 for( int i
= 0; i
!= nBars
; ++i
)
221 // postphone the resizement and refreshing the changed
224 mBarsToRefresh
.Append( (wxObject
*)barsToRepaint
[i
] );
225 mPanesList
.Append( &pane
);
228 // redraw decorations of entire row, regardless of how much
229 // of the bars were changed
230 pane
.PaintRow( &row
, *pDc
);
235 pane
.FinishDrawInArea( realBounds
);
240 wxClientDC
dc( &mpLayout
->GetParentFrame() );
241 pane
.PaintPaneDecorations( dc
);
246 if ( clientWindowChanged
)
248 mpLayout
->PositionClientWindow();
249 // ptr to client-window object is "marked" as 0
252 // step #2 - do ordered refreshing and resizing of bar window objects now
254 wxNode
* pNode
= mBarsToRefresh
.First();
255 wxNode
* pPaneNode
= mPanesList
.First();
259 cbBarInfo
* pBar
= (cbBarInfo
*) pNode
->Data();
260 cbDockPane
* pPane
= (cbDockPane
*)pPaneNode
->Data();
262 pPane
->SizeBar( pBar
);
264 pNode
= pNode
->Next();
265 pPaneNode
= pPaneNode
->Next();
268 pNode
= mBarsToRefresh
.First();
272 cbBarInfo
* pBar
= (cbBarInfo
*)pNode
->Data();
274 if ( pBar
->mpBarWnd
)
276 pBar
->mpBarWnd
->Refresh();
279 //info.mpBarWnd->Show(FALSE);
280 //info.mpBarWnd->Show(TRUE);
283 pNode
= pNode
->Next();
286 if ( clientWindowChanged
)
288 // FIXME:: excessive?
290 mpLayout
->GetFrameClient()->Refresh();