The R Project SVN R

Rev

Rev 43889 | Rev 82774 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 43889 Rev 45017
Line 70... Line 70...
70
    if (!ismdi() || !c || (c==MDIFrame)) return NULL;
70
    if (!ismdi() || !c || (c==MDIFrame)) return NULL;
71
    addto(MDIFrame);
71
    addto(MDIFrame);
72
    c->toolbar = newwindow("TOOLBAR", rect(0, 0, 100, height),
72
    c->toolbar = newwindow("TOOLBAR", rect(0, 0, 100, height),
73
			   ChildWindow | Border);
73
			   ChildWindow | Border);
74
    if (c->toolbar) {
74
    if (c->toolbar) {
75
        DWORD wcol = GetSysColor(COLOR_MENU);
75
	DWORD wcol = GetSysColor(COLOR_MENU);
76
	hide(c->toolbar);
76
	hide(c->toolbar);
77
	setbackground(c->toolbar,
77
	setbackground(c->toolbar,
78
                      rgb( (wcol >> 0) &  0x000000FFL,
78
		      rgb( (wcol >> 0) &  0x000000FFL,
79
                           (wcol >> 8) &  0x000000FFL,
79
			   (wcol >> 8) &  0x000000FFL,
80
                           (wcol >> 16) &  0x000000FFL));
80
			   (wcol >> 16) &  0x000000FFL));
81
    }
81
    }
82
    addto(c);
82
    addto(c);
83
    return (control) c->toolbar;
83
    return (control) c->toolbar;
84
}
84
}
85
 
85
 
Line 88... Line 88...
88
   (a) background is pixel (0,0);
88
   (a) background is pixel (0,0);
89
   (b) image depth is 8 bits;
89
   (b) image depth is 8 bits;
90
   (c) image is changed not copied.
90
   (c) image is changed not copied.
91
*/
91
*/
92
button newtoolbutton(image img, rect r, actionfn fn) {
92
button newtoolbutton(image img, rect r, actionfn fn) {
93
   DWORD wcol = GetSysColor(COLOR_MENU);
93
    DWORD wcol = GetSysColor(COLOR_MENU);
94
   rgb    col = rgb( (wcol >> 0) &  0x000000FFL,
94
    rgb    col = rgb( (wcol >> 0) &  0x000000FFL,
95
                     (wcol >> 8) &  0x000000FFL,
95
		      (wcol >> 8) &  0x000000FFL,
96
                     (wcol >> 16) &  0x000000FFL);
96
		      (wcol >> 16) &  0x000000FFL);
97
   img->cmap[img->pixels[0]] = col;
97
    img->cmap[img->pixels[0]] = col;
98
   return newimagebutton(img, r, fn);
98
    return newimagebutton(img, r, fn);
99
}
99
}
100
 
100
 
101
 
101
 
102
void scrolltext(textbox c, int lines)
102
void scrolltext(textbox c, int lines)
103
{
103
{
Line 120... Line 120...
120
 
120
 
121
 
121
 
122
/* Extra text editing functions for R, Chris Jackson */
122
/* Extra text editing functions for R, Chris Jackson */
123
#include <richedit.h>
123
#include <richedit.h>
124
 
124
 
125
/* Move the editor caret position lines down. 
125
/* Move the editor caret position lines down.
126
   If lines is negative moves caret up.
126
   If lines is negative moves caret up.
127
   Stops at the top or the bottom if lines is too big or small.
127
   Stops at the top or the bottom if lines is too big or small.
128
*/
128
*/
129
 
129
 
130
void scrollcaret(textbox t, int lines)
130
void scrollcaret(textbox t, int lines)
Line 205... Line 205...
205
{
205
{
206
    HGLOBAL hglb;
206
    HGLOBAL hglb;
207
    char *text;
207
    char *text;
208
    long pastelen;
208
    long pastelen;
209
    if ( OpenClipboard(NULL) &&
209
    if ( OpenClipboard(NULL) &&
210
         (hglb = GetClipboardData(CF_TEXT)) &&
210
	 (hglb = GetClipboardData(CF_TEXT)) &&
211
         (text = (char *)GlobalLock(hglb))) {
211
	 (text = (char *)GlobalLock(hglb))) {
212
	pastelen = strlen(text);
212
	pastelen = strlen(text);
213
	GlobalUnlock(hglb);
213
	GlobalUnlock(hglb);
214
	CloseClipboard();
214
	CloseClipboard();
215
    } else pastelen = 0;
215
    } else pastelen = 0;
216
    return pastelen;
216
    return pastelen;
Line 220... Line 220...
220
   with the EX messages used in rich edit controls. The selection
220
   with the EX messages used in rich edit controls. The selection
221
   messages without EX cannot handle more than 64K of text */
221
   messages without EX cannot handle more than 64K of text */
222
 
222
 
223
void textselectionex(control obj, long *start, long *end)
223
void textselectionex(control obj, long *start, long *end)
224
{
224
{
225
	CHARRANGE sel;
225
    CHARRANGE sel;
226
	if (! obj)
226
    if (! obj)
227
		return;
227
	return;
228
	if ((obj->kind != FieldObject) && (obj->kind != TextboxObject))
228
    if ((obj->kind != FieldObject) && (obj->kind != TextboxObject))
229
		return;
229
	return;
230
	sendmessage(obj->handle, EM_EXGETSEL, 0, &sel);
230
    sendmessage(obj->handle, EM_EXGETSEL, 0, &sel);
231
	*start = sel.cpMin;
231
    *start = sel.cpMin;
232
	*end = sel.cpMax;
232
    *end = sel.cpMax;
233
}
233
}
234
 
234
 
235
void selecttextex(control obj, long start, long end)
235
void selecttextex(control obj, long start, long end)
236
{
236
{
237
	CHARRANGE sel;
237
    CHARRANGE sel;
238
	long length;
238
    long length;
239
 
239
 
240
	if (! obj)
240
    if (! obj)
241
		return;
241
	return;
242
	if ((obj->kind != FieldObject) && (obj->kind != TextboxObject))
242
    if ((obj->kind != FieldObject) && (obj->kind != TextboxObject))
243
		return;
243
	return;
244
	length = GetWindowTextLength(obj->handle);
244
    length = GetWindowTextLength(obj->handle);
245
	sel.cpMin = (start < 0) ? length : start;
245
    sel.cpMin = (start < 0) ? length : start;
246
	sel.cpMax = (end < 0) ? length : end;
246
    sel.cpMax = (end < 0) ? length : end;
247
	sendmessage(obj->handle, EM_EXSETSEL, 0, &sel);
247
    sendmessage(obj->handle, EM_EXSETSEL, 0, &sel);
248
}
248
}