/* * Name: OgreTextFindThread.h * Project: OgreKit * * Creation Date: Sep 26 2003 * Author: Isao Sonobe * Copyright: Copyright (c) 2003 Isao Sonobe, All rights reserved. * License: OgreKit License * * Encoding: UTF8 * Tabsize: 4 */ #import #import #import //#import #import #import #import #import #import @protocol OgreTextFindProgressDelegate // show progress - (void)setProgress:(double)progression message:(NSString*)message; // progression < 0: indeterminate - (void)setDonePerTotalMessage:(NSString*)message; // finish - (void)done:(double)progression message:(NSString*)message; // progression < 0: indeterminate // close - (void)close:(id)sender; - (void)setReleaseWhenOKButtonClicked:(BOOL)shouldRelease; // cancel - (void)setCancelSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anObject; // show error alert - (void)showErrorAlert:(NSString*)title message:(NSString*)errorMessage; @end @class OgreTextFindRoot; @interface OgreTextFindThread : NSObject { /* implementors */ NSObject *_targetAdapter; OgreTextFindLeaf *_leafProcessing; NSEnumerator *_enumeratorProcessing; NSMutableArray *_enumeratorStack; NSMutableArray *_branchStack; OgreTextFindRoot *_rootAdapter; /* Parameters */ OGRegularExpression *_regex; // regular expression OGReplaceExpression *_repex; // replace expression NSColor *_highlightColor; // highlight color unsigned _searchOptions; // search option BOOL _inSelection; // find scope BOOL _asynchronous; // synchronous or asynchronous SEL _didEndSelector; // selector for sending a finish message id _didEndTarget; // target for sending a finish message NSObject *_progressDelegate; // progress checker volatile BOOL _shouldFinish; // finish flag /* state */ volatile BOOL _terminated; // two-phase termination BOOL _exceptionRaised; unsigned _numberOfMatches; // number of matches OgreTextFindResult *_textFindResult; // result int _numberOfDoneLeaves, _numberOfTotalLeaves; NSDate *_processTime; // process time NSDate *_metronome; // metronome } /* Creating and initializing */ - (id)initWithComponent:(NSObject *)aComponent; /* Running and stopping */ - (void)detach; - (void)terminate; - (void)terminate:(id)sender; - (void)finish; /* result */ - (OgreTextFindResult*)result; - (void)addResultLeaf:(id)aResultLeaf; - (void)beginGraftingToBranch:(OgreTextFindBranch*)aBranch; - (void)endGrafting; /* Configuration */ - (void)setRegularExpression:(OGRegularExpression*)regex; - (void)setReplaceExpression:(OGReplaceExpression*)repex; - (void)setHighlightColor:(NSColor*)highlightColor; - (void)setOptions:(unsigned)options; - (void)setInSelection:(BOOL)inSelection; - (void)setAsynchronous:(BOOL)asynchronou; - (void)setDidEndSelector:(SEL)aSelector toTarget:(id)aTarget; - (void)setProgressDelegate:(NSObject *)aDelegate; /* Accessors */ - (OGRegularExpression*)regularExpression; - (OGReplaceExpression*)replaceExpression; - (NSColor*)highlightColor; - (unsigned)options; - (BOOL)inSelection; - (NSObject *)progressDelegate; - (BOOL)isTerminated; - (NSTimeInterval)processTime; /* Protected methods */ - (unsigned)numberOfMatches; // number of matches - (void)incrementNumberOfMatches; // _numberofMatches++ - (void)finishingUp:(id)sender; - (void)exceptionRaised:(NSException*)exception; - (void)pushEnumerator:(NSEnumerator*)anEnumerator; - (NSEnumerator*)popEnumerator; - (NSEnumerator*)topEnumerator; - (OgreTextFindBranch*)rootAdapter; - (NSObject *)targetAdapter; - (void)pushBranch:(OgreTextFindBranch*)aBranch; - (OgreTextFindBranch*)popBranch; - (OgreTextFindBranch*)topBranch; - (void)_setLeafProcessing:(OgreTextFindLeaf*)aLeaf; /* Methods implemented by subclasses */ - (SEL)didEndSelectorForFindPanelController; - (void)willProcessFindingAll; - (void)willProcessFindingInBranch:(OgreTextFindBranch*)aBranch; - (void)willProcessFindingInLeaf:(OgreTextFindLeaf*)aLeaf; - (BOOL)shouldContinueFindingInLeaf:(OgreTextFindLeaf*)aLeaf; - (void)didProcessFindingInLeaf:(OgreTextFindLeaf*)aLeaf; - (void)didProcessFindingInBranch:(OgreTextFindBranch*)aBranch; - (void)didProcessFindingAll; - (void)finalizeFindingAll; - (NSString*)progressMessage; - (NSString*)doneMessage; - (double)progressPercentage; // percentage of completion - (double)donePercentage; // percentage of completion @end