The R Project SVN R

Rev

Rev 9095 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9095 Rev 9124
Line 300... Line 300...
300
    
300
    
301
    clearwindow();
301
    clearwindow();
302
 
302
 
303
    gfillrect(de, bbg, rect(0, 0, windowWidth, box_h));
303
    gfillrect(de, bbg, rect(0, 0, windowWidth, box_h));
304
    gfillrect(de, bbg, rect(0, 0, boxw[0], windowHeight));
304
    gfillrect(de, bbg, rect(0, 0, boxw[0], windowHeight));
305
 
305
    
306
    for (i = 1; i < nhigh; i++)
306
    for (i = 1; i < nhigh; i++)
307
	drawrectangle(0, hwidth + i * box_h, boxw[0], box_h, 1, 1);
307
	drawrectangle(0, hwidth + i * box_h, boxw[0], box_h, 1, 1);
308
     /* so row 0 and col 0 are reserved for labels */
308
     /* so row 0 and col 0 are reserved for labels */
309
    colmax = colmin + (nwide - 2);
309
    colmax = colmin + (nwide - 2);
310
    rowmax = rowmin + (nhigh - 2);
310
    rowmax = rowmin + (nhigh - 2);
Line 312... Line 312...
312
    if (inputlist != R_NilValue)
312
    if (inputlist != R_NilValue)
313
	for (i = colmin; i <= colmax; i++) drawcol(i);
313
	for (i = colmin; i <= colmax; i++) drawcol(i);
314
    /* row/col 1 = pos 0 */
314
    /* row/col 1 = pos 0 */
315
    gchangescrollbar(de, VWINSB, rowmin-1, ymaxused, nhigh, 0);
315
    gchangescrollbar(de, VWINSB, rowmin-1, ymaxused, nhigh, 0);
316
    gchangescrollbar(de, HWINSB, colmin-1, xmaxused, nwide, 0);
316
    gchangescrollbar(de, HWINSB, colmin-1, xmaxused, nwide, 0);
317
/*    Rprintf("rowmin %d colmin %d nwide %d nhigh %d xmax %d ymax %d\n", 
-
 
318
      rowmin, colmin, nwide, nhigh, xmaxused, ymaxused);*/
-
 
319
    highlightrect();
317
    highlightrect();
320
    show(de);
-
 
321
}
318
}
322
 
319
 
323
void doHscroll(int oldcol)
320
void doHscroll(int oldcol)
324
{
321
{
325
    int i, w, dw;
322
    int i, w, dw;
Line 353... Line 350...
353
	cleararea(dw, hwidth, WIDTH-dw, HEIGHT, p->bg);
350
	cleararea(dw, hwidth, WIDTH-dw, HEIGHT, p->bg);
354
	drawcol(colmin);
351
	drawcol(colmin);
355
    }
352
    }
356
    gchangescrollbar(de, HWINSB, colmin-1, xmaxused, nwide, 0);
353
    gchangescrollbar(de, HWINSB, colmin-1, xmaxused, nwide, 0);
357
    highlightrect();
354
    highlightrect();
358
    show(de);
-
 
359
}
355
}
360
 
356
 
361
/* find_coords finds the coordinates of the upper left corner of the
357
/* find_coords finds the coordinates of the upper left corner of the
362
   given cell on the screen: row and col are on-screen coords */
358
   given cell on the screen: row and col are on-screen coords */
363
 
359
 
Line 515... Line 511...
515
	    len = min(rowmax, LEVELS(CAR(tmp)) );
511
	    len = min(rowmax, LEVELS(CAR(tmp)) );
516
	    for (i = (rowmin - 1); i < len; i++)
512
	    for (i = (rowmin - 1); i < len; i++)
517
		printelt(CAR(tmp), i, i - rowmin + 2, col);
513
		printelt(CAR(tmp), i, i - rowmin + 2, col);
518
	}
514
	}
519
    }
515
    }
520
    show(de);
-
 
521
}
516
}
522
 
517
 
523
 
518
 
524
/* whichrow is absolute row no */
519
/* whichrow is absolute row no */
525
void drawrow(int whichrow)
520
void drawrow(int whichrow)
Line 547... Line 542...
547
	tvec = CAR(nthcdr(inputlist, i - 1));
542
	tvec = CAR(nthcdr(inputlist, i - 1));
548
	if (tvec != R_NilValue)
543
	if (tvec != R_NilValue)
549
	    if (whichrow <= (int)LEVELS(tvec))
544
	    if (whichrow <= (int)LEVELS(tvec))
550
	    printelt(tvec, whichrow - 1, row, i - colmin + 1);
545
	    printelt(tvec, whichrow - 1, row, i - colmin + 1);
551
    }
546
    }
552
    show(de);
-
 
553
}
547
}
554
 
548
 
555
 
549
 
556
/* printelt: print the correct value from vector[vrow] into the
550
/* printelt: print the correct value from vector[vrow] into the
557
   spreadsheet in row ssrow and col sscol */
551
   spreadsheet in row ssrow and col sscol */
Line 596... Line 590...
596
		(i = rowmin + whichrow - 2) < (int)LEVELS(CAR(tmp)) )
590
		(i = rowmin + whichrow - 2) < (int)LEVELS(CAR(tmp)) )
597
		printelt(CAR(tmp), i, whichrow, whichcol);
591
		printelt(CAR(tmp), i, whichrow, whichcol);
598
	} else
592
	} else
599
	printstring("", 0, whichrow,  whichcol, 0);
593
	printstring("", 0, whichrow,  whichcol, 0);
600
    }
594
    }
601
    show(de);
-
 
602
}
595
}
603
 
596
 
604
void jumppage(int dir)
597
void jumppage(int dir)
605
{
598
{
606
    int i, w, oldcol, wcol;
599
    int i, w, oldcol, wcol;
Line 648... Line 641...
648
    int x, y;
641
    int x, y;
649
    find_coords(crow, ccol, &x, &y);
642
    find_coords(crow, ccol, &x, &y);
650
    drawrectangle(x + lwd - 1, y + lwd -1,
643
    drawrectangle(x + lwd - 1, y + lwd -1,
651
		  BOXW(ccol+colmin-1) - lwd + 1,
644
		  BOXW(ccol+colmin-1) - lwd + 1,
652
		  box_h - lwd + 1, lwd, fore);
645
		  box_h - lwd + 1, lwd, fore);
653
    show(de);
-
 
654
}
646
}
655
 
647
 
656
void downlightrect()
648
void downlightrect()
657
{
649
{
658
    printrect(2, 0);
650
    printrect(2, 0);
Line 800... Line 792...
800
	    *(pc + fw - 1) = '>';
792
	    *(pc + fw - 1) = '>';
801
	    *(pc + fw) = '\0';
793
	    *(pc + fw) = '\0';
802
	}
794
	}
803
    }
795
    }
804
    de_drawtext(x_pos + text_xoffset, y_pos - text_yoffset, pc);
796
    de_drawtext(x_pos + text_xoffset, y_pos - text_yoffset, pc);
805
    show(de);
-
 
806
}
797
}
807
 
798
 
808
void clearrect()
799
void clearrect()
809
{
800
{
810
    int x_pos, y_pos;
801
    int x_pos, y_pos;
811
    find_coords(crow, ccol, &x_pos, &y_pos);
802
    find_coords(crow, ccol, &x_pos, &y_pos);
812
    cleararea(x_pos, y_pos, BOXW(ccol+colmin-1), box_h, p->bg);
803
    cleararea(x_pos, y_pos, BOXW(ccol+colmin-1), box_h, p->bg);
813
    show(de);
-
 
814
}
804
}
815
 
805
 
816
/* handlechar has to be able to parse decimal numbers and strings,
806
/* handlechar has to be able to parse decimal numbers and strings,
817
   depending on the current column type, only printing characters
807
   depending on the current column type, only printing characters
818
   should get this far */
808
   should get this far */
Line 936... Line 926...
936
}
926
}
937
 
927
 
938
static void de_drawtext(int xpos, int ypos, char *text)
928
static void de_drawtext(int xpos, int ypos, char *text)
939
{
929
{
940
    gdrawstr(de, p->f, p->fg, pt(xpos, ypos), text);
930
    gdrawstr(de, p->f, p->fg, pt(xpos, ypos), text);
941
    show(de);
-
 
942
}
931
}
943
 
932
 
944
/* Keypress callbacks */
933
/* Keypress callbacks */
945
 
934
 
946
void de_normalkeyin(control c, int k)
935
void de_normalkeyin(control c, int k)
Line 1021... Line 1010...
1021
	return;
1010
	return;
1022
    }
1011
    }
1023
    switch (key) {
1012
    switch (key) {
1024
    case HOME:
1013
    case HOME:
1025
	jumpwin(1, 1);
1014
	jumpwin(1, 1);
-
 
1015
	downlightrect();
-
 
1016
	crow = ccol = 1;
-
 
1017
	highlightrect();
1026
	break;
1018
	break;
1027
    case END:
1019
    case END:
1028
	i = ymaxused - nhigh + 2;
1020
	i = ymaxused - nhigh + 2;
1029
	crow = ymaxused;
-
 
1030
	jumpwin(xmaxused, max(i, 1));
1021
	jumpwin(xmaxused, max(i, 1));
-
 
1022
	downlightrect();
-
 
1023
	crow = ymaxused - rowmin + 1;
-
 
1024
	ccol = 1;
-
 
1025
	highlightrect();
1031
	break;
1026
	break;
1032
    case PGUP:
1027
    case PGUP:
1033
	i = rowmin - nhigh + 2;
1028
	i = rowmin - nhigh + 2;
1034
	jumpwin(xmaxused, max(i, 1));
1029
	jumpwin(colmin, max(i, 1));
1035
	break;
1030
	break;
1036
    case PGDN:
1031
    case PGDN:
1037
	jumpwin(colmin, rowmax);
1032
	jumpwin(colmin, rowmax);
1038
	break;
1033
	break;
1039
    case LEFT:
1034
    case LEFT:
Line 1201... Line 1196...
1201
    deredraw();
1196
    deredraw();
1202
}
1197
}
1203
 
1198
 
1204
static void deredraw()
1199
static void deredraw()
1205
{
1200
{
1206
    int i;
1201
    int i, w, dw;
1207
 
1202
 
1208
    if (WIDTH != oldWIDTH || HEIGHT != oldHEIGHT) {
1203
    if (WIDTH != oldWIDTH || HEIGHT != oldHEIGHT) {
1209
	drawwindow();
1204
	drawwindow();
1210
	return;
1205
	return;
1211
    }
1206
    }
-
 
1207
    windowWidth = w = 2*bwidth + boxw[0] + BOXW(colmin);
-
 
1208
    nwide = 2;
-
 
1209
    for (i = 2; i < 100; i++) { /* 100 on-screen columns cannot occur */
-
 
1210
	dw = BOXW(i + colmin - 1);
-
 
1211
	if((w += dw) > WIDTH) {
-
 
1212
	    nwide = i;
-
 
1213
	    windowWidth = w - dw;
-
 
1214
	    break;
-
 
1215
	}
1212
    
1216
    }
-
 
1217
 
1213
    gfillrect(de, bbg, rect(0, 0, windowWidth, box_h));
1218
    gfillrect(de, bbg, rect(0, 0, windowWidth, box_h));
1214
    gfillrect(de, bbg, rect(0, 0, boxw[0], windowHeight));
1219
    gfillrect(de, bbg, rect(0, 0, boxw[0], windowHeight));
1215
 
1220
 
1216
    for (i = 1; i < nhigh; i++)
1221
    for (i = 1; i < nhigh; i++)
1217
	drawrectangle(0, hwidth + i * box_h, boxw[0], box_h, 1, 1);
1222
	drawrectangle(0, hwidth + i * box_h, boxw[0], box_h, 1, 1);
-
 
1223
    colmax = colmin + (nwide - 2);
-
 
1224
    rowmax = rowmin + (nhigh - 2);
1218
    printlabs();
1225
    printlabs();
1219
    if (inputlist != R_NilValue)
1226
    if (inputlist != R_NilValue)
1220
	for (i = colmin; i <= colmax; i++) drawcol(i);
1227
	for (i = colmin; i <= colmax; i++) drawcol(i);
-
 
1228
    gfillrect(de, p->bg, rect(windowWidth+1, 0, WIDTH-windowWidth-1, HEIGHT));
1221
    highlightrect();
1229
    highlightrect();
1222
    show(de);
-
 
1223
}
1230
}
1224
 
1231
 
1225
void de_closewin()
1232
void de_closewin()
1226
{
1233
{
1227
    closerect();
1234
    closerect();