home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Shell_h
- #define __Shell_h
-
- #include <time.h>
- #include <stdio.h>
-
- #ifndef __dl_wimp_h
- #include "DeskLib:Wimp.h"
- #endif
-
- #ifndef __dl_coord_h
- #include "DeskLib:Coord.h"
- #endif
-
- #ifndef __dl_error_h
- #include "DeskLib:Error.h"
- #endif
-
- #ifndef __dl_linklist_h
- #include "DeskLib:LinkList.h"
- #endif
-
- #ifndef UNUSED
- #define UNUSED( x) (x) = (x)
- #endif
-
- #define Shell_MAXWINDS 4 /* Should convert the list of windows into a */
- /* linked list sometime. */
-
- #define Shell_TEXTXSIZE 16 /* width of a system-font character */
- #define Shell_TEXTYSIZE 32 /* height of a system-font character */
-
- #define Shell_PIXELXSIZE 2 /* This should depend on mode, but it */
- #define Shell_PIXELYSIZE 2 /* doesn't yet... */
-
- #define Shell_stringMAX 1023
- extern char Shell_string[ 1+Shell_stringMAX]; /* This is used in the Shell_*Printf( ...) */
- /* functions. */
-
-
-
-
- #define Shell_defaulttextrect NULL
- /* This is used to print text to a default output */
- /* window - when you first print text to this rectblock */
- /* Shell_ will open a window and define a textrect */
- /* automatically */
-
-
-
- typedef wimp_point Shell_convertpoint; /* The position of origin of a window in screen coors */
-
-
-
- typedef void (*Shell_redrawer)
- (
- Shell_convertpoint convert,
- wimp_point rectsize,
- void *reference,
- const wimp_rect *redrawrect
- );
-
- /* A fn which deals with a rectangle in a window. */
- /* rectsize is the size of the rectblock. */
- /* All redrawing should use convert, with (0,0) being */
- /* at the bottom-left of the rectblock. */
- /* redrawrect is relative to the rectblock. */
-
-
-
- typedef struct Shell_rectblock *Shell_rectblockptr;
-
- typedef BOOL (*Shell_saver)( char *filename, Shell_rectblockptr r);
- /* A fn which saves the data in a rectangle to */
- /* 'filename', using whatever format is most */
- /* appropriate for the rectangle's data. */
-
-
- typedef int (*Shell_ramsaver)(
- task_handle sourcetask,
- Shell_rectblockptr rect,
- task_handle desttask,
- void *destbuffer,
- unsigned int buffersize,
- int progress
- );
-
-
- typedef struct Shell_rectblock { /* Info for each rect registered in a window. */
- linklist_header header;
- window_handle window; /* Window handle of the window this rect is in. */
- icon_block icon;
- BOOL plot_icon; /* If set, Shell redraw fn will do a Wimp_PlotIcon. */
- wimp_rect rect; /* This is in work area coors. */
- clock_t last_update, /* Time this rect was last redrawn. */
- update_time; /* Minimum time between 'Slow' redraws. */
-
- Shell_redrawer redrawer; /* Fn to be called when this rect needs redrawing. */
- Shell_saver saver; /* Fn to be called to print rect to file. */
- Shell_ramsaver ramsaver; /* Fn to be called to ram-transfer a rect. */
- int filetype; /* Filetype to be used when saving this rect. */
- void *reference; /* Info to pass to redrawing fn. */
- }
- Shell_rectblock;
-
-
- typedef struct { /* Info for each window that */
- /* has been opened. */
- linklist_header anchor; /* Anchor of liked list of rectblocks. */
- window_handle window;
- int numrects;
- }
- Shell_windblock;
-
-
- extern int Shell_numwinds;
- extern Shell_windblock Shell_windows[ Shell_MAXWINDS];
-
-
-
-
-
- /* ********************** The Functions ***************************************** */
-
-
-
-
- #define Shell_ErrorReportFatal Error_ReportFatal
-
-
-
- void Shell_Init( char *progname, char *resourcedir);
- /* Inits DeskLib's Event_, Template_, Resource_, and loads */
- /* '<'resourcedir'$Dir>.Templates' using DeskLib's template */
- /* calls. This should contain the template 'ShellWindow'. */
-
-
- void Shell_Poll( void);
- /* Repeatedly calls Event_Poll until a null event is received. */
-
-
- extern BOOL Shell_paused;
- /* This can be changed anytime. Shell_Poll will check it, and if */
- /* Shell_paused==TRUE, will continue to call Wimp_Poll. */
-
- extern clock_t Shell_nextpolltime, Shell_pollinterval;
- /* Used by: */
-
- #define Shell_PollSlow() { \
- clock_t t = clock(); \
- if ( t > Shell_nextpolltime) { \
- Shell_nextpolltime = t + Shell_pollinterval; \
- Shell_Poll(); \
- } \
- }
- /* This is a macro that will call Shell_Poll() with minimum */
- /* interval Shell_pollinterval. */
- /* It should hopefuly waste very little time even if called */
- /* much more frequently than (Shell_pollinterval()^-1. */
-
-
- #define Shell_SetPollInterval( time) Shell_pollinterval = (clock_t) ( (time)*CLOCKS_PER_SEC)
- /* Sets the minimum interval between polls in Shell_PollSlow(). */
- /* 'time' should be in seconds. */
-
-
-
- #define Shell_OpenGFXWindow Shell_OpenWindow
- /* For compatibility with the original name. */
-
- Shell_windblock *Shell_OpenWindow( void);
- /* Opens a Shell window. You must have a window called 'ShellWindow' */
- /* in your application's 'Templates' file. */
-
-
-
-
- Shell_rectblock *Shell_AddRectangle(
- Shell_windblock *wind,
- const wimp_rect *rect,
- Shell_redrawer redrawfn,
- const void *reference
- );
-
- /* Adds a rectangle to a graphics window. You supply a */
- /* Shell_redrawer which is called whenever the rectangle */
- /* needs redrawing. */
-
- Shell_rectblock *Shell_AddRectangle2(
- Shell_windblock *wind,
- int xmin,
- int ymin,
- int xmax,
- int ymax,
- Shell_redrawer redrawfn,
- const void *reference
- );
-
- Shell_rectblock *Shell_AddRectangle3(
- Shell_windblock *wind,
- int xmin,
- int ymin,
- int xsize,
- int ysize,
- Shell_redrawer redrawfn,
- const void *reference
- );
-
- /* Same as above, except that the rectangle is specified by */
- /* four integers, rather than a (wimp_rect *). These integers */
- /* specify either the bottom-left and top-right points, or the */
- /* bottom left point, and the x and y size of the rectangle */
-
-
-
-
- void Shell_ForceRectRedraw( Shell_rectblock *rect);
- /* Makes this rectangle be redrawn at the next Wimp_Poll. */
- /* Use this if the data in the rectangle has changed. */
- /* This call just calls Wimp_ForceRedraw. */
-
- void Shell_ForceRectUpdate( Shell_rectblock *rect);
- /* As above, except the rectangle is not blanked, and the */
- /* redrawing is done imediately. Use this if the rectangle */
- /* involves animation. */
- /* This call uses Wimp_UpdateWindow */
-
- void Shell_ForceRectRedrawSlow( Shell_rectblock *rect);
- /* This calls Shell_ForceRectRedraw if the time since the */
- /* rectangle was last redrawn is greater than */
- /* rectnum->update_time. */
-
- #define Shell_SetRectUpdateTime( rect, time) \
- (rect)->update_time = (time_t) ( (time)*CLOCKS_PER_SEC) \
-
-
-
-
-
-
- void Shell_SetWindowTitle( window_handle window, char *text);
- /* This just calls Window_SetTitle. */
-
-
-
-
- void Shell_MakeRectIcon( Shell_rectblock *r, int forecol, int backcol, char *valid);
- /* Use this to make a rect automatically have a background */
- /* colour and a validation string to specify the border. */
- /* The string at 'valid' is strcpy-ed, so you can discard it */
- /* after this call. */
-
-
-
- #endif
-