The R Project SVN R

Rev

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

Rev 46038 Rev 46784
Line 397... Line 397...
397
    if (oldcol < DE->colmin) { /* drop oldcol...colmin - 1 */
397
    if (oldcol < DE->colmin) { /* drop oldcol...colmin - 1 */
398
	dw = DE->boxw[0];
398
	dw = DE->boxw[0];
399
	for (i = oldcol; i < DE->colmin; i++) dw += BOXW(i);
399
	for (i = oldcol; i < DE->colmin; i++) dw += BOXW(i);
400
	copyH(DE, dw, DE->boxw[0], oldwindowWidth - dw + 1);
400
	copyH(DE, dw, DE->boxw[0], oldwindowWidth - dw + 1);
401
	dw = oldwindowWidth - BOXW(oldcol) + 1;
401
	dw = oldwindowWidth - BOXW(oldcol) + 1;
402
	cleararea(DE, dw, DE->hwidth, DE->p->w-dw, DE->p->h, DE->p->bg);
402
	cleararea(DE, dw, DE->hwidth, DE->p->w-dw, DE->p->h, DE->p->guiColors[dataeditbg]);
403
	/* oldnwide includes the row labels */
403
	/* oldnwide includes the row labels */
404
	for (i = oldcol+oldnwide-1; i <= DE->colmax; i++) drawcol(DE, i);
404
	for (i = oldcol+oldnwide-1; i <= DE->colmax; i++) drawcol(DE, i);
405
    } else {
405
    } else {
406
	/* move one or more cols left */
406
	/* move one or more cols left */
407
	dw = BOXW(DE->colmin);
407
	dw = BOXW(DE->colmin);
408
	copyH(DE, DE->boxw[0], DE->boxw[0] + dw, DE->windowWidth - dw + 1);
408
	copyH(DE, DE->boxw[0], DE->boxw[0] + dw, DE->windowWidth - dw + 1);
409
	dw = DE->windowWidth + 1;
409
	dw = DE->windowWidth + 1;
410
	cleararea(DE, dw, DE->hwidth, DE->p->w-dw, DE->p->h, DE->p->bg);
410
	cleararea(DE, dw, DE->hwidth, DE->p->w-dw, DE->p->h, DE->p->guiColors[dataeditbg]);
411
	drawcol(DE, DE->colmin);
411
	drawcol(DE, DE->colmin);
412
    }
412
    }
413
    gchangescrollbar(DE->de, HWINSB, (DE->colmin - 1)/DE->xScrollbarScale,
413
    gchangescrollbar(DE->de, HWINSB, (DE->colmin - 1)/DE->xScrollbarScale,
414
		     DE->xmaxused/DE->xScrollbarScale,
414
		     DE->xmaxused/DE->xScrollbarScale,
415
		     max(DE->nwide/DE->xScrollbarScale, 1), 0);
415
		     max(DE->nwide/DE->xScrollbarScale, 1), 0);
Line 562... Line 562...
562
	bw = BOXW(whichcol);
562
	bw = BOXW(whichcol);
563
    const char *clab;
563
    const char *clab;
564
    SEXP tmp;
564
    SEXP tmp;
565
 
565
 
566
    find_coords(DE, 0, col, &src_x, &src_y);
566
    find_coords(DE, 0, col, &src_x, &src_y);
567
    cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->bg);
567
    cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->guiColors[dataeditbg]);
568
    cleararea(DE, src_x, src_y, bw, DE->box_h, bbg);
568
    cleararea(DE, src_x, src_y, bw, DE->box_h, bbg);
569
    for (i = 0; i < DE->nhigh; i++)
569
    for (i = 0; i < DE->nhigh; i++)
570
	drawrectangle(DE, src_x, DE->hwidth + i * DE->box_h, bw, DE->box_h, 1, 1);
570
	drawrectangle(DE, src_x, DE->hwidth + i * DE->box_h, bw, DE->box_h, 1, 1);
571
 
571
 
572
    /* now fill it in if it is active */
572
    /* now fill it in if it is active */
Line 591... Line 591...
591
    char rlab[15];
591
    char rlab[15];
592
    SEXP tvec;
592
    SEXP tvec;
593
 
593
 
594
    find_coords(DE, row, 0, &src_x, &src_y);
594
    find_coords(DE, row, 0, &src_x, &src_y);
595
    cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h,
595
    cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h,
596
	      (whichrow > 0) ? DE->p->bg : bbg);
596
	      (whichrow > 0) ? DE->p->guiColors[dataeditbg] : bbg);
597
    drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1);
597
    drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1);
598
 
598
 
599
    sprintf(rlab, DE->labform, whichrow);
599
    sprintf(rlab, DE->labform, whichrow);
600
    printstring(DE, rlab, strlen(rlab), row, 0, 0);
600
    printstring(DE, rlab, strlen(rlab), row, 0, 0);
601
 
601
 
Line 906... Line 906...
906
    char buf[BUFSIZE+1];
906
    char buf[BUFSIZE+1];
907
 
907
 
908
    find_coords(DE, row, col, &x_pos, &y_pos);
908
    find_coords(DE, row, col, &x_pos, &y_pos);
909
    if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1);
909
    if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1);
910
    cleararea(DE, x_pos + 1, y_pos + 1, bw - 1, DE->box_h - 1,
910
    cleararea(DE, x_pos + 1, y_pos + 1, bw - 1, DE->box_h - 1,
911
	      (row==0 || col==0) ? bbg:DE->p->bg);
911
	      (row==0 || col==0) ? bbg:DE->p->guiColors[dataeditbg]);
912
    fw = min(BUFSIZE, (bw - 8)/(DE->p->fw));
912
    fw = min(BUFSIZE, (bw - 8)/(DE->p->fw));
913
    bufw = min(fw, buflen);
913
    bufw = min(fw, buflen);
914
    strncpy(buf, ibuf, bufw);
914
    strncpy(buf, ibuf, bufw);
915
    buf[bufw] = '\0';
915
    buf[bufw] = '\0';
916
    if (buflen > fw) {
916
    if (buflen > fw) {
Line 930... Line 930...
930
{
930
{
931
    int x_pos, y_pos;
931
    int x_pos, y_pos;
932
 
932
 
933
    find_coords(DE, DE->crow, DE->ccol, &x_pos, &y_pos);
933
    find_coords(DE, DE->crow, DE->ccol, &x_pos, &y_pos);
934
    cleararea(DE, x_pos, y_pos, BOXW(DE->ccol+DE->colmin-1),
934
    cleararea(DE, x_pos, y_pos, BOXW(DE->ccol+DE->colmin-1),
935
	      DE->box_h, DE->p->bg);
935
	      DE->box_h, DE->p->guiColors[dataeditbg]);
936
}
936
}
937
 
937
 
938
/* handlechar has to be able to parse decimal numbers and strings,
938
/* handlechar has to be able to parse decimal numbers and strings,
939
   depending on the current column type, only printing characters
939
   depending on the current column type, only printing characters
940
   should get this far */
940
   should get this far */
Line 1045... Line 1045...
1045
    gfillrect(DE->de, col, rect(xpos, ypos, width, height));
1045
    gfillrect(DE->de, col, rect(xpos, ypos, width, height));
1046
}
1046
}
1047
 
1047
 
1048
static void clearwindow(DEstruct DE)
1048
static void clearwindow(DEstruct DE)
1049
{
1049
{
1050
    gfillrect(DE->de, DE->p->bg, rect(0, 0, DE->p->w, DE->p->h));
1050
    gfillrect(DE->de, DE->p->guiColors[dataeditbg], rect(0, 0, DE->p->w, DE->p->h));
1051
}
1051
}
1052
 
1052
 
1053
 
1053
 
1054
static void drawrectangle(DEstruct DE,
1054
static void drawrectangle(DEstruct DE,
1055
			  int xpos, int ypos, int width, int height,
1055
			  int xpos, int ypos, int width, int height,
1056
			  int lwd, int fore)
1056
			  int lwd, int fore)
1057
{
1057
{
1058
    /* only used on screen, so always fast */
1058
    /* only used on screen, so always fast */
1059
    gdrawrect(DE->de, lwd, 0, (fore==1)? DE->p->ufg: DE->p->bg,
1059
    gdrawrect(DE->de, lwd, 0, (fore==1)? DE->p->guiColors[dataedituser]: DE->p->guiColors[dataeditbg],
1060
	      rect(xpos, ypos, width, height), 1, PS_ENDCAP_SQUARE,
1060
	      rect(xpos, ypos, width, height), 1, PS_ENDCAP_SQUARE,
1061
	      PS_JOIN_BEVEL, 10);
1061
	      PS_JOIN_BEVEL, 10);
1062
}
1062
}
1063
 
1063
 
1064
static void de_drawtext(DEstruct DE, int xpos, int ypos, const char *text)
1064
static void de_drawtext(DEstruct DE, int xpos, int ypos, const char *text)
1065
{
1065
{
1066
    gdrawstr(DE->de, DE->p->f, DE->p->fg, pt(xpos, ypos), text);
1066
    gdrawstr(DE->de, DE->p->f, DE->p->guiColors[dataeditfg], pt(xpos, ypos), text);
1067
}
1067
}
1068
 
1068
 
1069
/* Keypress callbacks */
1069
/* Keypress callbacks */
1070
 
1070
 
1071
static void de_normalkeyin(control c, int k)
1071
static void de_normalkeyin(control c, int k)
Line 1319... Line 1319...
1319
	    prev = get_cell_text(DE);
1319
	    prev = get_cell_text(DE);
1320
	    if (strlen(prev) * (DE->p->fw) > bw)
1320
	    if (strlen(prev) * (DE->p->fw) > bw)
1321
		rr.width = (strlen(prev) + 2) * (DE->p->fw);
1321
		rr.width = (strlen(prev) + 2) * (DE->p->fw);
1322
	    addto(DE->de);
1322
	    addto(DE->de);
1323
	    DE->celledit = newfield_no_border(prev, rr);
1323
	    DE->celledit = newfield_no_border(prev, rr);
1324
	    setbackground(DE->celledit, DE->p->bg);
-
 
1325
	    setforeground(DE->celledit, DE->p->ufg);
-
 
1326
	    settextfont(DE->celledit, DE->p->f);
1324
	    settextfont(DE->celledit, DE->p->f);
-
 
1325
	    setbackground(DE->celledit, DE->p->guiColors[dataeditbg]);
-
 
1326
	    setforeground(DE->celledit, DE->p->guiColors[dataedituser]);
-
 
1327
 
1327
	    show(DE->celledit);
1328
	    show(DE->celledit);
1328
	    DE->CellEditable = TRUE;
1329
	    DE->CellEditable = TRUE;
1329
	} else if (buttons & LeftButton) {
1330
	} else if (buttons & LeftButton) {
1330
	    DE->ccol = wcol;
1331
	    DE->ccol = wcol;
1331
	    DE->crow = wrow;
1332
	    DE->crow = wrow;
Line 1381... Line 1382...
1381
	DE->colmax = min(DE->xmaxused, DE->colmin + (DE->nwide - 2));
1382
	DE->colmax = min(DE->xmaxused, DE->colmin + (DE->nwide - 2));
1382
	DE->rowmax = min(DE->ymaxused, DE->rowmin + (DE->nhigh - 2));
1383
	DE->rowmax = min(DE->ymaxused, DE->rowmin + (DE->nhigh - 2));
1383
    }
1384
    }
1384
    printlabs(DE);
1385
    printlabs(DE);
1385
    for (i = DE->colmin; i <= DE->colmax; i++) drawcol(DE,i);
1386
    for (i = DE->colmin; i <= DE->colmax; i++) drawcol(DE,i);
1386
    gfillrect(DE->de, DE->p->bg, rect(DE->windowWidth+1, DE->hwidth,
1387
    gfillrect(DE->de, DE->p->guiColors[dataeditbg], rect(DE->windowWidth+1, DE->hwidth,
1387
				      DE->p->w - DE->windowWidth-1,
1388
				      DE->p->w - DE->windowWidth-1,
1388
				      DE->p->h - DE->hwidth));
1389
				      DE->p->h - DE->hwidth));
1389
    highlightrect(DE);
1390
    highlightrect(DE);
1390
}
1391
}
1391
 
1392
 
Line 1747... Line 1748...
1747
    dataeditor c;
1748
    dataeditor c;
1748
    menuitem m;
1749
    menuitem m;
1749
 
1750
 
1750
    DE->p = newconsoledata((consolefn) ? consolefn : FixedFont,
1751
    DE->p = newconsoledata((consolefn) ? consolefn : FixedFont,
1751
			   pagerrow, pagercol, 0, 0,
1752
			   pagerrow, pagercol, 0, 0,
1752
			   consolefg, consoleuser, consolebg,
1753
			   guiColors,
1753
			   DATAEDITOR, 0);
1754
			   DATAEDITOR, 0);
1754
    if (!DE->p) return NULL;
1755
    if (!DE->p) return NULL;
1755
 
1756
 
1756
    w = DE->p->w ;
1757
    w = DE->p->w ;
1757
    h = DE->p->h;
1758
    h = DE->p->h;
Line 1776... Line 1777...
1776
    (DE->p->cols) = DE->p->w / (DE->p->fw) - 1;
1777
    (DE->p->cols) = DE->p->w / (DE->p->fw) - 1;
1777
    (DE->p->rows) = DE->p->h / (DE->p->fh) - 1;
1778
    (DE->p->rows) = DE->p->h / (DE->p->fh) - 1;
1778
    DE->p->right = (DE->p->w - (DE->p->cols)*(DE->p->fw)) / 2;
1779
    DE->p->right = (DE->p->w - (DE->p->cols)*(DE->p->fw)) / 2;
1779
    DE->p->top = (DE->p->h - (DE->p->rows)*(DE->p->fh)) / 2;
1780
    DE->p->top = (DE->p->h - (DE->p->rows)*(DE->p->fh)) / 2;
1780
    gsetcursor(c, ArrowCursor);
1781
    gsetcursor(c, ArrowCursor);
1781
    setbackground(c, consolebg);
1782
    setbackground(c, guiColors[dataeditbg]);
1782
    if (ismdi() && (RguiMDI & RW_TOOLBAR)) {
1783
    if (ismdi() && (RguiMDI & RW_TOOLBAR)) {
1783
	/* blank toolbar to stop windows jumping around */
1784
	/* blank toolbar to stop windows jumping around */
1784
	int btsize = 24;
1785
	int btsize = 24;
1785
	control tb;
1786
	control tb;
1786
	addto(c);
1787
	addto(c);