Home » Developing U++ » UppHub » Raster Control
Re: Raster Control [message #15111 is a reply to message #15110] |
Tue, 01 April 2008 15:11 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I'm opening an image that doesn't require thumbnails to be shown and is smaller than the window. This causes 3/4 divide by ZERO errors for various reasons. I appreciate that this is kind of the opposite to how the control is supposed to be used though.
- In RasterThumbsCtrl::CalcScale:
int RasterThumbsCtrl::CalcScale(int imScale, int rasterWidth, int maxPageHeight)
{
// calculates scale factor based on max thumb width
// slightly smaller than ctrl width
int maxScaledWidth = iscale(GetSize().cx, THUMBS_HSIZE_MUL, THUMBS_HSIZE_DIV);
return iscale(maxScaledWidth, 1000, rasterWidth);
} // END RasterThumbsCtrl::CalcScale() With no thumbnails GetSize().cx is 0 since you have previously set the splitter pos to 0. imageScale is then set to 0 and causes a DIVIDE_BY_ZERO. Adding the following after the call to CalcSize in RasterBaseCtrl::Layout
if (!imageScale) {
inside = false;
return;
} fixes it.
- Also RasterBaseCtrl::Layout. You need !0 checks for vScollMax and hScrollMax on the two lines that do:
hScrollBar.Set(iscale(hScrollPos, scaledRasterWidth, hScrollMax)); and the vertical equivalent. I don't really understand what's going on here, but I can't see how this could ever work since vScrollMax should always start as 0.
- RasterBaseCtrl::PaintCache. Add a check for imageScale == 0 at the start of the function.
- ImageCache::Fill, caused when you resize the window down to nothing. Change first line to:
if(imageBuffer.IsEmpty() || !imageBuffer.GetSize().cx || !imageBuffer.GetSize().cy)
Then everything works very nicely .
You also may want to investigate Upp::Scroller. Not sure if this'll help in your case but it's worth a look.
James
[Updated on: Tue, 01 April 2008 18:12] Report message to a moderator
|
|
|
|
|
Raster Control
By: mdelfede on Thu, 20 March 2008 21:58
|
|
|
Re: Raster Control
By: mrjt on Tue, 01 April 2008 11:22
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 14:09
|
|
|
Re: Raster Control
By: mrjt on Tue, 01 April 2008 15:11
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 15:38
|
|
|
Re: Raster Control
By: mrjt on Tue, 01 April 2008 16:13
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 18:52
|
|
|
Re: Raster Control
By: mrjt on Tue, 01 April 2008 19:08
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 21:05
|
|
|
Re: Raster Control
By: mr_ped on Tue, 01 April 2008 21:57
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 22:14
|
|
|
Re: Raster Control
By: mdelfede on Tue, 01 April 2008 22:59
|
|
|
Re: Raster Control
By: mr_ped on Tue, 08 April 2008 17:34
|
|
|
Re: Raster Control
By: mdelfede on Wed, 09 April 2008 10:28
|
|
|
Re: Raster Control
By: mr_ped on Wed, 09 April 2008 10:59
|
Goto Forum:
Current Time: Wed Jun 05 03:46:00 CEST 2024
Total time taken to generate the page: 0.01997 seconds
|