Changeset 602 for trunk/Cocoa/Pester/Source/OACalendarView.m
- Timestamp:
- 12/21/09 22:12:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/OACalendarView.m
r601 r602 79 79 80 80 NSDateFormatter *monthAndYearFormatter; 81 int index;81 int dayOfWeek; 82 82 NSUserDefaults *defaults; 83 83 NSArray *shortWeekDays; … … 98 98 defaults = [NSUserDefaults standardUserDefaults]; 99 99 shortWeekDays = [defaults objectForKey:NSShortWeekDayNameArray]; 100 for ( index = 0; index < OACalendarViewNumDaysPerWeek; index++) {101 dayOfWeekCell[ index] = [[NSTableHeaderCell alloc] init];102 [dayOfWeekCell[ index] setAlignment:NSCenterTextAlignment];103 [dayOfWeekCell[ index] setStringValue:[[shortWeekDays objectAtIndex:index] substringToIndex:1]];100 for (dayOfWeek = 0; dayOfWeek < OACalendarViewNumDaysPerWeek; dayOfWeek++) { 101 dayOfWeekCell[dayOfWeek] = [[NSTableHeaderCell alloc] init]; 102 [dayOfWeekCell[dayOfWeek] setAlignment:NSCenterTextAlignment]; 103 [dayOfWeekCell[dayOfWeek] setStringValue:[[shortWeekDays objectAtIndex:dayOfWeek] substringToIndex:1]]; 104 104 } 105 105 … … 145 145 - (void)dealloc; 146 146 { 147 int index;147 int dayOfWeek; 148 148 149 149 [dayOfMonthCell release]; 150 150 151 for ( index = 0; index < OACalendarViewNumDaysPerWeek; index++)152 [dayOfWeekCell[ index] release];151 for (dayOfWeek = 0; dayOfWeek < OACalendarViewNumDaysPerWeek; dayOfWeek++) 152 [dayOfWeekCell[dayOfWeek] release]; 153 153 154 154 [monthAndYearTextFieldCell release]; … … 395 395 NSMutableArray *days; 396 396 NSCalendarDate *day; 397 int index;397 int dayOfWeek; 398 398 399 399 days = [NSMutableArray arrayWithCapacity:OACalendarViewNumDaysPerWeek]; 400 400 day = [selectedDay dateByAddingYears:0 months:0 days:-[selectedDay dayOfWeek] hours:0 minutes:0 seconds:0]; 401 for ( index = 0; index < OACalendarViewNumDaysPerWeek; index++) {401 for (dayOfWeek = 0; dayOfWeek < OACalendarViewNumDaysPerWeek; dayOfWeek++) { 402 402 NSCalendarDate *nextDay; 403 403 404 nextDay = [day dateByAddingYears:0 months:0 days: indexhours:0 minutes:0 seconds:0];404 nextDay = [day dateByAddingYears:0 months:0 days:dayOfWeek hours:0 minutes:0 seconds:0]; 405 405 if (flags.showsDaysForOtherMonths || [nextDay monthOfYear] == [selectedDay monthOfYear]) 406 406 [days addObject:nextDay]; … … 415 415 NSMutableArray *days; 416 416 NSCalendarDate *day; 417 int index;417 int dayOfWeek; 418 418 419 419 days = [NSMutableArray arrayWithCapacity:OACalendarViewMaxNumWeeksIntersectedByMonth]; 420 420 day = [selectedDay dateByAddingYears:0 months:0 days:-(([selectedDay weekOfMonth] - 1) * OACalendarViewNumDaysPerWeek) hours:0 minutes:0 seconds:0]; 421 for ( index = 0; index < OACalendarViewMaxNumWeeksIntersectedByMonth; index++) {421 for (dayOfWeek = 0; dayOfWeek < OACalendarViewMaxNumWeeksIntersectedByMonth; dayOfWeek++) { 422 422 NSCalendarDate *nextDay; 423 423 424 nextDay = [day dateByAddingYears:0 months:0 days:( index* OACalendarViewNumDaysPerWeek) hours:0 minutes:0 seconds:0];424 nextDay = [day dateByAddingYears:0 months:0 days:(dayOfWeek * OACalendarViewNumDaysPerWeek) hours:0 minutes:0 seconds:0]; 425 425 if (flags.showsDaysForOtherMonths || [nextDay monthOfYear] == [selectedDay monthOfYear]) 426 426 [days addObject:nextDay]; … … 648 648 int visibleMonthIndex; 649 649 NSCalendarDate *thisDay; 650 int index, row, column;650 int cellIndex, row, column; 651 651 NSSize cellSize; 652 652 BOOL isFirstResponder = ([[self window] firstResponder] == self); … … 663 663 thisDay = [visibleMonth dateByAddingYears:0 months:0 days:-[visibleMonth dayOfWeek] hours:0 minutes:0 seconds:0]; 664 664 665 for (row = column = index = 0; index < OACalendarViewMaxNumWeeksIntersectedByMonth * OACalendarViewNumDaysPerWeek; index++) {665 for (row = column = cellIndex = 0; cellIndex < OACalendarViewMaxNumWeeksIntersectedByMonth * OACalendarViewNumDaysPerWeek; cellIndex++) { 666 666 NSColor *textColor; 667 667 BOOL isVisibleMonth; … … 709 709 [[self target] calendarView:self willDisplayCell:dayOfMonthCell forDate:thisDay]; 710 710 } else { 711 if ((dayHighlightMask & (1 << index)) == 0) {711 if ((dayHighlightMask & (1 << cellIndex)) == 0) { 712 712 textColor = (isVisibleMonth ? [NSColor blackColor] : [NSColor grayColor]); 713 713 } else { … … 769 769 { 770 770 float maxWidth; 771 int index;771 int dayOfWeek; 772 772 773 773 maxWidth = 0; 774 for ( index = 0; index < OACalendarViewNumDaysPerWeek; index++) {774 for (dayOfWeek = 0; dayOfWeek < OACalendarViewNumDaysPerWeek; dayOfWeek++) { 775 775 NSSize cellSize; 776 776 777 cellSize = [dayOfWeekCell[ index] cellSize];777 cellSize = [dayOfWeekCell[dayOfWeek] cellSize]; 778 778 if (maxWidth < cellSize.width) 779 779 maxWidth = cellSize.width; … … 785 785 - (NSSize)_maximumDayOfMonthSize; 786 786 { 787 NSSize max Size;788 int index;789 790 max Size = NSZeroSize; // I'm sure the height doesn't change, but I need to know the height anyway.791 for ( index = 1; index <= 31; index++) {787 NSSize maximumSize; 788 int dayOfMonth; 789 790 maximumSize = NSZeroSize; // I'm sure the height doesn't change, but I need to know the height anyway. 791 for (dayOfMonth = 1; dayOfMonth <= 31; dayOfMonth++) { 792 792 NSString *str; 793 793 NSSize cellSize; 794 794 795 str = [NSString stringWithFormat:@"%d", index];795 str = [NSString stringWithFormat:@"%d", dayOfMonth]; 796 796 [dayOfMonthCell setStringValue:str]; 797 797 cellSize = [dayOfMonthCell cellSize]; 798 if (max Size.width < cellSize.width)799 max Size.width = cellSize.width;800 if (max Size.height < cellSize.height)801 max Size.height = cellSize.height;802 } 803 804 max Size.width = ceil(maxSize.width);805 max Size.height = ceil(maxSize.height);806 807 return max Size;798 if (maximumSize.width < cellSize.width) 799 maximumSize.width = cellSize.width; 800 if (maximumSize.height < cellSize.height) 801 maximumSize.height = cellSize.height; 802 } 803 804 maximumSize.width = ceilf(maximumSize.width); 805 maximumSize.height = ceilf(maximumSize.height); 806 807 return maximumSize; 808 808 } 809 809
Note:
See TracChangeset
for help on using the changeset viewer.