home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #include "DeskLib:WimpSWIs.h"
-
- #include "Shell.Array.h"
- #include "Shell.Extra.h"
- #include "Shell.SafeAlloc.h"
-
-
-
-
-
- #define COLUMN_WIDTH 8
-
-
-
-
-
- void Shell_DoubleArrayDrawer(
- Shell_convertpoint convert,
- wimp_point rectsize,
- void *reference,
- const wimp_rect *redrawrect
- )
- {
- wimp_rect rect = *redrawrect;
- double **data = (double **) reference;
- int i, j;
- char s[64];
-
- Shell_ConvertToSubTextRect2( &rect, rectsize);
- rect.min.x /= COLUMN_WIDTH;
- rect.max.x /= COLUMN_WIDTH;
-
-
- for ( i=rect.min.x; i<=rect.max.x; i++) {
- int x = i*COLUMN_WIDTH*Shell_TEXTXSIZE;
-
- for ( j=rect.min.y; j<=rect.max.y; j++) {
- sprintf( s, "%.2g", data[j][i]);
- /* Note the order. This is so that matrices are displayed with first */
- /* indice denoting the row, and the second denoting the column. */
- s[ COLUMN_WIDTH-1] = '\0';
- Shell_PrintString( s, x, rectsize.y - j*Shell_TEXTYSIZE, convert);
- }
-
- }
-
- return;
- }
-
-
-
-
- BOOL Shell_DoubleArraySaver( char *filename, Shell_rectblock *r)
- {
- double **data = (double **) r->reference;
- int x, y;
- FILE *f;
-
- f = fopen( filename, "w);
- if (!f) return FALSE;
-
- for ( y=0; y<info->info.size.y; y++) {
- for ( x=0; x<info->info.size.x; x++) {
- fprintf( f, info->fn( x, y, &info->info));
- fprintf( f, "\t");
- }
- fprintf( f, "\n");
- }
- return TRUE;
- }
-
-
-
-
-
- Shell_rectblock *Shell_Add2DDoubleArray(
- Shell_windblock *w, int x, int y, int xsize, int ysize,
- int forecol, int backcol, double **data
- )
- {
- Shell_rectblock *rectblock;
-
- rectblock = Shell_AddRectangle2(
- w,
- x, y - ysize*Shell_TEXTYSIZE,
- x + xsize * COLUMN_WIDTH * Shell_TEXTXSIZE, y,
- Shell_DoubleArrayDrawer,
- (void *) data
- );
-
-
- Shell_MakeRectIcon( rectblock, forecol, backcol, "r1");
-
- return rectblock;
- }
-
-
-