source: trunk/Cocoa/Pester/Source/PSTimeDateEditor.m@ 355

Last change on this file since 355 was 355, checked in by Nicholas Riley, 15 years ago

English.lproj/MainMenu.nib: Modernize menu and alarm set dialog
layout. Use keyed archiving (10.2+) nib format.

Info-Pester.plist: Moved from old PBX project.

NJRFSObjectSelector.m: Bug fixes from code sent to Joey: remove
incorrect usage of tryToPerform:with:; fix logic error in menu
construction. Work around Cocoa's deciding that the menu font size
needs adjustment when it doesn't - so the menu font size now matches
the button font size, though the position is still off. Don't pop up
a menu if we're disabled. Use IconRefs for menu icons, though not
(yet) for the button icon.

NJRHistoryTrackingComboBox.m: Remove item height adjustment
workaround; it now makes the items too tall.

NJRHotKey.m: Add a missing [super dealloc] caught by current GCC.

NJRHotKeyField.m: Add a missing [super dealloc] caught by current GCC.

NJRHotKeyManager.m: Add a missing [super dealloc] caught by current

NJRIntervalField.m: Fix some type errors.

NJRQTMediaPopUpButton.m: Replace SoundFileManager SPI usage, which
doesn't work in Leopard anyway, with manual enumeration of system
sounds. Start migration to QTKit. Use IconRefs for menu icons.

NJRReadMeController.m: Change source encoding to UTF-8.

NJRSoundManager.m: Fix a type error.

NJRVoicePopUpButton.m: Change source encoding to UTF-8.

NSMenuItem-NJRExtensions.[hm]: Code from ICeCoffEE to use IconRefs for
menu item icons.

PSAlarm.m: Change source encoding to UTF-8.

PSAlarms.m: Fix a signedness mismatch.

PSAlarmsController.m: Change source encoding to UTF-8.

PSAlarmSetController.m: Set keyboard focus after unchecking "Do
script:" and "Play" checkboxes.

PSAlerts.m: Add a missing [super dealloc] caught by current GCC. Fix
a memory leak in property list serialization.

PSPowerManager.[hm]: There's now API for scheduling wakeups; use it
(the old code asserted on startup). To fix: removing scheduled
wakeup. Fix a small type-checking error.

PSPreferencesController.m: Add a missing [super dealloc] caught by
current GCC.

PSScriptAlert.m: Change source encoding to UTF-8.

PSTimeDateEditor.m: Fix a tiny, and one-time, memory leak.

PSTimer.m: Update for new PSPowerManager API.

Pester.pbproj: Deleted; now supporting OS X 10.4+ (up from 10.1,

Pester.xcodeproj: Xcode 2.4+ project, upgraded targets, etc.

SoundFileManager.h: Deleted; this SPI no longer exists in Leopard and
possibly earlier.

File size: 2.0 KB
2// PSTimeDateEditor.m
3// Pester
5// Created by Nicholas Riley on Sun Feb 16 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
9#import "PSTimeDateEditor.h"
10#import "NJRDateFormatter.h"
12@implementation PSTimeDateEditor
14+ (void)setUpTimeField:(NSTextField *)timeOfDay dateField:(NSTextField *)timeDate completions:(NSPopUpButton *)timeDateCompletions;
16 static NJRDateFormatter *timeFormatter = nil, *dateFormatter = nil;
17 if (timeFormatter == nil) {
18 timeFormatter = [[NJRDateFormatter alloc] initWithDateFormat: [NJRDateFormatter localizedTimeFormatIncludingSeconds: NO] allowNaturalLanguage: YES];
19 dateFormatter = [[NJRDateFormatter alloc] initWithDateFormat: [NJRDateFormatter localizedDateFormatIncludingWeekday: NO] allowNaturalLanguage: YES];
20 }
21 [timeOfDay setFormatter: timeFormatter];
22 [timeDate setFormatter: dateFormatter];
23 [timeDate setObjectValue: [NSDate date]];
25 // add completions
26 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
27 NSArray *dayNames = [defaults arrayForKey: NSWeekDayNameArray];
28 NSArray *completions = [timeDateCompletions itemTitles];
29 NSEnumerator *e = [completions objectEnumerator];
30 NSString *title;
31 int itemIndex = 0;
32 NSRange matchingRange;
33 while ( (title = [e nextObject]) != nil) {
34 matchingRange = [title rangeOfString: @"«day»"];
35 if (matchingRange.location != NSNotFound) {
36 NSMutableString *format = [title mutableCopy];
37 NSEnumerator *we = [dayNames objectEnumerator];
38 NSString *dayName;
39 [format deleteCharactersInRange: matchingRange];
40 [format insertString: @"%@" atIndex: matchingRange.location];
41 [timeDateCompletions removeItemAtIndex: itemIndex];
42 while ( (dayName = [we nextObject]) != nil) {
43 [timeDateCompletions insertItemWithTitle: [NSString stringWithFormat: format, dayName] atIndex: itemIndex];
44 itemIndex++;
45 }
46 [format release];
47 } else itemIndex++;
48 }
Note: See TracBrowser for help on using the repository browser.