home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
AESample.sit
/
AESample
/
sources
/
sample.subs.c
< prev
Wrap
Text File
|
1996-06-22
|
9KB
|
355 lines
/*
*--------------------------------------------------------------
* sample.subs.c
*--------------------------------------------------------------
*/
#include <Gestalt.h>
#include "sample.h"
#include "sample.subs.h"
#include "sample.dlog.h"
#include "sample.alrt.h"
#include "custom.wind.h"
/*
*--------------------------------------------------------------
* globals
*--------------------------------------------------------------
*/
Cursor gWaitCursor;
/*
*--------------------------------------------------------------
* GestaltChecks
*--------------------------------------------------------------
* this sample just checks System Version but
* you should check other materials whatever you need
*--------------------------------------------------------------
*/
Boolean GestaltChecks(void)
{
long gestaltAnswer;
OSErr result;
result = Gestalt(gestaltVersion, &gestaltAnswer);
if (result != noErr) {
return (false);
}
result = Gestalt(gestaltSystemVersion, &gestaltAnswer);
if ((result != noErr) || (gestaltAnswer < 0x0700)) {
return (false);
}
return (true);
}
/*
*--------------------------------------------------------------
* SetUpPreferences
*--------------------------------------------------------------
* load data from the preferences file or
* initialize preferences in here
*--------------------------------------------------------------
*/
Boolean SetUpPreferences(void)
{
/*
setup prefs here
*/
return (true);
}
/*
*--------------------------------------------------------------
* SetUpMyCursors
*--------------------------------------------------------------
* load cursor data in here
*--------------------------------------------------------------
*/
Boolean SetUpMyCursors(void)
{
gWaitCursor = **GetCursor(watchCursor);
SetCursor(&gWaitCursor);
return (true);
}
/*
*--------------------------------------------------------------
* SetUpMyWindows
*--------------------------------------------------------------
* setup windows
*--------------------------------------------------------------
*/
Boolean SetUpMyWindows(void)
{
if (!SetUpMyMainWindow()) return (false);
/*
setup other windows in here
*/
return (true);
}
/*
*--------------------------------------------------------------
* AdjustMyCursor
*--------------------------------------------------------------
* change cursor status according to current conditions
*--------------------------------------------------------------
*/
void AdjustMyCursor(void)
{
/*
this is just a CW.
implement such as TEIdle here
*/
if (gNowBackGround == false) {
InitCursor();
}
}
/*
*--------------------------------------------------------------
* DoUpdate
*--------------------------------------------------------------
* handle update event here
*--------------------------------------------------------------
*/
void DoUpdate(EventRecord *theEvent)
{
WindowRef aWindow = (WindowRef)theEvent->message;
if (aWindow != nil) {
BeginUpdate(aWindow);
/*
handle update event; draw window or so.
*/
if (aWindow == gMainWindow) {
DrawMyMainWindow();
}
EndUpdate(aWindow);
}
}
/*
*--------------------------------------------------------------
* DoActivate
*--------------------------------------------------------------
* handle activate event here
*--------------------------------------------------------------
*/
void DoActivate(EventRecord *theEvent)
{
WindowRef aWindow = (WindowRef)theEvent->message;
GrafPtr savePort;
GetPort(&savePort);
SetPortWindowPort(aWindow);
/*
handle activate event.
*/
SetPort(savePort);
}
/*
*--------------------------------------------------------------
* DoContent
*--------------------------------------------------------------
* handle window events here
*--------------------------------------------------------------
*/
void DoContent(WindowRef theWindow, Point where)
{
if (FrontWindow() != theWindow){
SelectWindow(theWindow);
} else {
if (theWindow == gMainWindow) {
DoMyMainWindow(where);
}
/*
handle other window events
*/
}
}
/*
*--------------------------------------------------------------
* DoGrow
*--------------------------------------------------------------
* handle grow window here
*--------------------------------------------------------------
*/
void DoGrow(WindowRef theWindow, Point where)
{
GrafPtr savedPort;
Rect maxRect, sizeLimits;
long newSize;
GetPort(&savedPort);
SetPortWindowPort(theWindow);
maxRect = (**GetGrayRgn()).rgnBBox;
sizeLimits.top = 128; /* minimum height */
sizeLimits.left = maxRect.bottom - maxRect.top; /* maximum height */
sizeLimits.bottom = 128; /* minimum width */
sizeLimits.right = maxRect.right - maxRect.left; /* maximum width */
newSize = GrowWindow(theWindow, where, &sizeLimits);
if (newSize != 0) {
short newHigh = HiWord(newSize);
short newWide = LoWord(newSize);
/*
adjust controls in the window
*/
}
SetPort(savedPort);
}
/*
*--------------------------------------------------------------
* DoDrag
*--------------------------------------------------------------
* handle grow window here
*--------------------------------------------------------------
*/
void DoDrag(WindowRef theWindow, Point where)
{
Rect maxRect;
maxRect = (**GetGrayRgn()).rgnBBox;
InsetRect(&maxRect, 8, 8); // have mergines
DragWindow(theWindow, where, &maxRect);
/*
remember window position if needed
*/
}
/*
*--------------------------------------------------------------
* DoGoAway
*--------------------------------------------------------------
* handle grow window here
*--------------------------------------------------------------
*/
void DoGoAway(WindowRef theWindow, Point where)
{
if (TrackGoAway(theWindow, where)) {
/*
hide or dispose the window
*/
if (theWindow == gMainWindow) gForever = false;
else
if (theWindow == gViewDialog) HideWindow(gViewDialog);
}
}
/*
*--------------------------------------------------------------
* DoZoom
*--------------------------------------------------------------
* handle zoom window here
*--------------------------------------------------------------
*/
void DoZoom(WindowRef theWindow, Point where, const short zoom)
{
if (TrackBox(theWindow, where, zoom)) {
if (theWindow == gMainWindow) {
ZoomMyMainWindow(zoom);
} else {
ZoomWindow(theWindow, zoom, false);
}
/*
adjust controls in the window
*/
}
}
/*
*--------------------------------------------------------------
* DoOSEvent
*--------------------------------------------------------------
* suspend and resule event handling
*--------------------------------------------------------------
*/
void DoOSEvent(EventRecord *theEvent)
{
short messageKind = (theEvent->message >> 24) & 0xff;
short messageFlag = theEvent->message & 0xff;
if (messageKind == suspendResumeMessage) {
if (messageFlag & resumeFlag) {
gNowBackGround = false;
if (messageFlag & convertClipboardFlag) {
DoConvertScrap(kClipboardToPrivate);
}
DoResume(theEvent);
} else {
gNowBackGround = true;
DoConvertScrap(kPrivateToClipboard);
DoSuspend(theEvent);
}
/* redraw dialog button frame */
if (IsWindowVisible(GetDialogWindow(gViewDialog))) {
FrameBoldButton(gViewDialog, ok);
}
}
}
/*
*--------------------------------------------------------------
* DoResume
*--------------------------------------------------------------
* handle resume event
*--------------------------------------------------------------
*/
void DoResume(EventRecord *theEvent)
{
#pragma unused (theEvent) /* remove this when you implement real handler */
}
/*
*--------------------------------------------------------------
* DoSuspend
*--------------------------------------------------------------
* handle suspend event
*--------------------------------------------------------------
*/
void DoSuspend(EventRecord *theEvent)
{
#pragma unused (theEvent) /* remove this when you implement real handler */
}
/*
*--------------------------------------------------------------
* DoConvertScrap
*--------------------------------------------------------------
* exchange data between private scrap and system scrap
*--------------------------------------------------------------
*/
void DoConvertScrap(Boolean toScrap)
{
if (toScrap == true) {
/*
copy local buffer to clipboard
*/
} else {
/*
copy clipboard to local buffer
*/
}
}
/*
*--------------------------------------------------------------
* DoMountDisk
*--------------------------------------------------------------
* disk mount check
*--------------------------------------------------------------
*/
void DoMountDisk(EventRecord *theEvent)
{
Point warnPos = {64, 64};
long diskMessage = theEvent->message;
if (HiWord(diskMessage) != noErr) {
DIBadMount(warnPos, diskMessage);
}
}
/*
*--------------------------------------------------------------
* SaveMyPreferences
*--------------------------------------------------------------
* save preference data to preference file
*--------------------------------------------------------------
*/
void SaveMyPreferences(void)
{
/*
store prefernces data in your preferences file
*/
}