source: trunk/Cocoa/Pester/Source/PSCalendarController.m @ 516

Last change on this file since 516 was 133, checked in by Nicholas Riley, 18 years ago

VERSION: Updated for 1.1b4.

PSMovieAlertController.[hm]: Set output volume from alert; save and
restore output volume (bug 27).

PSBeepAlert.[hm]: Save and set volume, disabled pending a
synchronous equivalent to NSBeep().

NJRQTMediaPopUpButton.[hm]: Save movieHasAudio (does not include
beeps, pending the above fix, since they don't permit volume
adjustment). savedVolume indicates whether the volume has been saved
but not restored yet; outputVolume stores the set volume (eventually
incorporated into a PSMediaAlert).

PSMediaAlert.[hm]: Stores repetitions and volume information for audio
alerts. New superclass of PSBeepAlert and PSMovieAlert.

PSPreferencesController.m: Fixed bug where hot keys still appeared
even after they couldn't be set - last of bug 29. Add Command-comma
to the list of disallowed equivalents, as it's reserved for
Preferences now (still a bug - it'll show the entire set key
equivalent at the left side of the window when you press
command-comma; ah well.)

Volume [0123].png: Volume-indicating small icons from QuickTime? 6.

NJRSoundManager.[hm]: Interface to volume saving, restoring, setting -
necessary because the QuickTime? call to SetDefaultOutputVolume? sets
the right channel volume only (bug 27).

PSVolumeController.h: Controller for volume popup window (bug 27).
Not your average NSWindowController, but it works. Keyboard control
of volume is still necessary; filed as bug 31.

PSAlarmSetController.[hm]: Added references to sound volume button and
showVolume: action. Added volume setting support (bug 27); mostly
similar interface to calendar, though we need direct calls to
NJRSoundManager to restore sound volume at times. Only enable sound
volume button if selected media file has audio component (and isn't the
system alert sound, which I discussed above). Take advantage of
PSMediaAlert to factor some code in _readAlerts:. Save and restore
volume as part of alerts.

Read Me.rtfd: Updated release notes; fixed some bizarre text
formatting problems; search/replace "* " bullet-space with "*\t"
bullet-tab to improve alignment in release notes.

PSMovieAlert.[hm]: Factored code into PSMediaAlert. Describe output
volume as percentage of maximum.

NJRHotKey.m: Fixed some odd spacing left over from Ecky's code.

PSApplication.m: Restore saved output volume on quit.

English.lproj/MainMenu.nib: Added volume button.

English.lproj/Volume.nib: Volume nib (bug 27).

PSCalendarController.m: Removed casts from a copy/paste error. Fixed
variable names in some code inherited from my TextExtras? incremental
search modifications - it's not always a text field now.

File size: 3.5 KB
Line 
1//
2//  PSCalendarController.m
3//  Pester
4//
5//  Created by Nicholas Riley on Fri Feb 14 2003.
6//  Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "PSCalendarController.h"
10#import "OACalendarView.h"
11#import "NSCalendarDate-OFExtensions.h"
12#import "NSCalendarDate-NJRExtensions.h"
13
14@implementation PSCalendarController
15
16+ (PSCalendarController *)controllerWithDate:(NSCalendarDate *)aDate delegate:(id)aDelegate;
17{
18    return [[self alloc] initWithDate: aDate delegate: aDelegate];
19}
20
21- (id)initWithDate:(NSCalendarDate *)aDate delegate:(id)aDelegate;
22{
23    if ([self initWithWindowNibName: @"Calendar"]) {
24        NSWindow *window = [self window]; // connect outlets
25        [calendarView setTarget: self]; // delegate
26        [calendarView setSelectionType: OACalendarViewSelectByDay];
27        [calendarView setShowsDaysForOtherMonths: YES];
28        if (aDate == nil) aDate = [NSCalendarDate calendarDate];
29        [calendarView setSelectedDay: aDate];
30        [calendarView setVisibleMonth: aDate];
31        delegate = [aDelegate retain];
32
33        NSView *view = [aDelegate calendarControllerLaunchingView: self];
34        if (view != nil) {
35            NSRect rect = [view convertRect: [view bounds] toView: nil];
36            NSWindow *parentWindow = [view window];
37            rect.origin = [parentWindow convertBaseToScreen: rect.origin];
38            rect.origin.x -= [window frame].size.width - rect.size.width;
39            [window setFrameTopLeftPoint: rect.origin];
40            NSRect visibleFrame = [[parentWindow screen] visibleFrame];
41            if (!NSContainsRect(visibleFrame, [window frame])) {
42                NSPoint viewTopLeft = { rect.origin.x, rect.origin.y + rect.size.height };
43                [window setFrameOrigin: viewTopLeft];
44            }
45        }
46       
47        [window setOpaque: NO];
48        [window setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.81f alpha: 0.9f]];
49        [window setHasShadow: NO];
50        [window setLevel: NSModalPanelWindowLevel];
51        [NSApp runModalForWindow: window];
52    }
53    return self;
54}
55
56- (void)dealloc;
57{
58    [delegate release];
59    [super dealloc];
60}
61
62- (IBAction)close:(NSButton *)sender;
63{
64    [NSApp stopModal];
65    [delegate calendarController: self didSetDate: [calendarView selectedDay]];
66    [self close];
67}
68
69- (IBAction)cancel:(NSButton *)sender;
70{
71    [NSApp stopModal];
72    [self close];
73}
74
75- (IBAction)today:(NSButton *)sender;
76{
77    NSCalendarDate *today = [NSCalendarDate calendarDate];
78    [calendarView setSelectedDay: today];
79    [calendarView setVisibleMonth: today];
80}
81
82@end
83
84@implementation PSCalendarController (OACalendarViewDelegate)
85
86- (BOOL)calendarView:(OACalendarView *)aCalendarView shouldSelectDate:(NSCalendarDate *)aDate;
87{
88    return ([[NSCalendarDate dateForDay: aDate] compare: [NSCalendarDate dateForDay: [NSCalendarDate calendarDate]]] != NSOrderedAscending);
89}
90
91- (int)calendarView:(OACalendarView *)aCalendarView highlightMaskForVisibleMonth:(NSCalendarDate *)visibleMonth;
92{
93    NSCalendarDate *today = [NSCalendarDate calendarDate];
94    if ([visibleMonth yearOfCommonEra] == [today yearOfCommonEra] && [visibleMonth monthOfYear] == [today monthOfYear]) {
95        return 1 << ([today dayOfMonth] - 1 + [[today firstDayOfMonth] dayOfWeek]);
96    }
97
98    return 0;
99}
100
101- (void)calendarViewShouldDismiss:(OACalendarView *)aCalendarView;
102{
103    [okButton performClick: aCalendarView];
104}
105
106@end
107
108@implementation PSCalendarController (NSWindowNotifications)
109
110- (void)windowWillClose:(NSNotification *)notification;
111{
112    [self autorelease];
113}
114
115@end
Note: See TracBrowser for help on using the repository browser.