home *** CD-ROM | disk | FTP | other *** search
- #include <MacTypes.h>
- #include <QuickDraw.h>
- #include <WindowMgr.h>
- #include <ControlMgr.h>
- #include <DialogMgr.h>
- #include <EventMgr.h>
- #include <ToolboxUtil.h>
-
- #include "fix.h"
-
- #define WATCH_CURSOR 4
-
- /* Get an item handle from a dialog. */
-
- Handle get_item(the_dialog,item)
- DialogPtr the_dialog;
- int item;
- {
- Handle the_item;
- int type;
- Rect box;
-
- GetDItem(the_dialog, item, &type, &the_item, &box);
- return(the_item);
- }
-
- /* Set the cursor to the watch. */
-
- void set_watch_cursor()
- {
- SetCursor(*GetCursor(WATCH_CURSOR));
- }
-
- /* Set the cursor to the arrow. */
-
- void set_normal_cursor()
- {
- InitCursor();
- }
-
- /* Remove a resource from the current resource file. */
-
- #ifndef TEST_MODE
-
- void kill_resource(type, id)
- long type;
- int id;
- {
- register Handle hand;
-
- SetResLoad(0);
- hand = GetResource(type, id);
- if (HomeResFile(hand) == CurResFile()) {
- RmveResource(hand);
- DisposHandle(hand);
- }
- else
- ReleaseResource(hand);
- SetResLoad(1);
- }
- #endif TEST_MODE
-
- /* Copy a Pascal-style string */
-
- void copystr(dest, source)
- register unsigned char *dest, *source;
- {
- register int length;
-
- asm {
- clr.w length ; Need full word for length
- move.b (source),length ; Get length byte
- @0 move.b (source)+,(dest)+ ; Copy a byte of the string
- dbra length,@0 ; Keep going until all done
- }
- }
-
- /* Concatenate two Pascal-style strings into a third. */
-
- void concatstr(first, second, dest)
- register unsigned char *first, *second, *dest;
- {
- /* Copy the first string to the destination (unless the same). */
-
- if (first != dest)
- copystr(dest, first);
-
- /* If second string empty, just return. */
-
- if (second[0] == '\0')
- return;
-
- /* If destination empty, just copy second to it. */
-
- if (dest[0] == '\0') {
- copystr(dest, second);
- return;
- }
-
- /* Check that both strings will fit. */
-
- {
- register int l1, l2;
-
- l1 = (unsigned char) first[0];
- l2 = (unsigned char) second[0];
- if ((l1 + l2) > 255) /* doesn't fit! */
- return;
- }
-
- /* Copy the second string to the end of the destination. */
-
- {
- register int length, first_length;
-
- asm {
- clr.w first_length ; Get length of first string
- move.b (first),first_length ; (may also be destination)
- clr.w length ; Get length of second string
- move.b (second),length
- add.b length,(dest) ; Expand string to fit
- adda.w first_length,dest ; Advance pointer forward
- addq.w #1,dest ; Past length byte, too...
- addq.w #1,second ; Skip length byte
- subq.w #1,length ; Skip it again
- @0 move.b (second)+,(dest)+ ; Copy a byte
- dbra length, @0 ; Keep going until all done
- }
- }
- }
-
- /* Test two Pascal-style strings for equality */
-
- int equalstr(s1, s2)
- unsigned char *s1, *s2;
- {
- /* Could call IUEqualString if wanted. */
-
- return (EqualString(s1, s2, FALSE, TRUE));
- }
-