mirror of
https://github.com/softdorothy/Pararena2.git
synced 2024-06-02 16:41:31 +00:00
1 line
32 KiB
C
1 line
32 KiB
C
|
#define USE_PICTS 1 /* 1 if PICTs are to be displayed, 0 for text only */
#define ONE_RESOURCE 0 /* 1 for Get1Resource, 0 for GetResource, etc. */
#define COMPRESSION 1 /* compressed TEXT/styl */
#define STANDALONE 0
#define CHECKPOINTS 0
#define ASSERTIONS 0
#if STANDALONE
#define Show_help main
#else
void main( void );
#endif
#include "Show_help.h"
/*
Show_help by James W. Walker, June 1991
version 1.6, updated March 1992
This code is freely usable. If you want to show your gratitude,
you could send me a free copy of whatever program you develop
with it.
e-mail:
Internet 76367.2271@compuserve.com
CIS 76367,2271
America Online JWWalker
This code displays scrolling text in a dialog box. The text comes
from TEXT/styl resources, which can be created with ResEdit 2.1 or
with an accompanying HyperCard stack.
The text cannot be edited, but one can select text and copy it to
the clipboard using command-C, or save it as a TeachText file.
Pictures can be included in the text using the same scheme as
TeachText: Each option-space character indicates where the top
edge of a picture should go, and pictures are centered horizontally.
Pictures come from consecutively-numbered PICT resources.
A popup menu can be used to jump to "bookmarks", which are indicated
by tab characters at ends of lines.
Prototype:
pascal void Show_help( short help_dlog_id, StringPtr help_text_name,
short base_pict_id, StringPtr default_filename,
StringPtr default_menuname );
help_dlog_id is the resource ID of the DLOG resource. The dialog
should have an OK button as item 1 and a userItem, to
display the text, in item 2.
help_text_name is the suffix of the resource name of the TEXT and
styl resources. For instance if help_text_name is
"\pblah", and COMPRESSION is 1, then Show_help will
look for '4CMP' resources named "TEXTblah" and "stylblah".
If COMPRESSION is 0, Show_help looks for a 'TEXT'
resource named "blah" and a 'styl' resource named "blah".
base_pict_id is the resource ID of the first PICT resource.
default_filename is the filename initially presented in the Save dialog
when the user saves the help text as TeachText.
default_menuname is the menu item used for a line that consists of
a tab and nothing else.
TO DO: error recovery, support for modeless use.
*/
#if __option(a4_globals)
#define RESTORE_A4 asm { move.L (SP)+, A4 }
#if __option(pcrel_strings) // single-segment code resource
#define SETUP_A4 asm { move.L A4, -(SP) }\
asm { LEA main, A4 }
#else // multi-segment code resource
#include <SetUpA4.h>
#define SETUP_A4 SetUpA4()
#endif
#else
#define SETUP_A4
#define RESTORE_A4
#endif
#ifndef NIL
#define NIL 0L
#endif
#if ONE_RESOURCE
#define GetResource Get1Resource
#define CountResources Count1Resources
#define GetNamedResource Get1NamedResource
#endif ONE_RESOURCE
#if ASSERTIONS
#define ASSERT(x,y) if (!(x)) {DebugStr("\p" y);}
#else
#define ASSERT(x,y)
#endif ASSERTIONS
#if CHECKPOINTS
#define CKPT(x) DebugStr( "\p" x )
#else
#define CKPT(x)
#endif CHECKPOINTS
enum {
c_OK = 1, /* OK button */
c_help, /* userItem for our help display */
c_save, /* Button to save as TeachText */
c_menu /* userItem for popup menu */
};
#define SCROLLBAR_WIDTH 16
#define TEXT_INSET 4
typedef struct {
Rect bounds;
PicHandle pict;
} pict_info;
typedef struct {
short array_size;
short high_waiting;
Rect high_rect[];
} high_info;
#define INITIAL_HIGHLIGHTS 8
typedef struct { // piggyback some other info on the dialog record
DialogRecord dialog;
ControlHandle scrollbar;
#if USE_PICTS
high_info **high;
short pict_count; /* how many pictures */
pict_info *pict_data; /* pointer to an array */
Boolean high_defer_flag;
#endif
} help_record, *help_ptr;
#if COMPRESSION
typedef struct {
ResType srcType;
Handle srcHandle;
ResType dstType;
Handle dstHandl
|