home *** CD-ROM | disk | FTP | other *** search
- /*
-
- Starter.m
- Robby
- Sean Luke
- August 14, 1995
- MiscKit Example
-
- Permission to use, copy, modify, and distribute this material
- for any purpose and without fee, under the restrictions as noted
- in the MiscKit copyright notice, is hereby granted, provided that
- the MiscKit copyright notice and this permission notice
- appear in all source copies, and that the author's name shall not
- be used in advertising or publicity pertaining to this
- material without the specific, prior written permission
- of the author. SEAN O. LUKE MAKES NO REPRESENTATIONS ABOUT THE
- ACCURACY OR SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE.
- IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
-
- */
-
-
- #import "Starter.h"
- #import <misckit/MiscVolumeLight.h>
- #import <misckit/MiscTapper.h>
- #include <misckit/MiscAppIcon.h>
- //#include "MiscAppIcon.h"
- #include <stdio.h>
- #include <string.h>
-
- @implementation Starter
-
- /*
- Starter is the main object of Robby. It does four things, basically:
-
- 0) init sets up the MiscTapper
- 1) appDidInit sets up the MiscVolumeLight (which is in an off-screen window)
- 2) meterWillUpdateOnOwn is a delegate method of the MiscVolumeLight, which
- is called _before_ the MiscVolumeLight locks focus and redraws itself.
- This gives Starter a chance to spit a blank app tile in the background for
- the Volume Light to draw on top of. If you launch Robby from the
- Workspace, this isn't necessary since the Workspace owns the app icon
- and makes sure there's a nice background for it. But if you launch Robby
- from the Terminal (calling, say, Robby.app/Robby) then Robby owns the
- app icon and you have to draw the little beveled, shaded-gray look
- yourself. cleanTileToWindow: does this for you.
- 3) meterDidUpdate, another delegate method of MiscVolumeLight, tells Starter
- that the meter has finished drawing itself in the window. So Starter
- then procedes to splat the resultant window image onto the app icon by
- calling windowToAppIcon:.
-
- Modifications
- January 1993: Created original version of Robby
- August 14, 1995: Ported Robby to be a MiscKit example
-
- */
-
- - init
- {
- tapper=[[MiscTapper alloc] init];
- return [super init];
- }
-
-
- - appDidInit:sender
- {
- const NXDefaultsVector TheDefaults = {{"Output","YES"},{NULL,NULL}};
- NXRegisterDefaults ([NXApp appName], TheDefaults);
-
- if (!strcmp(NXGetDefaultValue ([NXApp appName],"Output"), "NO"))
- {
- [volume_light setToInput];
- [toggle_menu setTitle:"Listening"];
- [tapper run:self];
- output=NO;
- }
- else
- {
- [volume_light setToOutput];
- [toggle_menu setTitle:"Talking "];
- [tapper stop:self];
- output=YES;
- }
-
- [volume_light setBezeled:YES];
- [volume_light setDelegate:self];
-
- [volume_light run];
- return self;
- }
-
-
- - meterWillUpdateOnOwn:sender
- {
- return [NXApp cleanTileToWindow:hidden_window];
- // A MiscAppIcon category method
- }
-
-
- - meterDidUpdate:sender
- {
- return [NXApp windowToAppIcon:hidden_window];
- // A MiscAppIcon category method
- }
-
-
- - toggleInputOutput:sender
- {
- if (output)
- {
- [volume_light setToInput];
- [toggle_menu setTitle:"Listening"];
- [tapper run:self];
- output=NO;
- }
- else
- {
- [volume_light setToOutput];
- [toggle_menu setTitle:"Talking "];
- [tapper stop:self];
- output=YES;
- }
- NXWriteDefault([NXApp appName],
- "Output", output? "YES":"NO");
- return self;
- }
-
- - free
- {
- [tapper stop:self];
- [tapper free];
- return [super free];
- }
-
- @end
-