This is DayWindow.m in view mode; [Download] [Up]
//
// DayWindow.m
// Copyright (c) 1991 by Jiro Nakamura
// All rights reserved
//
// by Jiro Nakamura (jiro@shaman.com)
//
// RCS Information
// Revision Number-> $Revision: 1.3 $
// Last Revised-> $Date: 91/02/17 22:03:21 $
//
static char rcsid[] = "$Id: WeekWindow.m,v 1.3 91/02/17 22:03:21 jiro Exp Locker: jiro $";
#import "Global.h"
#import "DayText.h"
#import "Event.h"
#import "cass.h" // for TODAYICON
#import "calendar.h" // for ascMyDate()
#import "Cassandra.h" // For NXApp
#import <appkit/ScrollView.h>
#import <appkit/TextField.h>
#import <appkit/PopUpList.h>
#import <appkit/Matrix.h>
#import "DayWindow.h"
#import <sys/file.h>
#import <libc.h>
#import <strings.h>
// The minimum dimensions of the day window
#define MIN_WIDTH 870.0
#define MIN_HEIGHT 100.0
@implementation DayWindow
- open:sender
{
static alreadyInited = FALSE;
NXRect tmpFrame;
if( !alreadyInited)
{
char dumbChar[5];
// dumb references to some static constants, just
// to avoid warning messages from the compiler (Garance)
dumbChar[1] = rcsid[0]; // dumb de dumb
alreadyInited = TRUE;
// [self placeWindow: [[NXApp global] dayFrame]];
today = *timeNow();
today.tm_hour = today.tm_min = today.tm_sec = 0;
fixTmStructure( &today);
#ifdef DEBUG
fprintf(stderr,"Today is: %s",
ascMyDate(&today));
#endif
priorityCutOff = [[NXApp global] lowPriority];
[self setDelegate: self];
[[eventsScroll docView] getFrame: &tmpFrame];
eventsText = [[DayText alloc] initFrame:
&tmpFrame];
[eventsScroll setDocView: eventsText];
[eventsText setMonoFont: FALSE];
[eventsText setEditable: YES];
[eventsText setBackgroundGray: NX_WHITE];
// [self setMiniwindowIcon: DAYICON];
viewPopUp = [PopUpList new];
[viewPopUp addItem: "View All"];
[viewPopUp addItem: "View Mid~High"];
[viewPopUp addItem: "View Only High"];
[[viewPopUp itemList] selectCellAt:1:0];
NXAttachPopUpList(viewPopUpButton, viewPopUp);
}
[self makeKeyAndOrderFront: self];
[self update]; // this will cause an update
return self;
}
- save
{
// This window shouldn't save itself.
return nil;
}
- close
{
// [[NXApp global] saveThisWindowPosition: DEFAULTDAYFRAME : self];
[super close];
miniaturized = FALSE;
return self;
}
- update
{
static char temp[20];
extern const char *shortMonths[12], *shortWeekDays[7];
if( miniaturized || ![self isVisible])
return self;
sprintf(temp, "%s %s %2d, %d",
shortWeekDays[today.tm_wday],
shortMonths[today.tm_mon],
today.tm_mday,today.tm_year + 1900);
[dayTextField setStringValue: temp];
[eventsText setDate: &today andPriority: priorityCutOff];
[eventsText updateText];
return self;
}
- dayBefore:sender
{
today.tm_mday -= 1;
[self update];
return self;
}
- dayAfter:sender
{
today.tm_mday += 1;
[self update];
return self;
}
- dayNow:sender
{
today = *timeNow();
today.tm_hour = today.tm_min = today.tm_sec = 0;
fixTmStructure( &today);
[self update];
return self;
}
- viewPopUpChanged:sender
{
switch( [[viewPopUp itemList] selectedRow])
{
case 2:
priorityCutOff = [[NXApp global] highPriority];
break;
case 1:
priorityCutOff = [[NXApp global] lowPriority];
break;
case 0:
default:
priorityCutOff = 0;
break;
}
#ifdef DEBUG
fprintf(stderr, "Priority changed to %d.... (tag = %d)\n",
priorityCutOff, [[viewPopUp itemList] selectedRow]);
#endif
[self update];
return self;
}
- windowDidMiniaturize: sender
{
#ifdef DEBUG
fprintf(stderr,"Today did miniaturize\n");
#endif
miniaturized = TRUE;
return self;
}
- windowDidDeminiaturize: sender
{
#ifdef DEBUG
fprintf(stderr,"Today did deminiaturize\n");
#endif
miniaturized = FALSE;
[self update];
return self;
}
- defaultsDidChange: sender
{
return [eventsText defaultsDidChange: sender];
}
- windowWillResize: (id) sender toSize: (NXSize *) size
{
#ifdef DEBUG
fprintf(stderr,"Window would have resized to %f x %f.\n",
size->width, size->height);
#endif
size->width = MIN_WIDTH; // can't change the width, ever
if( size->height < MIN_HEIGHT)
size->height = MIN_HEIGHT;
#ifdef DEBUG
fprintf(stderr,"Window will resize to %f x %f.\n",
size->width, size->height);
#endif
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.