]>
Commit | Line | Data |
---|---|---|
8e08b761 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4cbc57f0 JS |
2 | // Name: updatesmgr.cpp |
3 | // Purpose: cbSimpleUpdatesMgr implementation. | |
8e08b761 JS |
4 | // Author: Aleksandras Gluchovas |
5 | // Modified by: | |
6 | // Created: 19/10/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
4cbc57f0 | 9 | // Licence: wxWindows licence |
8e08b761 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8e08b761 JS |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
23 | #include "wx/fl/updatesmgr.h" | |
24 | ||
25 | // helper function | |
26 | ||
27 | static inline bool rect_hits_rect( const wxRect& r1, const wxRect& r2 ) | |
28 | { | |
4cbc57f0 JS |
29 | if ( ( r2.x >= r1.x && r2.x <= r1.x + r1.width ) || |
30 | ( r1.x >= r2.x && r1.x <= r2.x + r2.width ) ) | |
8e08b761 | 31 | |
4cbc57f0 JS |
32 | if ( ( r2.y >= r1.y && r2.y <= r1.y + r1.height ) || |
33 | ( r1.y >= r2.y && r1.y <= r2.y + r2.height ) ) | |
34 | ||
35 | return 1; | |
8e08b761 | 36 | |
4cbc57f0 | 37 | return 0; |
8e08b761 JS |
38 | } |
39 | ||
40 | /***** Implementation for class cbSimpleUpdatesMgr *****/ | |
41 | ||
42 | IMPLEMENT_DYNAMIC_CLASS( cbSimpleUpdatesMgr, cbUpdatesManagerBase ) | |
43 | ||
44 | cbSimpleUpdatesMgr::cbSimpleUpdatesMgr( wxFrameLayout* pPanel ) | |
4cbc57f0 | 45 | : cbUpdatesManagerBase( pPanel ) |
8e08b761 JS |
46 | {} |
47 | ||
48 | bool cbSimpleUpdatesMgr::WasChanged( cbUpdateMgrData& data, wxRect& currentBounds ) | |
49 | { | |
4cbc57f0 | 50 | return ( data.IsDirty() || |
8e08b761 | 51 | |
4cbc57f0 JS |
52 | ( data.mPrevBounds.x != currentBounds.x || |
53 | data.mPrevBounds.y != currentBounds.y || | |
54 | data.mPrevBounds.width != currentBounds.width || | |
55 | data.mPrevBounds.height != currentBounds.height ) | |
56 | ); | |
8e08b761 JS |
57 | } |
58 | ||
59 | void cbSimpleUpdatesMgr::OnStartChanges() | |
60 | { | |
4cbc57f0 JS |
61 | // memorize states of ALL items in the layout - |
62 | // this is quite excessive, but OK for the simple | |
63 | // implementation of updates manager | |
64 | ||
65 | mpLayout->GetPrevClientRect() = mpLayout->GetClientRect(); | |
66 | ||
67 | cbDockPane** panes = mpLayout->GetPanesArray(); | |
68 | ||
69 | for( int n = 0; n != MAX_PANES; ++n ) | |
70 | { | |
71 | cbDockPane& pane = *panes[n]; | |
72 | // store pane state | |
73 | pane.mUMgrData.StoreItemState( pane.mBoundsInParent ); | |
c82c42d4 | 74 | pane.mUMgrData.SetDirty( false ); |
4cbc57f0 JS |
75 | |
76 | for( size_t i = 0; i != pane.GetRowList().Count(); ++i ) | |
77 | { | |
78 | cbRowInfo& row = *pane.GetRowList()[ i ]; | |
79 | ||
80 | // store row state | |
81 | row.mUMgrData.StoreItemState( row.mBoundsInParent ); | |
c82c42d4 | 82 | row.mUMgrData.SetDirty( false ); |
4cbc57f0 JS |
83 | |
84 | for( size_t k = 0; k != row.mBars.Count(); ++k ) | |
85 | { | |
86 | cbBarInfo& bar = *row.mBars[ k ]; | |
87 | ||
88 | // store bar state | |
89 | bar.mUMgrData.StoreItemState( bar.mBoundsInParent ); | |
c82c42d4 | 90 | bar.mUMgrData.SetDirty( false ); |
4cbc57f0 JS |
91 | } |
92 | } | |
93 | } | |
8e08b761 JS |
94 | } |
95 | ||
96 | void cbSimpleUpdatesMgr::OnFinishChanges() | |
97 | { | |
4cbc57f0 | 98 | // nothing here, could be overriden by more sophisticated updates-managers |
8e08b761 JS |
99 | } |
100 | ||
196be0f1 | 101 | void cbSimpleUpdatesMgr::OnRowWillChange( cbRowInfo* WXUNUSED(pRow), cbDockPane* WXUNUSED(pInPane) ) |
8e08b761 | 102 | { |
4cbc57f0 | 103 | // -/- |
8e08b761 JS |
104 | } |
105 | ||
196be0f1 JS |
106 | void cbSimpleUpdatesMgr::OnBarWillChange( cbBarInfo* WXUNUSED(pBar), |
107 | cbRowInfo* WXUNUSED(pInRow), cbDockPane* WXUNUSED(pInPane) ) | |
8e08b761 | 108 | { |
4cbc57f0 | 109 | // -/- |
8e08b761 JS |
110 | } |
111 | ||
196be0f1 | 112 | void cbSimpleUpdatesMgr::OnPaneMarginsWillChange( cbDockPane* WXUNUSED(pPane) ) |
8e08b761 | 113 | { |
4cbc57f0 | 114 | // -/- |
8e08b761 JS |
115 | } |
116 | ||
196be0f1 | 117 | void cbSimpleUpdatesMgr::OnPaneWillChange( cbDockPane* WXUNUSED(pPane) ) |
8e08b761 | 118 | { |
4cbc57f0 | 119 | // -/- |
8e08b761 JS |
120 | } |
121 | ||
122 | void cbSimpleUpdatesMgr::UpdateNow() | |
123 | { | |
4cbc57f0 | 124 | cbDockPane** panes = mpLayout->GetPanesArray(); |
8e08b761 | 125 | |
4cbc57f0 JS |
126 | wxRect& r1 = mpLayout->GetClientRect(); |
127 | wxRect& r2 = mpLayout->GetPrevClientRect(); | |
8e08b761 | 128 | |
4cbc57f0 | 129 | // detect changes in client window's area |
8e08b761 | 130 | |
4cbc57f0 JS |
131 | bool clientWindowChanged = ( r1.x != r2.x || |
132 | r1.y != r2.y || | |
133 | r1.width != r2.width || | |
134 | r1.height != r2.height ); | |
135 | ||
136 | // step #1 - detect changes in each row of each pane, | |
137 | // and repaint decorations around changed windows | |
8e08b761 | 138 | |
4cbc57f0 JS |
139 | wxList mBarsToRefresh; |
140 | wxList mPanesList; | |
8e08b761 | 141 | |
4cbc57f0 JS |
142 | for( int n = 0; n != MAX_PANES; ++n ) |
143 | { | |
144 | cbDockPane& pane = *(panes[n]); | |
8e08b761 | 145 | |
4cbc57f0 | 146 | bool paneChanged = WasChanged( pane.mUMgrData, pane.mBoundsInParent ); |
8e08b761 | 147 | |
4cbc57f0 JS |
148 | if ( paneChanged ) |
149 | { | |
150 | wxClientDC dc( &mpLayout->GetParentFrame() ); | |
151 | pane.PaintPaneBackground( dc ); | |
152 | } | |
8e08b761 | 153 | |
4cbc57f0 | 154 | wxRect realBounds; |
8e08b761 | 155 | |
4cbc57f0 JS |
156 | for( size_t i = 0; i != pane.GetRowList().Count(); ++i ) |
157 | { | |
158 | cbRowInfo& row = *pane.GetRowList()[ i ]; | |
8e08b761 | 159 | |
4cbc57f0 | 160 | wxDC* pDc = NULL; |
8e08b761 | 161 | |
c82c42d4 | 162 | bool rowChanged = false; |
8e08b761 | 163 | |
4cbc57f0 JS |
164 | // FIXME:: the below should not be fixed |
165 | cbBarInfo* barsToRepaint[256]; | |
8e08b761 | 166 | |
4cbc57f0 JS |
167 | // number of bars, that were changed in the current row |
168 | int nBars = 0; | |
8e08b761 | 169 | |
4cbc57f0 JS |
170 | if ( WasChanged( row.mUMgrData, row.mBoundsInParent ) ) |
171 | ||
c82c42d4 | 172 | rowChanged = true; |
4cbc57f0 JS |
173 | else |
174 | for( size_t k = 0; k != row.mBars.Count(); ++k ) | |
8e08b761 | 175 | |
4cbc57f0 JS |
176 | if ( WasChanged( row.mBars[k]->mUMgrData, |
177 | row.mBars[k]->mBoundsInParent ) | |
178 | ) | |
179 | ||
180 | barsToRepaint[nBars++] = row.mBars[k]; | |
8e08b761 | 181 | |
4cbc57f0 JS |
182 | if ( nBars || rowChanged ) |
183 | { | |
184 | realBounds = row.mBoundsInParent; | |
8e08b761 | 185 | |
4cbc57f0 JS |
186 | // include 1-pixel thick shades around the row |
187 | realBounds.x -= 1; | |
188 | realBounds.y -= 1; | |
189 | realBounds.width += 2; | |
190 | realBounds.height += 2; | |
8e08b761 | 191 | |
4cbc57f0 JS |
192 | pDc = pane.StartDrawInArea( realBounds ); |
193 | } | |
8e08b761 | 194 | |
4cbc57f0 JS |
195 | if ( rowChanged ) |
196 | { | |
197 | // postphone the resizing and refreshing the changed | |
198 | // bar windows | |
8e08b761 | 199 | |
4cbc57f0 JS |
200 | for( size_t k = 0; k != row.mBars.Count(); ++k ) |
201 | { | |
202 | mBarsToRefresh.Append( (wxObject*)row.mBars[k] ); | |
203 | mPanesList.Append( &pane ); | |
204 | } | |
8e08b761 | 205 | |
4cbc57f0 | 206 | // draw only their decorations now |
8e08b761 | 207 | |
4cbc57f0 JS |
208 | pane.PaintRow( &row, *pDc ); |
209 | } | |
210 | else | |
211 | if ( nBars != 0 ) | |
212 | { | |
213 | for( int i = 0; i != nBars; ++i ) | |
214 | { | |
215 | // postphone the resizement and refreshing the changed | |
216 | // bar windows | |
8e08b761 | 217 | |
4cbc57f0 JS |
218 | mBarsToRefresh.Append( (wxObject*)barsToRepaint[i] ); |
219 | mPanesList.Append( &pane ); | |
220 | } | |
8e08b761 | 221 | |
4cbc57f0 JS |
222 | // redraw decorations of entire row, regardless of how much |
223 | // of the bars were changed | |
224 | pane.PaintRow( &row, *pDc ); | |
225 | } | |
8e08b761 | 226 | |
4cbc57f0 JS |
227 | if ( pDc ) |
228 | ||
229 | pane.FinishDrawInArea( realBounds ); | |
230 | } // end of while | |
8e08b761 | 231 | |
4cbc57f0 JS |
232 | if ( paneChanged ) |
233 | { | |
234 | wxClientDC dc( &mpLayout->GetParentFrame() ); | |
235 | pane.PaintPaneDecorations( dc ); | |
236 | } | |
8e08b761 | 237 | |
4cbc57f0 | 238 | } // end of for |
8e08b761 | 239 | |
4cbc57f0 JS |
240 | if ( clientWindowChanged ) |
241 | { | |
242 | mpLayout->PositionClientWindow(); | |
243 | // ptr to client-window object is "marked" as 0 | |
244 | } | |
8e08b761 | 245 | |
4cbc57f0 | 246 | // step #2 - do ordered refreshing and resizing of bar window objects now |
8e08b761 | 247 | |
8495ba53 GD |
248 | wxNode* pNode = mBarsToRefresh.GetFirst(); |
249 | wxNode* pPaneNode = mPanesList.GetFirst(); | |
4cbc57f0 JS |
250 | |
251 | while( pNode ) | |
252 | { | |
8495ba53 GD |
253 | cbBarInfo* pBar = (cbBarInfo*) pNode->GetData(); |
254 | cbDockPane* pPane = (cbDockPane*)pPaneNode->GetData(); | |
8e08b761 | 255 | |
4cbc57f0 JS |
256 | pPane->SizeBar( pBar ); |
257 | ||
8495ba53 GD |
258 | pNode = pNode->GetNext(); |
259 | pPaneNode = pPaneNode->GetNext(); | |
4cbc57f0 JS |
260 | } |
261 | ||
8495ba53 | 262 | pNode = mBarsToRefresh.GetFirst(); |
4cbc57f0 JS |
263 | |
264 | while( pNode ) | |
265 | { | |
8495ba53 | 266 | cbBarInfo* pBar = (cbBarInfo*)pNode->GetData(); |
4cbc57f0 JS |
267 | |
268 | if ( pBar->mpBarWnd ) | |
269 | { | |
270 | pBar->mpBarWnd->Refresh(); | |
271 | ||
272 | // FIXME:: | |
c82c42d4 WS |
273 | //info.mpBarWnd->Show(false); |
274 | //info.mpBarWnd->Show(true); | |
4cbc57f0 JS |
275 | } |
276 | ||
8495ba53 | 277 | pNode = pNode->GetNext(); |
4cbc57f0 JS |
278 | } |
279 | ||
280 | if ( clientWindowChanged ) | |
281 | { | |
282 | // FIXME:: excessive? | |
283 | ||
284 | mpLayout->GetFrameClient()->Refresh(); | |
285 | } | |
8e08b761 JS |
286 | } |
287 | ||
11a68fa3 | 288 |