File: programming/cocoa/UKProgressPanel.zip/UKProgressPanel_02/UKProgressPanel/UKProgressPanelTask.m


/* =============================================================================
	POJECT:		UKProgressPanel
	FILE:		UKProgressPanelTask.m
	PURPOSE:	A single "task" (i.e. progress bar and status text field) for
				our MT-Newswatcher/Finder-style progress window for keeping the
				user current on concurrently running tasks.
	AUTHORS:	M. Uli Kusterer (UK), (c) 2003, all rights reserved.
	
	REQUIRES:	UKProgressPanelTask.h
				UKProgressPanelTask.nib
				UKProgressPanel.h
				UKProgressPanel.m
				(UKProgressPanel.nib)
				(UKProgressPanel.strings)
	
	NOTE:		UKProgressPanel and UKProgressPanelTask are thread-safe.
	
	DIRECTIONS:
			Using the progress panel is very simple: Use newProgressPanelTask
			and consorts to create a new task when you begin your lengthy
			operation, and release it when you have finished.
			
			The task will automatically take care of creating and showing the
			progress panel if needed, and will add itself to the shared
			progress panel instance.
			
			A task supports most of the methods of NSProgressIndicator to
			allow you to control the progress bar without any deep-reaching
			code changes. Use setTitle: to provide a general title indicating
			what action this is (e.g. "Emptying the trash"). The title will be
			displayed in bold above the progress bar. Use setStatus: to provide
			information about the step currently being executed, expected time
			to finish etc. - This will be displayed below the progress bar.
   ========================================================================== */
 
/* -----------------------------------------------------------------------------
	Headers:
   -------------------------------------------------------------------------- */
 
#import "UKProgressPanelTask.h"
#import "UKProgressPanel.h"
#import "UKMainThreadProxy.h"
#include <unistd.h>
 
 
/* -----------------------------------------------------------------------------
	Macros:
   -------------------------------------------------------------------------- */
 
#ifndef UK_DEBUG_PRINT
#define	UK_DEBUG_PRINT(a,b)		//NSLog((a),(b))
#endif
/* -----------------------------------------------------------------------------
	newProgressPanelTask:
		Convenience constructor for creating a task. This automatically adds
		the task to the shared progress panel, creating one if necessary.
		
		Caller is responsible for releasing the result of this.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	Constructor:
		Do not call this unless you really know what you're doing.
   -------------------------------------------------------------------------- */"NSOwner",
									topLevelObjects, @"NSTopLevelObjects"// We're responsible for releasing the top-level objects in the NIB (our view, right now).
"%@: Couldn't find NIB file \"%@\"."/* -----------------------------------------------------------------------------
	Destructor:
		Makes sure we no longer belong to our progress window.
   -------------------------------------------------------------------------- */"*** WARNING: UKProgressPanelTask got dealloced from another thread. Our release override should make that impossible?!""%lx: Waiting for removal of panel.""%lx: Panel removed.""%lx: Toplevel objects removed.""%lx: Lock removed.""%lx: got dealloced."/* -----------------------------------------------------------------------------
	Controlling the progress bar:
		These methods simply forward the messages to our progress bar.
   -------------------------------------------------------------------------- */"%lx: retrieving minValue""%lx: retrieving maxValue""%lx: Changing minValue""%lx: Changing maxValue""%lx: retrieving value""%lx: Changing value""%lx: incrementing value""%lx: retrieving isIndeterminate""%lx: Changing isIndeterminate of""%lx: animating"/* -----------------------------------------------------------------------------
	title/status:
   -------------------------------------------------------------------------- */"%lx: Changing title""%lx: Changing status"/* -----------------------------------------------------------------------------
	setStopDelegate:
		Use this to specify an object to be sent the stopAction (defaults to
		@selector(stop:)) when the user clicks the "Stop" button in this
		panel.
		
		This defaults to nil, meaning no notification will be sent.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	stopDelegate:
		Returns the delegate that will be notified of clicks in the "Stop"
		button.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	setStopAction:
		Use this to specify the message (defaults to @selector(stop:)) to be
		sent to the stopDelegate when the user clicks the "Stop" button in this
		panel. If you don't specify a stop delegate, the stop button will be
		disabled. (I'm not hiding it since that's too much work in Cocoa and
		I want to encourage writing abortable operations).
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	stopAction:
		The message (defaults to @selector(stop:)) to be sent to the
		stopDelegate when the user clicks the "Stop" button in this panel.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	stopped:
		Accessor for the flag that is set by our "stop:" action method when the
		user clicks the "Stop" button.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	stop:
		This method is called by the "Stop" button whenever it's been clicked.
		
		It does two things: It sets this object's "stopped" flag that you can
		check, and it sends the stopAction to the stopDelegate.
		
	REVISIONS:
		2004-10-17	UK	Changed this to send message to main thread and to
						pass "self" as the sender. The "stop" button isn't
						really interesting.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
	progressTaskView:
		Returns the view containing the title/status fields and progress bar
		for this task.
   -------------------------------------------------------------------------- */// Name of NIB file to use for our task:
#if UK_PROGRESS_PANEL_SAFARI_STYLE
"UKListProgressPanelTask";
	#else
"UKProgressPanelTask";
	#endif
 

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.