This is HipsView.m in view mode; [Download] [Up]
/* Copyright Notice: Copyright 1990 Robert C. Hood This software is distributed "as is" without warranty. Use this software at your OWN RISK. Source may be distributed freely, at NO CHARGE, but must be accompanied by this documentation and copyright notice. */ #include <stdio.h> #import "HipsImage.h" #import "HipsApp.h" #import "HipsView.h" /** ** ** IMPLEMENTATION SECTION ** **/ @implementation HipsView : View { } +new { self = [super new]; } -open: (char *)fileName file: (char *) file { char tstring[500]; double xpos, ypos; thisview = self; if ((fp = fopen (fileName, "rb")) == 0) { NXRunAlertPanel("HIPS ERROR","Can't open %s",NULL,NULL,NULL,fileName); [self free]; return self; } if ((hipsImage = [HipsImage getimagefromfile: fp]) == NULL) { NXRunAlertPanel("HIPS ERROR","Error reading image header",NULL,NULL,NULL); [self free]; return self; } xsize = [hipsImage getcols]; ysize = [hipsImage getrows]; xpos = 150.0; ypos = 800.0 - (double)ysize; NXSetRect(&temprect,xpos,ypos,(double)xsize,(double)ysize); thiswindow = [Window newContent: &temprect style: NX_TITLEDSTYLE backing: NX_RETAINED buttonMask: NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK | NX_RESIZEBUTTONMASK defer: NO ]; sprintf(tstring,"Image: %s",file); [thiswindow setTitle: tstring]; [thiswindow orderFront: nil]; [thiswindow display]; NXPing(); [[thiswindow setContentView: self] free]; [thiswindow display]; } -drawSelf: (const NXRect *)rects : (int)rectCount { [self getFrame: &temprect]; temprect.origin.x = 0.0; temprect.origin.y = 0.0; [self lockFocus]; NXImageBitmap(&temprect, // Rect xsize, // pixelsWide ysize, // pixelsWide [hipsImage getbits_per_pixel], // bps (bits per sample) 1, // spp (samples per pixel) NX_MESHED, // config NX_MONOTONICMASK, // mask [hipsImage getdata], // data1 NULL, // data2 NULL, // data3 NULL, // data4 NULL); // data5 [self unlockFocus]; return self; } -free { [hipsImage free]; [super free]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.