mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-29 07:49:46 +00:00
1 line
17 KiB
C
1 line
17 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// SelectHouse.c
//----------------------------------------------------------------------------
//============================================================================
#include <Aliases.h>
#include <Resources.h>
#include <Sound.h>
#include <StringCompare.h>
#include "DialogUtils.h"
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "RectUtils.h"
#define kLoadHouseDialogID 1000
#define kDispFiles 12
#define kLoadTitlePictItem 3
#define kLoadNameFirstItem 5
#define kLoadNameLastItem 16
#define kLoadIconFirstItem 17
#define kLoadIconLastItem 28
#define kScrollUpItem 29
#define kScrollDownItem 30
#define kLoadTitlePict1 1001
#define kLoadTitlePict8 1002
#define kDefaultHousePict1 1003
#define kDefaultHousePict8 1004
#define kGrayedOutUpArrow 1052
#define kGrayedOutDownArrow 1053
#define kMaxExtraHouses 8
void UpdateLoadDialog (DialogPtr);
void PageUpHouses (DialogPtr);
void PageDownHouses (DialogPtr);
pascal Boolean LoadFilter (DialogPtr, EventRecord *, short *);
void SortHouseList (void);
void DoDirSearch (void);
Rect loadHouseRects[12];
FSSpecPtr theHousesSpecs;
FSSpec extraHouseSpecs[kMaxExtraHouses];
long lastWhenClick;
Point lastWhereClick;
short housesFound, thisHouseIndex, maxFiles, willMaxFiles;
short housePage, demoHouseIndex, numExtraHouses;
char fileFirstChar[12];
extern UInt32 doubleTime;
//============================================================== Functions
//-------------------------------------------------------------- UpdateLoadWindow
#ifndef COMPILEDEMO
void UpdateLoadDialog (DialogPtr theDialog)
{
Rect tempRect, dialogRect, dummyRect;
short houseStart, houseStop, i, wasResFile, isResFile, count;
// char wasState;
WindowRef theWindow;
// RgnHandle theRegion;
theWindow = GetDialogWindow(theDialog);
GetWindowBounds(theWindow, kWindowContentRgn, &dialogRect);
/*
wasState = HGetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn);
HLock((Handle)(((DialogPeek)theDialog)->window).port.visRgn);
dialogRect = (**((((DialogPeek)theDialog)->window).port.visRgn)).rgnBBox;
HSetState((Handle)(((DialogPeek)theDialog)->window).port.visRgn, wasState);
*/
DrawDialog(theDialog);
ColorFrameWHRect(8, 39, 413, 184, kRedOrangeColor8); // box around files
houseStart = housePage;
houseStop = housesFound;
if ((houseStop - houseStart) > kDispFiles)
houseStop = houseStart + kDispFiles;
wasResFile = CurResFile();
count = 0;
for (i = 0; i < 12; i++)
fileFirstChar[i] = 0x7F;
for (i = houseStart; i < houseStop; i++)
{
SpinCursor(1);
GetDialogItemRect(theDialog, kLoadIconFirstItem + i - housePage,
&tempRect);
if (SectRect(&dialogRect, &tempRect, &dummyRect))
{
isResFile = HOpenResFile(theHousesSpecs[i].vRefNum,
theHousesSpecs[i].parID, theHousesSpecs[i].name, fsRdPerm);
if (isResFile != -1)
{
if (Get1Resource('icl8', -16455) != nil)
{
LargeIconPlot(&tempRect, -16455);
}
else
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
kDefaultHousePict8);
CloseResFile(isResFile);
}
else
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
kDefaultHousePict8);
}
fileFirstChar[count] = theHousesSpecs[i].name[1];
if ((fileFirstChar[count] <= 0x7A) && (fileFirstChar[count] > 0x60))
fileFirstChar[count] -= 0x20;
count++;
DrawDialogUserText(theDialog, kLoadNameFirstItem + i - housePage,
theHousesSpecs[i].name, i == (thisHouseIndex + housePage));
}
InitCursor();
UseResFile(wasResFile);
}
#endif
//-------------------------------------------------------------- PageUpHouses
#ifndef COMPILEDEMO
void PageUpHouses (DialogPtr theDial)
{
Rect tempRect;
if (housePage < kDispFiles)
{
SysBeep(1);
return;
}
housePage -= kDispFiles;
thisHouseIndex = kDispFiles - 1;
ShowDialogItem(theDial, kScrollDownItem);
if (housePage < kD
|