/* CardQuizController.m - card quiz controller class for Popup.app Copyright (C) 2003, 2004 Rob Burns December,13 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA. */ #include "CardQuizController.h" #include "Constants.h" @implementation CardQuizController -(void)dealloc { [super dealloc]; } - (void) awakeFromNib { [super awakeFromNib]; [correctButton setStringValue: _(@"Pass")]; [wrongButton setStringValue: _(@"Fail")]; [flipButton setStringValue: _(@"Flip")]; } - (void) displayCurrentCard: (id)sender; { RETAIN(correctButton); [correctButton removeFromSuperview]; RETAIN(wrongButton); [wrongButton removeFromSuperview]; [cardDisplay setBackgroundColor: [NSColor whiteColor]]; [cardDisplay setStringValue: [currentCard front]]; } - (NSString *) nibName { return @"CardQuiz"; } - (NSString *) quizName { return _(@"Flashcard"); } // ************** // Action Methods // ************** - (void) correctButtonPressed: (id)sender { [self setCardPassedAtIndex: [currentCard index]];; [progress incrementBy: 1]; [self drawNextCard: self]; } - (void) wrongButtonPressed: (id)sender { [self setCardFailedAtIndex: [currentCard index]]; if( [self quizMethod] == SHOWONCE_QUIZ_METHOD ) [progress incrementBy: 1]; [self drawNextCard: self]; } - (void) flipButtonPressed: (id)sender { [cardDisplay setBackgroundColor: [NSColor colorWithCalibratedRed: 1.0 green: 0.9686 blue: 0.6980 alpha: 1.0]]; [cardDisplay setStringValue: [currentCard back]]; [[[self window] contentView] addSubview: correctButton]; [[[self window] contentView] addSubview: wrongButton]; } @end