home *** CD-ROM | disk | FTP | other *** search
- //************************************************************************
- //
- // ToolBar.m.
- //
- // ToolBar control object
- //
- // by Felipe A. Rodriguez
- //
- // This code is supplied "as is" the author makes no warranty as to its
- // suitability for any purpose. This code is free and may be distributed
- // in accordance with the terms of the:
- //
- // GNU GENERAL PUBLIC LICENSE
- // Version 2, June 1991
- // copyright (C) 1989, 1991 Free Software Foundation, Inc.
- // 675 Mass Ave, Cambridge, MA 02139, USA
- //
- //************************************************************************
-
-
- #import "GKdefs.h"
- #import "IconView.h"
- #import "ToolBar.h"
- #import "ToolBarView.h"
- #import "ToolIconView.h"
- #import "HLRecord.h"
- #import "HLDelegate.h"
- #import "Coordinator.h"
- #import <appkit/appkit.h>
- #import <dbkit/DBImageView.h>
-
- #import <sys/types.h>
- #import <sys/dir.h> /* POSIX applications #include <dirent.h> */
-
-
- @implementation ToolBar
-
- //************************************************************************
- //
- // sent to us after nib objects are unarchived and init'd
- //
- //************************************************************************
-
- - awakeFromNib
- {
- NXRect appIconFrame;
- NXRect lineViewRect;
- id appIcon;
-
- appTile = [NXImage findImageNamed: "NXAppTile"];
- appIcon = [NXApp appIcon]; // get appIcon window
- [appIcon getFrame:&appIconFrame]; // get appIcon frame rect
- [Window getContentRect:&lineViewRect // get content view rect appIco
- forFrameRect:&appIconFrame style:[appIcon style]];
- // reduce the size and width/ht by a border of 1
- NX_X(&lineViewRect) = 1;
- NX_Y(&lineViewRect) = 1;
- NX_WIDTH(&lineViewRect) -= 1 ;
- NX_HEIGHT(&lineViewRect) -= 1;
- // create tool view
- theToolView = [[ToolBarView alloc] initFrame:&lineViewRect];
- // create icon view
- toolIconView = [[ToolIconView alloc] initFrame:&lineViewRect];
- toolWin = [[Window allocFromZone:[self zone]] // create tool Win
- initContent:&appIconFrame
- style:NX_TOKENSTYLE
- backing:NX_BUFFERED
- // buttonMask:NX_CLOSEBUTTONMASK defer:NO];
- buttonMask:0 defer:NO];
- [toolWin setFreeWhenClosed:NO];
-
- if(![toolWin setFrameUsingName:"toolBar"])
- [toolWin moveTo:100.0 :100.0]; // initial pos of toolB
- [toolWin setFrameUsingName:"toolbar"]; // remember location
- [toolWin setFrameAutosaveName:"toolbar"]; // remember location
- [[toolWin setContentView:theToolView] free]; // replace cont w/toolV
- // add IB created backWindow's contentView
- [[toolWin contentView] addSubview:[backWindow contentView]];
- toolView = [toolWin setContentView:toolIconView];
- [toolWin setBackgroundGray:NX_BLACK];
- [[toolWin contentView] getFrame:&lineViewRect];
- [[toolWin contentView] convertRect:&lineViewRect toView:nil];
- [toolWin setTrackingRect:&lineViewRect // create mouse
- inside:YES // tracking rect
- owner:self
- tag:1500
- left:NO
- right:NO];
-
- nxAppDel = [NXApp delegate];
- hotListDelegate = [nxAppDel hotListDelegate];
- [hotListDelegate setToolBar:toolIconView];
- [toolWin orderFront:self];
- [toolWin display];
-
- return self;
- }
- //*****************************************************************************
- //
- // user pressed play button in toolbar
- //
- //*****************************************************************************
-
- - playLink:sender
- {
- [sender setState:0];
- [[NXApp delegate] Link:self];
-
- return self;
- }
- //*****************************************************************************
- //
- // user pressed stop button in toolbar
- //
- //*****************************************************************************
-
- - playUnlink:sender
- {
- [sender setState:0];
- if((strcmp([[[NXApp mainMenu] findCellWithTag:2] title],
- [[NXApp delegate] localString:"Disconnect"]) == 0) &&
- [[[NXApp mainMenu] findCellWithTag:2] isEnabled])
- [[NXApp delegate] UnLink:self]; // item enabled
-
- return self;
- }
- //*****************************************************************************
- //
- // go to next gate doc in hotList
- //
- //*****************************************************************************
-
- - nextItem:sender
- {
- return [hotListDelegate nextItem:sender];
- }
- //*****************************************************************************
- //
- // go to previous gate doc in hotList
- //
- //*****************************************************************************
-
- - prevItem:sender
- {
- return [hotListDelegate prevItem:sender];
- }
- //*****************************************************************************
- //
- // close toolbar
- //
- //*****************************************************************************
-
- - close:sender
- {
- if(!NXWriteDefault([NXApp appName], DISPLAYT, "NO"))
- [[NXApp delegate] showAlert:"ddbWriteError"];
- [sender setState:0];
- [toolWin close];
-
- return self;
- }
- //*****************************************************************************
- //
- // mouse has entered our tracking rect (window)
- //
- //*****************************************************************************
-
- - mouseEntered:(NXEvent *)theEvent
- {
- wasHidden = [NXApp isHidden]; // is the app hidden?
- [NXApp unhide:self];
- statusVisible = [[hotListDelegate statusWindow] isVisible];
- [toolWin setContentView:toolView];
- [toolWin display];
- [hotListDelegate loadBrowser]; // NXBrowser s/load cols from its delegate
- if([nxAppDel mailInQueue])
- iWasSet = 8;
- cursorOverToolBar = YES;
- if(iWasSet > 0)
- {
- [[nxAppDel appIconView] setMailFlag:YES];
- [self perform:@selector(mailInQueueIcon) with:self afterDelay:3000
- cancelPrevious:YES];
- }
- NXPing();
-
- return self;
- }
- //*****************************************************************************
- //
- // mouse has exited our tracking rect (window)
- //
- //*****************************************************************************
-
- - mouseExited:(NXEvent *)theEvent
- {
- [toolWin setContentView:toolIconView];
- [toolWin display];
-
- [[nxAppDel appIconView] setMailFlag:NO];
- // if status win was hidden prior to cursor in, hide
- if(!statusVisible && cursorOverToolBar)
- [[hotListDelegate statusWindow] close];
- if(wasHidden) // if app was hidden prior to cursor in, hide
- [NXApp hide:self];
- cursorOverToolBar = NO;
-
- return self;
- }
- - (BOOL)acceptsFirstMouse
- {
- return YES;
- }
- //*****************************************************************************
- //
- // clear mail in queue icon from app icon if mail has been sent
- //
- //*****************************************************************************
-
- - mailInQueueIcon
- {
- if(!((strcmp([[[NXApp mainMenu] findCellWithTag:2] title],
- [[NXApp delegate] localString:"Disconnect"]) == 0) &&
- [[[NXApp mainMenu] findCellWithTag:2] isEnabled]))
- iWasSet = 0;
- if(![nxAppDel mailInQueue])
- {
- iWasSet--;
- // if user mouseExited while mail icon set,
- // mouseEntered may occur during interim period
- // when mail is not shown in queue, but is
- if(iWasSet > 0 && cursorOverToolBar)
- [[nxAppDel appIconView] setMailFlag:YES];
- else
- [[nxAppDel appIconView] setMailFlag:NO];
- }
- else
- iWasSet = 8;
- if(iWasSet > 0)
- [self perform:@selector(mailInQueueIcon) with:self
- afterDelay:4000 cancelPrevious:YES];
-
- return self;
- }
- //*****************************************************************************
- //
- // forward anything in Greek to someone who might understand
- //
- //*****************************************************************************
-
- - forward:(SEL)aSelector :(marg_list)argFrame
- {
- if ( [toolWin respondsTo:aSelector] )
- return [toolWin performv:aSelector :argFrame];
-
- [self doesNotRecognize:aSelector]; // error abort process
-
- return self;
- }
- //************************************************************************
- //
- // free simply gets rid of everything we created
- // This is how nice objects clean up.
- //
- //************************************************************************
-
- - free
- {
- if(toolWin)
- [toolWin free];
- if(theToolView)
- [theToolView free];
- if(toolIconView)
- [toolIconView free];
-
- return [super free];
- }
-
- @end
-