src/window.cpp
changeset 10161 4331e1c4c987
parent 10083 9fb63cf5cc90
child 10162 d0d33ae1c7bc
equal deleted inserted replaced
10160:11cc0b7750c2 10161:4331e1c4c987
   248 			}
   248 			}
   249 		}
   249 		}
   250 	}
   250 	}
   251 }
   251 }
   252 
   252 
   253 static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right, int bottom);
       
   254 
       
   255 /**
       
   256  * From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
       
   257  * These windows should be re-painted.
       
   258  * @param left Left edge of the rectangle that should be repainted
       
   259  * @param top Top edge of the rectangle that should be repainted
       
   260  * @param right Right edge of the rectangle that should be repainted
       
   261  * @param bottom Bottom edge of the rectangle that should be repainted
       
   262  */
       
   263 void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
       
   264 {
       
   265 	Window* const *wz;
       
   266 	DrawPixelInfo bk;
       
   267 	_cur_dpi = &bk;
       
   268 
       
   269 	FOR_ALL_WINDOWS(wz) {
       
   270 		const Window *w = *wz;
       
   271 		if (right > w->left &&
       
   272 				bottom > w->top &&
       
   273 				left < w->left + w->width &&
       
   274 				top < w->top + w->height) {
       
   275 			DrawOverlappedWindow(wz, left, top, right, bottom);
       
   276 		}
       
   277 	}
       
   278 }
       
   279 
       
   280 /**
   253 /**
   281  * Generate repaint events for the visible part of window *wz within the rectangle.
   254  * Generate repaint events for the visible part of window *wz within the rectangle.
   282  *
   255  *
   283  * The function goes recursively upwards in the window stack, and splits the rectangle
   256  * The function goes recursively upwards in the window stack, and splits the rectangle
   284  * into multiple pieces at the window edges, so obscured parts are not redrawn.
   257  * into multiple pieces at the window edges, so obscured parts are not redrawn.
   286  * @param wz Pointer into window stack, pointing at the window that needs to be repainted
   259  * @param wz Pointer into window stack, pointing at the window that needs to be repainted
   287  * @param left Left edge of the rectangle that should be repainted
   260  * @param left Left edge of the rectangle that should be repainted
   288  * @param top Top edge of the rectangle that should be repainted
   261  * @param top Top edge of the rectangle that should be repainted
   289  * @param right Right edge of the rectangle that should be repainted
   262  * @param right Right edge of the rectangle that should be repainted
   290  * @param bottom Bottom edge of the rectangle that should be repainted
   263  * @param bottom Bottom edge of the rectangle that should be repainted
   291  *
       
   292  * @todo Swap this function to above DrawOverlappedWindowForAll() to eliminate the forward declaration
       
   293  */
   264  */
   294 static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right, int bottom)
   265 static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right, int bottom)
   295 {
   266 {
   296 	Window* const *vz = wz;
   267 	Window* const *vz = wz;
   297 
   268 
   331 
   302 
   332 			return;
   303 			return;
   333 		}
   304 		}
   334 	}
   305 	}
   335 
   306 
   336 	{
   307 	DrawPixelInfo *dp = _cur_dpi;
   337 		DrawPixelInfo *dp = _cur_dpi;
   308 	dp->width = right - left;
   338 		dp->width = right - left;
   309 	dp->height = bottom - top;
   339 		dp->height = bottom - top;
   310 	dp->left = left - (*wz)->left;
   340 		dp->left = left - (*wz)->left;
   311 	dp->top = top - (*wz)->top;
   341 		dp->top = top - (*wz)->top;
   312 	dp->pitch = _screen.pitch;
   342 		dp->pitch = _screen.pitch;
   313 	dp->dst_ptr = BlitterFactoryBase::GetCurrentBlitter()->MoveTo(_screen.dst_ptr, left, top);
   343 		dp->dst_ptr = BlitterFactoryBase::GetCurrentBlitter()->MoveTo(_screen.dst_ptr, left, top);
   314 	dp->zoom = ZOOM_LVL_NORMAL;
   344 		dp->zoom = ZOOM_LVL_NORMAL;
   315 	CallWindowEventNP(*wz, WE_PAINT);
   345 		CallWindowEventNP(*wz, WE_PAINT);
   316 }
       
   317 
       
   318 /**
       
   319  * From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
       
   320  * These windows should be re-painted.
       
   321  * @param left Left edge of the rectangle that should be repainted
       
   322  * @param top Top edge of the rectangle that should be repainted
       
   323  * @param right Right edge of the rectangle that should be repainted
       
   324  * @param bottom Bottom edge of the rectangle that should be repainted
       
   325  */
       
   326 void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
       
   327 {
       
   328 	Window* const *wz;
       
   329 	DrawPixelInfo bk;
       
   330 	_cur_dpi = &bk;
       
   331 
       
   332 	FOR_ALL_WINDOWS(wz) {
       
   333 		const Window *w = *wz;
       
   334 		if (right > w->left &&
       
   335 				bottom > w->top &&
       
   336 				left < w->left + w->width &&
       
   337 				top < w->top + w->height) {
       
   338 			DrawOverlappedWindow(wz, left, top, right, bottom);
       
   339 		}
   346 	}
   340 	}
   347 }
   341 }
   348 
   342 
   349 /**
   343 /**
   350  * Dispatch an event to a possibly non-existing window.
   344  * Dispatch an event to a possibly non-existing window.