~ubuntu-branches/ubuntu/jaunty/preview.app/jaunty

« back to all changes in this revision

Viewing changes to Document.m

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2006-09-20 22:15:07 UTC
  • mfrom: (2.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060920221507-m97eitwwghgspz7p
Tags: 0.8.5-2
* Rebuild against latest libgnustep-gui-dev.
* Bump standards version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
        Document class & WindowController : This file is part of Preview 
5
5
 
6
6
        Copyright (C) 2003;2004 Fabien VALLON 
 
7
        2003,2004 Alcove ( http://www.alcove.com ) 
7
8
        Additional copyrights here
8
9
 
9
 
        Authors : Fabien VALLON <fabien.vallon@fr.alcove.com>
 
10
        Authors : Fabien VALLON <fabien@sonappart.net>
10
11
        Date:   10 Oct 2003
11
12
 
12
13
        This program is free software; you can redistribute it and/or
112
113
-(NSSize) _originalSize;
113
114
-(void) _setCurrentItem:(unsigned) tag;
114
115
-(unsigned) _currentItem;
115
 
- (void) _notifyDragScroll: (id)notification;
 
116
-(void) _notifyDragScroll: (id)notification;
 
117
-(void) _setIsAlpha:(BOOL) flag;
 
118
-(BOOL) _isAlpha;
116
119
@end
117
120
 
118
121
@implementation Document (Private)
129
132
      imageSize = [imageView frame].size;
130
133
      
131
134
      [imageView  setFrameSize:[affineTransform transformSize:imageSize]];
 
135
      if ( _isAlpha ) 
 
136
        {
 
137
          [checkeredView  setFrameSize:
 
138
                            [affineTransform transformSize:imageSize]];
 
139
        }
 
140
      
 
141
      [imageView setNeedsDisplay:YES];
 
142
 
132
143
    }
133
144
}
134
145
 
166
177
  return _tag;
167
178
}
168
179
 
169
 
 
170
180
- (void) _notifyDragScroll: (id)notification
171
181
{
172
182
   NSPoint  newOrigin;
189
199
}
190
200
 
191
201
 
 
202
-(void) _setIsAlpha:(BOOL) flag
 
203
{
 
204
  _isAlpha = flag;
 
205
}
 
206
 
 
207
-(BOOL) _isAlpha
 
208
{
 
209
  return _isAlpha;
 
210
}
 
211
 
 
212
 
192
213
 
193
214
@end
194
215
 
228
249
    return;
229
250
 
230
251
  {
231
 
    BOOL bigger = NO;;
 
252
    BOOL bigger = NO;
232
253
    NSSize imageSize = [_image size];
233
254
    NSSize contentSize;
234
255
    NSSize screenSize = [[NSScreen mainScreen] frame].size;
253
274
    
254
275
    if ( [[_image  bestRepresentationForDevice:nil]  hasAlpha] ) 
255
276
      {
256
 
        id view = [[CheckeredView alloc] initWithFrame: NSMakeRect(0,0,imageSize.width,imageSize.height)];
 
277
        [self _setIsAlpha: YES];
 
278
        checkeredView = [[CheckeredView alloc] initWithFrame: NSMakeRect(0,0,imageSize.width,imageSize.height)];
257
279
        [imageView retain];
258
 
        [scrollView setDocumentView: view];
259
 
        [view addSubview:imageView ];
 
280
        [scrollView setDocumentView: checkeredView];
 
281
        [checkeredView addSubview:imageView ];
 
282
      }
 
283
    else 
 
284
      {
 
285
        [self _setIsAlpha: NO];
260
286
      }
261
287
 
 
288
    
262
289
    [imageView setFrame:NSMakeRect(0,0,imageSize.width,imageSize.height)];
263
290
    [imageView setImage:_image];
264
 
 
265
 
    if ( bigger ) 
266
 
      [scrollView setDocumentCursor: [[NSCursor alloc] initWithImage: [NSImage imageNamed: @"hand"]
267
 
                                                       hotSpot: NSZeroPoint]];
 
291
    
 
292
    int test = [imageView addTrackingRect:[imageView bounds]
 
293
                          owner:imageView 
 
294
                          userData:nil
 
295
                          assumeInside:YES];
268
296
 
269
297
    [window setContentSize:contentSize];
270
298
    [window setFrameOrigin: NSMakePoint(100,120)];
275
303
                                          selector: @selector(_notifyDragScroll:)
276
304
                                          name: @"TEST"
277
305
                                          object: imageView];
 
306
 
 
307
    [[NSNotificationCenter defaultCenter] addObserver: self
 
308
                                          selector: @selector(_notifyMouseDown:)
 
309
                                          name: @"MOUSEDOWN"
 
310
                                          object: nil];
 
311
 
 
312
    [[NSNotificationCenter defaultCenter] addObserver: self
 
313
                                          selector: @selector(_notifyMouseUp:)
 
314
                                          name: @"MOUSEUP"
 
315
                                          object: nil];
 
316
 
278
317
  }
279
318
 
280
319
 
456
495
   case FIT_WINDOW:
457
496
     newSize.width = [scrollView contentSize].width;
458
497
     newSize.height = [scrollView contentSize].height;
459
 
     [[scrollView documentView] setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
460
 
      if ( [[_image  bestRepresentationForDevice:nil]  hasAlpha] ) 
461
 
        [imageView setAutoresizingMask: (NSViewWidthSizable|NSViewHeightSizable)];
462
 
 
 
498
     [imageView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
 
499
     if ( [self _isAlpha] ) 
 
500
        {
 
501
          NSLog(@"isAlpha");
 
502
          [checkeredView setAutoresizingMask: 
 
503
                           (NSViewWidthSizable|NSViewHeightSizable)];
 
504
        }
463
505
     break;
464
506
   case FIT_WIDTH:
465
507
      newSize.width = [scrollView contentSize].width;
466
508
      newSize.height = [imageView frame].size.height;
467
 
      [[scrollView documentView] setAutoresizingMask: (NSViewWidthSizable)];
468
 
      if ( [[_image  bestRepresentationForDevice:nil]  hasAlpha] ) 
469
 
          [imageView setAutoresizingMask: NSViewWidthSizable];
 
509
      [imageView setAutoresizingMask: (NSViewWidthSizable)];
 
510
      if ( [self _isAlpha] ) 
 
511
        [checkeredView setAutoresizingMask: NSViewWidthSizable];
470
512
      break; 
471
513
    default: 
472
514
      printf("problem resize default \n");
 
515
      return;
473
516
    }
474
517
 
475
 
  [[scrollView documentView] setFrame: NSMakeRect(0,0,newSize.width,newSize.height)];
476
 
  if ( [[_image  bestRepresentationForDevice:nil]  hasAlpha] ) 
477
 
    [imageView setFrame:NSMakeRect(0,0,newSize.width,newSize.height) ];
478
 
 
 
518
  //set autoresizing Mask
479
519
  if ( tag < FIT_WINDOW ) 
480
520
    {
481
 
      [[scrollView documentView] setAutoresizingMask: (NSViewNotSizable)];
482
 
      if ( [[_image  bestRepresentationForDevice:nil]  hasAlpha] ) 
483
 
        [imageView setAutoresizingMask: NSViewNotSizable];
484
 
    }
485
 
  
 
521
      if ( [self  _isAlpha] ) 
 
522
        [checkeredView setAutoresizingMask: NSViewNotSizable];
 
523
 
 
524
      [imageView setAutoresizingMask: NSViewNotSizable];
 
525
    }
 
526
 
 
527
  
 
528
  //Resize
 
529
  if ( [self _isAlpha] ) 
 
530
    {
 
531
      [checkeredView setFrame:NSMakeRect(0,0,newSize.width,newSize.height) ];
 
532
    }
 
533
  
 
534
  NSLog(@"apres newSize %@",NSStringFromSize(newSize));
 
535
 
 
536
  [imageView setFrame: NSMakeRect(0,0,newSize.width,newSize.height)];
 
537
    
 
538
  // why TODO FIXME !!! only need with FIT_WINDOW 
 
539
  [imageView setNeedsDisplay:YES];
 
540
  [checkeredView setNeedsDisplay:YES];
486
541
  [self _setCurrentItem: tag];
487
542
}
488
543