home *** CD-ROM | disk | FTP | other *** search
- #include <Windows.h>
- #include "go.h"
- #include "display.h"
-
- #include "window.proto.h"
- #include "init.proto.h"
- #include "initdirs.proto.h"
- #include "initicons.proto.h"
- #include "misc.proto.h"
- #include "menu.proto.h"
- #include "view.proto.h"
- #include "mouse.proto.h"
-
- #include "windlist.h"
-
- void
- setwindowicons (CWindowPeek wp)
- {
- ControlHandle c;
- opendirinfo **infoh;
-
- infoh = (opendirinfo **) wp->refCon;
- for (c = wp->controlList; c != 0; c = (*c)->nextControl)
- {
- if (c != (*infoh)->sbar)
- {
- setoneicon (c);
- ShowControl (c);
- }
- }
- }
-
- int
- executor_p (void)
- {
- return *(long *) 0x5c != *(long *) 0x58;
- }
-
- static void
- make_at_least (short n, short *valp)
- {
- if (*valp < n)
- *valp = n;
- }
-
- #define FRAME_HEIGHT 20
-
- static void
- adjust_zoom_rect (CWindowPeek wp)
- {
- WStateDataHandle wh;
-
- wh = (WStateDataHandle) wp->dataHandle;
- make_at_least (HOTBANDBOTTOM + FRAME_HEIGHT + 2, &(*wh)->userState.top);
- make_at_least (HOTBANDBOTTOM + FRAME_HEIGHT + 2, &(*wh)->stdState.top);
- }
-
- static void
- watch_cursor (void)
- {
- static CursHandle watch_cursorh = 0;
-
- if (!watch_cursorh)
- watch_cursorh = GetCursor (watchCursor);
- SetCursor (*watch_cursorh);
- }
-
- static void
- arrow_cursor (void)
- {
- SetCursor (&arrow);
- }
-
- CWindowPtr
- createdirwindow (CInfoPBRec *dir, Rect *r, char **path, short volume)
- {
- CWindowPeek wp;
- short i;
- OSErr e;
- Str255 s;
- opendirinfo **infoh;
- ControlHandle c;
-
- watch_cursor ();
- if (executor_p ())
- {
- CInfoPBRec cpb;
- OSErr e2;
-
- cpb = *dir;
- e2 = unixmount (&cpb);
- if (e2 == noErr)
- volume = cpb.hFileInfo.ioVRefNum;
- }
- tail (*path, s);
- wp = (CWindowPeek) NewPtr (sizeof (CWindowRecord));
- wp = (CWindowPeek) NewCWindow (wp, r, s, false, documentProc+zoomDocProc, (WindowPtr) 0, true, 0);
- adjust_zoom_rect (wp);
- add_browser_window ((WindowPtr) wp);
- wp->refCon = (long) NewHandle (sizeof (opendirinfo));
-
- infoh = (opendirinfo **) wp->refCon;
- #if 1
- /* This handle should be unlocked later, but it isn't for Executor 1.99m */
- HLock ((Handle) infoh);
- #endif /* 0 */
- (*infoh)->sortorder = ALPHABETIC;
- (*infoh)->items = (ControlHandle (**)[])
- NewHandle (BANDARRAYSIZE * sizeof (ControlHandle));
- (*infoh)->path = path;
- (*infoh)->iodirid = dir->dirInfo.ioDrDirID;
- (*infoh)->vrefnum = volume;
- (*infoh)->numitems = 0;
- (*infoh)->view = ICONVIEW;
-
- /* NOTE: r is the wrong rectangle, but it gets fixed before it's used. */
- (*infoh)->sbar = NewControl ((WindowPtr) wp, r, (StringPtr) "\p", false, 0, 0, 0,
- scrollBarProc, 0);
- MoveControl ((*infoh)->sbar, wp->port.portRect.right - SCROLLBARWIDTH, 0);
-
- dir->hFileInfo.ioNamePtr = s;
- dir->hFileInfo.ioVRefNum = volume;
- e = noErr;
- for (i = 1; e == noErr; i++)
- {
- checkgrowitemarray (i, (*infoh)->items);
- dir->hFileInfo.ioDirID = (*infoh)->iodirid;
- dir->hFileInfo.ioFDirIndex = i;
- e = PBGetCatInfo (dir, false);
- if (e == noErr && !(dir->hFileInfo.ioFlFndrInfo.fdFlags & fInvisible))
- {
- c = addtolist ((WindowPeek) wp, s, dir->hFileInfo.ioFlParID, volume);
- if (dir->hFileInfo.ioFlFndrInfo.fdType == 'APPL' ||
- dir->hFileInfo.ioFlFndrInfo.fdType == 'dfil')
- hashicons (c);
- }
- }
- setwindowicons (wp);
- sortwin ((WindowPtr) wp, namecmp, ALPHABETIC);
- straightenwindow ((WindowPtr) wp);
- arrow_cursor ();
- return (CWindowPtr) wp;
- }
-
- void
- dodragwin (Point start, WindowPtr wp)
- {
- Rect r;
-
- SetRect (&r, 4, HOTBANDBOTTOM + 4 + start.v -
- (*((WindowPeek) wp)->strucRgn)->rgnBBox.top,
- qd.screenBits.bounds.right - 4, qd.screenBits.bounds.bottom - 4);
- DragWindow (wp, start, &r);
- }
-
- void
- dogrowwin (Point start, WindowPtr wp)
- {
- Rect r;
- long newsize;
-
- /* todo: find out what is normally done when there is no maximum size that needs to be enforced */
- SetRect (&r, ICONWIDTHUSED, 2 * ICONHEIGHTUSED, 32767, 32767);
- newsize = GrowWindow (wp, start, &r);
- SizeWindow (wp, LoWord (newsize), HiWord (newsize), true);
- InvalRect (&wp->portRect);
- straightenwindow (wp);
- }
-
- void
- disposedirwindow (WindowPtr wp)
- {
- SendBehind (g_hotband, (WindowPtr) 0);
- if ((**g_selection)[0] != 0 && (*(**g_selection)[0])->contrlOwner == wp)
- replaceselected((ControlHandle) 0);
- DisposHandle ((*(opendirinfo **) ((WindowPeek) wp)->refCon)->path);
- remove_browser_window (wp);
- DisposeWindow (wp);
- showviewmenu (FrontWindow () != g_hotband);
- }
-
- void
- dogoaway (Point start, WindowPtr wp)
- {
- if (TrackGoAway (wp, start))
- disposedirwindow (wp);
- }
-
- void
- do_zoom (short part, Point start, WindowPtr wp)
- {
- if (TrackBox (wp, start, part))
- {
- SetPort (wp);
- ZoomWindow (wp, part, TRUE);
- EraseRect (&wp->portRect);
- InvalRect (&wp->portRect);
- straightenwindow (wp);
- }
- }