@ -113,7 +113,7 @@ as approximate as possible). However when converting from widget to image and ba
this can result in the final rectangle being smaller than the original .
this can result in the final rectangle being smaller than the original .
The widgetToImageBounding ( ) function converts from widget to image coordinates
The widgetToImageBounding ( ) function converts from widget to image coordinates
in a way which makes sure the reverse conversion will be at least as large
in a way which makes sure the reverse conversion will be at least as large
as the original tq geometry.
as the original geometry.
There are no conversion functions for only width / height , as their conversion
There are no conversion functions for only width / height , as their conversion
depends on the position ( because of the rounding etc . ) . For similar reasons
depends on the position ( because of the rounding etc . ) . For similar reasons
@ -257,7 +257,7 @@ struct ImageView::Private {
const double zoomValues [ ] = { 0.5 , 1 , 2 } ;
const double zoomValues [ ] = { 0.5 , 1 , 2 } ;
int nbValues = sizeof ( zoomValues ) / sizeof ( double ) ;
int nbValues = sizeof ( zoomValues ) / sizeof ( double ) ;
for ( int pos = 0 ; pos < nbValues ; + + pos ) {
for ( int pos = 0 ; pos < nbValues ; + + pos ) {
TQString txt = TQString ( " %1% " ) . tq arg( int ( zoomValues [ pos ] * 100 ) ) ;
TQString txt = TQString ( " %1% " ) . arg( int ( zoomValues [ pos ] * 100 ) ) ;
mZoomCombo - > insertItem ( txt ) ;
mZoomCombo - > insertItem ( txt ) ;
}
}
}
}
@ -423,7 +423,7 @@ ImageView::~ImageView() {
void ImageView : : slotLoaded ( ) {
void ImageView : : slotLoaded ( ) {
if ( d - > mDocument - > isNull ( ) ) {
if ( d - > mDocument - > isNull ( ) ) {
resizeContents ( 0 , 0 ) ;
resizeContents ( 0 , 0 ) ;
viewport ( ) - > tq repaint( false ) ;
viewport ( ) - > repaint( false ) ;
return ;
return ;
}
}
@ -488,7 +488,7 @@ KToggleAction* ImageView::zoomToFit() const {
void ImageView : : updateFromSettings ( ) {
void ImageView : : updateFromSettings ( ) {
// Reset, so that next tq repaint doesn't possibly take longer because of
// Reset, so that next repaint doesn't possibly take longer because of
// smoothing
// smoothing
ImageViewConfig : : setMaxRepaintSize ( DEFAULT_MAX_REPAINT_SIZE ) ;
ImageViewConfig : : setMaxRepaintSize ( DEFAULT_MAX_REPAINT_SIZE ) ;
ImageViewConfig : : setMaxScaleRepaintSize ( DEFAULT_MAX_REPAINT_SIZE ) ;
ImageViewConfig : : setMaxScaleRepaintSize ( DEFAULT_MAX_REPAINT_SIZE ) ;
@ -625,7 +625,7 @@ void ImageView::drawContents(TQPainter* painter,int clipx,int clipy,int clipw,in
TQRect widgetRect = TQRect ( 0 , 0 , visibleWidth ( ) , visibleHeight ( ) ) ;
TQRect widgetRect = TQRect ( 0 , 0 , visibleWidth ( ) , visibleHeight ( ) ) ;
TQRegion region = TQRegion ( widgetRect ) - imageRect ;
TQRegion region = TQRegion ( widgetRect ) - imageRect ;
TQMemArray < TQRect > rects = region . tq rects( ) ;
TQMemArray < TQRect > rects = region . rects( ) ;
for ( unsigned int pos = 0 ; pos < rects . count ( ) ; + + pos ) {
for ( unsigned int pos = 0 ; pos < rects . count ( ) ; + + pos ) {
painter - > eraseRect ( rects [ pos ] ) ;
painter - > eraseRect ( rects [ pos ] ) ;
}
}
@ -701,7 +701,7 @@ void ImageView::limitPaintSize( PendingPaint& paint ) {
// don't paint more than max_size pixels at a time
// don't paint more than max_size pixels at a time
int maxHeight = ( maxSize + paint . rect . width ( ) - 1 ) / paint . rect . width ( ) ; // round up
int maxHeight = ( maxSize + paint . rect . width ( ) - 1 ) / paint . rect . width ( ) ; // round up
maxHeight = TQMAX ( maxHeight , 5 ) ; // at least 5 lines together
maxHeight = TQMAX ( maxHeight , 5 ) ; // at least 5 lines together
// can't tq repaint whole paint at once, adjust height and schedule the rest
// can't repaint whole paint at once, adjust height and schedule the rest
if ( maxHeight < paint . rect . height ( ) ) {
if ( maxHeight < paint . rect . height ( ) ) {
TQRect remaining = paint . rect ;
TQRect remaining = paint . rect ;
remaining . setTop ( remaining . top ( ) + maxHeight ) ;
remaining . setTop ( remaining . top ( ) + maxHeight ) ;
@ -781,12 +781,12 @@ void ImageView::slotBusyLevelChanged( BusyLevel level ) {
// How to do painting:
// How to do painting:
// When something needs to be erased: TQPainter on viewport and eraseRect()
// When something needs to be erased: TQPainter on viewport and eraseRect()
// When whole picture needs to be repainted: fullRepaint()
// When whole picture needs to be repainted: fullRepaint()
// When a part of the picture needs to be updated: viewport()-> tq repaint(area,false)
// When a part of the picture needs to be updated: viewport()-> repaint(area,false)
// All other paints will be changed to progressive painting.
// All other paints will be changed to progressive painting.
void ImageView : : fullRepaint ( ) {
void ImageView : : fullRepaint ( ) {
if ( ! viewport ( ) - > isUpdatesEnabled ( ) ) return ;
if ( ! viewport ( ) - > isUpdatesEnabled ( ) ) return ;
cancelPending ( ) ;
cancelPending ( ) ;
viewport ( ) - > tq repaint( false ) ;
viewport ( ) - > repaint( false ) ;
}
}
void ImageView : : cancelPending ( ) {
void ImageView : : cancelPending ( ) {
@ -832,7 +832,7 @@ void ImageView::performPaint( TQPainter* painter, int clipx, int clipy, int clip
int extraPixels = ImageUtils : : extraScalePixels ( smoothAlgo , zoom ( ) ) ;
int extraPixels = ImageUtils : : extraScalePixels ( smoothAlgo , zoom ( ) ) ;
TQRect imageRect = d - > widgetToImageBounding ( TQRect ( clipx , clipy , clipw , cliph ) , extraPixels ) ;
TQRect imageRect = d - > widgetToImageBounding ( TQRect ( clipx , clipy , clipw , cliph ) , extraPixels ) ;
imageRect = imageRect . intersect ( TQRect ( 0 , 0 , d - > mDocument - > width ( ) , d - > mDocument - > height ( ) ) ) ;
imageRect = imageRect . intersect ( TQRect ( 0 , 0 , d - > mDocument - > width ( ) , d - > mDocument - > height ( ) ) ) ;
TQMemArray < TQRect > rects = TQRegion ( d - > mValidImageArea . intersect ( imageRect ) ) . tq rects( ) ;
TQMemArray < TQRect > rects = TQRegion ( d - > mValidImageArea . intersect ( imageRect ) ) . rects( ) ;
for ( unsigned int i = 1 ; i < rects . count ( ) ; + + i ) {
for ( unsigned int i = 1 ; i < rects . count ( ) ; + + i ) {
addPendingPaint ( secondPass , d - > imageToWidget ( rects [ i ] ) ) ;
addPendingPaint ( secondPass , d - > imageToWidget ( rects [ i ] ) ) ;
}
}
@ -1024,7 +1024,7 @@ bool ImageView::eventFilter(TQObject* obj, TQEvent* event) {
return true ;
return true ;
// Getting/loosing focus causes repaints, but repainting here is expensive,
// Getting/loosing focus causes repaints, but repainting here is expensive,
// and there's no need to tq repaint on focus changes, as the focus is not
// and there's no need to repaint on focus changes, as the focus is not
// indicated.
// indicated.
case TQEvent : : FocusIn :
case TQEvent : : FocusIn :
case TQEvent : : FocusOut :
case TQEvent : : FocusOut :
@ -1313,7 +1313,7 @@ void ImageView::slotImageSizeUpdated() {
void ImageView : : slotImageRectUpdated ( const TQRect & imageRect ) {
void ImageView : : slotImageRectUpdated ( const TQRect & imageRect ) {
d - > mValidImageArea + = imageRect ;
d - > mValidImageArea + = imageRect ;
viewport ( ) - > tq repaint( d - > imageToWidget ( imageRect ) , false ) ;
viewport ( ) - > repaint( d - > imageToWidget ( imageRect ) , false ) ;
}
}
@ -1339,7 +1339,7 @@ double ImageView::computeZoomToFit() const {
return 1.0 ;
return 1.0 ;
}
}
TQSize size = d - > mDocument - > image ( ) . size ( ) ;
TQSize size = d - > mDocument - > image ( ) . size ( ) ;
size . tq scale( width ( ) , height ( ) , TQSize : : ScaleMin ) ;
size . scale( width ( ) , height ( ) , TQSize : : ScaleMin ) ;
double zoom = double ( size . width ( ) ) / d - > mDocument - > width ( ) ;
double zoom = double ( size . width ( ) ) / d - > mDocument - > width ( ) ;
if ( zoom > 1.0 & & ! ImageViewConfig : : enlargeSmallImages ( ) ) return 1.0 ;
if ( zoom > 1.0 & & ! ImageViewConfig : : enlargeSmallImages ( ) ) return 1.0 ;
@ -1350,7 +1350,7 @@ double ImageView::computeZoomToWidth() const {
if ( d - > mDocument - > isNull ( ) ) {
if ( d - > mDocument - > isNull ( ) ) {
return 1.0 ;
return 1.0 ;
}
}
int sw = verticalScrollBar ( ) - > tq sizeHint( ) . width ( ) ; // tq geometry is not valid before first show()
int sw = verticalScrollBar ( ) - > sizeHint( ) . width ( ) ; // geometry is not valid before first show()
int w = width ( ) ;
int w = width ( ) ;
int dw = d - > mDocument - > width ( ) ;
int dw = d - > mDocument - > width ( ) ;
switch ( vScrollBarMode ( ) ) {
switch ( vScrollBarMode ( ) ) {
@ -1370,7 +1370,7 @@ double ImageView::computeZoomToHeight() const {
if ( d - > mDocument - > isNull ( ) ) {
if ( d - > mDocument - > isNull ( ) ) {
return 1.0 ;
return 1.0 ;
}
}
int sh = horizontalScrollBar ( ) - > tq sizeHint( ) . height ( ) ;
int sh = horizontalScrollBar ( ) - > sizeHint( ) . height ( ) ;
int h = height ( ) ;
int h = height ( ) ;
int dh = d - > mDocument - > height ( ) ;
int dh = d - > mDocument - > height ( ) ;
switch ( vScrollBarMode ( ) ) {
switch ( vScrollBarMode ( ) ) {
@ -1425,11 +1425,11 @@ void ImageView::updateImageOffset() {
int zpixHeight = int ( d - > mDocument - > height ( ) * d - > mZoom ) ;
int zpixHeight = int ( d - > mDocument - > height ( ) * d - > mZoom ) ;
if ( zpixWidth > viewWidth & & hScrollBarMode ( ) ! = AlwaysOff ) {
if ( zpixWidth > viewWidth & & hScrollBarMode ( ) ! = AlwaysOff ) {
// use tq sizeHint() - tq geometry is not valid before first show()
// use sizeHint() - geometry is not valid before first show()
viewHeight - = horizontalScrollBar ( ) - > tq sizeHint( ) . height ( ) ;
viewHeight - = horizontalScrollBar ( ) - > sizeHint( ) . height ( ) ;
}
}
if ( zpixHeight > viewHeight & & vScrollBarMode ( ) ! = AlwaysOff ) {
if ( zpixHeight > viewHeight & & vScrollBarMode ( ) ! = AlwaysOff ) {
viewWidth - = verticalScrollBar ( ) - > tq sizeHint( ) . width ( ) ;
viewWidth - = verticalScrollBar ( ) - > sizeHint( ) . width ( ) ;
}
}
d - > mXOffset = TQMAX ( 0 , ( viewWidth - zpixWidth ) / 2 ) ;
d - > mXOffset = TQMAX ( 0 , ( viewWidth - zpixWidth ) / 2 ) ;
@ -1457,7 +1457,7 @@ void ImageView::updateZoomActions() {
if ( d - > mZoomMode = = ZOOM_FREE ) {
if ( d - > mZoomMode = = ZOOM_FREE ) {
d - > mZoomIn - > setEnabled ( d - > mZoom < MAX_ZOOM ) ;
d - > mZoomIn - > setEnabled ( d - > mZoom < MAX_ZOOM ) ;
d - > mZoomOut - > setEnabled ( d - > mZoom > 1 / MAX_ZOOM ) ;
d - > mZoomOut - > setEnabled ( d - > mZoom > 1 / MAX_ZOOM ) ;
TQString zoomText = TQString ( " %1% " ) . tq arg( int ( d - > mZoom * 100 ) ) ;
TQString zoomText = TQString ( " %1% " ) . arg( int ( d - > mZoom * 100 ) ) ;
d - > mZoomCombo - > setCurrentText ( zoomText ) ;
d - > mZoomCombo - > setCurrentText ( zoomText ) ;
} else {
} else {
d - > mZoomIn - > setEnabled ( true ) ;
d - > mZoomIn - > setEnabled ( true ) ;