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