The R Project SVN R

Rev

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

Rev 40869 Rev 41783
Line 114... Line 114...
114
static void drawrectangle(DEstruct, int, int, int, int, int, int);
114
static void drawrectangle(DEstruct, int, int, int, int, int, int);
115
static void drawrow(DEstruct, int);
115
static void drawrow(DEstruct, int);
116
static void find_coords(DEstruct, int, int, int*, int*);
116
static void find_coords(DEstruct, int, int, int*, int*);
117
static void handlechar(DEstruct, char*);
117
static void handlechar(DEstruct, char*);
118
static void highlightrect(DEstruct);
118
static void highlightrect(DEstruct);
119
static Rboolean initwin(DEstruct, char *);
119
static Rboolean initwin(DEstruct, const char *);
120
static void jumppage(DEstruct, int);
120
static void jumppage(DEstruct, int);
121
static void jumpwin(DEstruct, int, int);
121
static void jumpwin(DEstruct, int, int);
122
static void de_popupmenu(DEstruct, int, int, int);
122
static void de_popupmenu(DEstruct, int, int, int);
123
static void printlabs(DEstruct);
123
static void printlabs(DEstruct);
124
static void printrect(DEstruct, int, int);
124
static void printrect(DEstruct, int, int);
125
static void printstring(DEstruct, char*, int, int, int, int);
125
static void printstring(DEstruct, const char*, int, int, int, int);
126
static void printelt(DEstruct, SEXP, int, int, int);
126
static void printelt(DEstruct, SEXP, int, int, int);
127
static void setcellwidths(DEstruct);
127
static void setcellwidths(DEstruct);
128
 
128
 
129
static dataeditor newdataeditor(DEstruct, char *);
129
static dataeditor newdataeditor(DEstruct, const char *);
130
static void de_copy(control c);
130
static void de_copy(control c);
131
static void de_paste(control c);
131
static void de_paste(control c);
132
static void de_delete(control c);
132
static void de_delete(control c);
133
 
133
 
134
 
134
 
Line 491... Line 491...
491
    }
491
    }
492
 
492
 
493
    highlightrect(DE);
493
    highlightrect(DE);
494
}
494
}
495
 
495
 
496
static char *get_col_name(DEstruct DE, int col)
496
static const char *get_col_name(DEstruct DE, int col)
497
{
497
{
498
    static char clab[25];
498
    static char clab[25];
499
    if (col <= DE->xmaxused) {
499
    if (col <= DE->xmaxused) {
500
	/* don't use NA labels */
500
	/* don't use NA labels */
501
	SEXP tmp = STRING_ELT(DE->names, col - 1);
501
	SEXP tmp = STRING_ELT(DE->names, col - 1);
Line 549... Line 549...
549
/* whichcol is absolute col no, col is position on screen */
549
/* whichcol is absolute col no, col is position on screen */
550
static void drawcol(DEstruct DE, int whichcol)
550
static void drawcol(DEstruct DE, int whichcol)
551
{
551
{
552
    int i, src_x, src_y, len, col = whichcol - DE->colmin + 1, 
552
    int i, src_x, src_y, len, col = whichcol - DE->colmin + 1, 
553
	bw = BOXW(whichcol);
553
	bw = BOXW(whichcol);
554
    char *clab;
554
    const char *clab;
555
    SEXP tmp;
555
    SEXP tmp;
556
 
556
 
557
    find_coords(DE, 0, col, &src_x, &src_y);
557
    find_coords(DE, 0, col, &src_x, &src_y);
558
    cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->bg);
558
    cleararea(DE, src_x, src_y, bw, DE->windowHeight, DE->p->bg);
559
    cleararea(DE, src_x, src_y, bw, DE->box_h, bbg);
559
    cleararea(DE, src_x, src_y, bw, DE->box_h, bbg);
Line 630... Line 630...
630
 
630
 
631
 
631
 
632
static void drawelt(DEstruct DE, int whichrow, int whichcol)
632
static void drawelt(DEstruct DE, int whichrow, int whichcol)
633
{
633
{
634
    int i;
634
    int i;
635
    char *clab;
635
    const char *clab;
636
    SEXP tmp;
636
    SEXP tmp;
637
 
637
 
638
    if (whichrow == 0) {
638
    if (whichrow == 0) {
639
	clab = get_col_name(DE, whichcol + DE->colmin - 1);
639
	clab = get_col_name(DE, whichcol + DE->colmin - 1);
640
	printstring(DE, clab, strlen(clab), 0, whichcol, 0);
640
	printstring(DE, clab, strlen(clab), 0, whichcol, 0);
Line 833... Line 833...
833
   the print area and print it, left adjusted if necessary; clear the
833
   the print area and print it, left adjusted if necessary; clear the
834
   area of previous text; */
834
   area of previous text; */
835
 
835
 
836
/* This version will only display BUFSIZE chars, but the maximum col width
836
/* This version will only display BUFSIZE chars, but the maximum col width
837
   will not allow that many */
837
   will not allow that many */
838
static void printstring(DEstruct DE, 
838
static void printstring(DEstruct DE, const char *ibuf, int buflen, 
839
			char *ibuf, int buflen, int row, int col, int left)
839
			int row, int col, int left)
840
{
840
{
841
    int x_pos, y_pos, bw, fw, bufw;
841
    int x_pos, y_pos, bw, fw, bufw;
842
    char buf[BUFSIZE+1];
842
    char buf[BUFSIZE+1];
843
 
843
 
844
    find_coords(DE, row, col, &x_pos, &y_pos);
844
    find_coords(DE, row, col, &x_pos, &y_pos);
Line 952... Line 952...
952
    bell();
952
    bell();
953
}
953
}
954
 
954
 
955
static void printlabs(DEstruct DE)
955
static void printlabs(DEstruct DE)
956
{
956
{
957
    char clab[15], *p;
957
    char clab[15];
-
 
958
    const char *p;
958
    int i;
959
    int i;
959
 
960
 
960
    for (i = DE->colmin; i <= DE->colmax; i++) {
961
    for (i = DE->colmin; i <= DE->colmax; i++) {
961
	p = get_col_name(DE, i);
962
	p = get_col_name(DE, i);
962
	printstring(DE, p, strlen(p), 0, i - DE->colmin + 1, 0);
963
	printstring(DE, p, strlen(p), 0, i - DE->colmin + 1, 0);
Line 1329... Line 1330...
1329
{
1330
{
1330
    copyrect(DE->de, pt(dest_x, DE->hwidth),
1331
    copyrect(DE->de, pt(dest_x, DE->hwidth),
1331
	     rect(src_x, DE->hwidth, width, DE->windowHeight - DE->hwidth));
1332
	     rect(src_x, DE->hwidth, width, DE->windowHeight - DE->hwidth));
1332
}
1333
}
1333
 
1334
 
1334
static Rboolean initwin(DEstruct DE, char *title)
1335
static Rboolean initwin(DEstruct DE, const char *title)
1335
{
1336
{
1336
    int i, labdigs;
1337
    int i, labdigs;
1337
    rect r;
1338
    rect r;
1338
 
1339
 
1339
    DE->de = newdataeditor(DE, title);
1340
    DE->de = newdataeditor(DE, title);
Line 1441... Line 1442...
1441
    if(key == '\n') popupclose(wconf);
1442
    if(key == '\n') popupclose(wconf);
1442
}
1443
}
1443
 
1444
 
1444
static void de_popupmenu(DEstruct DE, int x_pos, int y_pos, int col)
1445
static void de_popupmenu(DEstruct DE, int x_pos, int y_pos, int col)
1445
{
1446
{
1446
    char *blah;
1447
    const char *blah;
1447
    rect r = screen_coords(DE->de);
1448
    rect r = screen_coords(DE->de);
1448
 
1449
 
1449
    popupcol = DE->colmin + col - 1;
1450
    popupcol = DE->colmin + col - 1;
1450
    blah = get_col_name(DE, popupcol);
1451
    blah = get_col_name(DE, popupcol);
1451
    wconf = newwindow(G_("Variable editor"),
1452
    wconf = newwindow(G_("Variable editor"),
1452
		      rect(x_pos + r.x-150, y_pos + r.y-50, 300, 100),
1453
		      rect(x_pos + r.x-150, y_pos + r.y-50, 300, 100),
1453
		      Titlebar | Closebox | Modal);
1454
		      Titlebar | Closebox | Modal);
1454
    setclose(wconf, popupclose);
1455
    setclose(wconf, popupclose);
1455
    setbackground(wconf, bbg);
1456
    setbackground(wconf, bbg);
1456
    lwhat = newlabel(G_("variable name"), rect(10, 22, 90, 20), AlignLeft);
1457
    lwhat = newlabel(G_("variable name"), rect(10, 22, 90, 20), AlignLeft);
1457
    varname = newfield(blah, rect(100, 20, 120, 20));
1458
    varname = newfield((char *)blah, rect(100, 20, 120, 20));
1458
    lrb = newlabel(G_("type"), rect(50, 62, 50, 20), AlignLeft);
1459
    lrb = newlabel(G_("type"), rect(50, 62, 50, 20), AlignLeft);
1459
    rb_num = newradiobutton("numeric", rect(100, 60 , 80, 20), NULL);
1460
    rb_num = newradiobutton("numeric", rect(100, 60 , 80, 20), NULL);
1460
    rb_char = newradiobutton("character", rect(180, 60 , 80, 20), NULL);
1461
    rb_char = newradiobutton("character", rect(180, 60 , 80, 20), NULL);
1461
    isnumeric = (get_col_type(DE, popupcol) == NUMERIC);
1462
    isnumeric = (get_col_type(DE, popupcol) == NUMERIC);
1462
    if (isnumeric) check(rb_num); else check(rb_char);
1463
    if (isnumeric) check(rb_num); else check(rb_char);
Line 1661... Line 1662...
1661
 
1662
 
1662
#define MCHECK(a) if (!(a)) {del(c);return NULL;}
1663
#define MCHECK(a) if (!(a)) {del(c);return NULL;}
1663
 
1664
 
1664
RECT *RgetMDIsize(); /* in rui.c */
1665
RECT *RgetMDIsize(); /* in rui.c */
1665
 
1666
 
1666
static dataeditor newdataeditor(DEstruct DE, char *title)
1667
static dataeditor newdataeditor(DEstruct DE, const char *title)
1667
{
1668
{
1668
    int w, h, x, y;
1669
    int w, h, x, y;
1669
    dataeditor c;
1670
    dataeditor c;
1670
    menuitem m;
1671
    menuitem m;
1671
 
1672
 
Line 1683... Line 1684...
1683
	y = (pR->bottom - h) / 3; y = y > 20 ? y:20;
1684
	y = (pR->bottom - h) / 3; y = y > 20 ? y:20;
1684
    } else {
1685
    } else {
1685
	x = (devicewidth(NULL) - w) / 3;
1686
	x = (devicewidth(NULL) - w) / 3;
1686
	y = (deviceheight(NULL) - h) / 3 ;
1687
	y = (deviceheight(NULL) - h) / 3 ;
1687
    }
1688
    }
1688
    c = (dataeditor) newwindow(title, rect(x, y, w, h),
1689
    c = (dataeditor) newwindow((char *) title, rect(x, y, w, h),
1689
			       Document | StandardWindow | Menubar |
1690
			       Document | StandardWindow | Menubar |
1690
			       VScrollbar | HScrollbar | TrackMouse);
1691
			       VScrollbar | HScrollbar | TrackMouse);
1691
    if (!c) {
1692
    if (!c) {
1692
         freeConsoleData(DE->p);
1693
         freeConsoleData(DE->p);
1693
         return NULL;
1694
         return NULL;