The R Project SVN R

Rev

Rev 7849 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7849 Rev 9237
1
/* Copyright (C) 1999 Guido Masarotto
1
/* Copyright (C) 1999, 2000 Guido Masarotto
2
 
2
 
3
   Generalized version of widgets in buttons.c
3
   Generalized version of widgets in buttons.c
4
 
4
 
5
 
5
 
6
   This file is part of GraphApp, a cross-platform C graphics library.
6
   This file is part of GraphApp, a cross-platform C graphics library.
7
 
7
 
8
   GraphApp is free software; you can redistribute it and/or modify it
8
   GraphApp is free software; you can redistribute it and/or modify it
9
   under the terms of the GNU Library General Public License.
9
   under the terms of the GNU Library General Public License.
10
   GraphApp is distributed in the hope that it will be useful, but
10
   GraphApp is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY.
11
   WITHOUT ANY WARRANTY.
12
 
12
 
13
   See the file COPYLIB.TXT for details.
13
   See the file COPYLIB.TXT for details.
14
*/
14
*/
15
 
15
 
16
#include "internal.h"
16
#include "internal.h"
17
 
17
 
18
/* Win32 style scrollbars */
18
/* Win32 style scrollbars */
19
void
19
void
20
gchangescrollbar(scrollbar obj, int which, int where, int max, int pagesize,
20
gchangescrollbar(scrollbar obj, int which, int where, int max, int pagesize,
21
		 int disablenoscroll)
21
		 int disablenoscroll)
22
{
22
{
23
    HWND hwnd;
23
    HWND hwnd;
24
    SCROLLINFO si;
24
    SCROLLINFO si;
25
 
25
 
26
    if (! obj) return;
26
    if (! obj) return;
27
    hwnd = obj->handle;
27
    hwnd = obj->handle;
28
    switch (which) {
28
    switch (which) {
29
    case HWINSB: 
29
    case HWINSB: 
30
	obj->xmax = max;
30
	obj->xmax = max;
31
	obj->xsize = pagesize;
31
	obj->xsize = pagesize;
32
	which = SB_HORZ;
32
	which = SB_HORZ;
33
	break;
33
	break;
34
    case VWINSB: 
34
    case VWINSB: 
35
	obj->max = max;
35
	obj->max = max;
36
	obj->size = pagesize;
36
	obj->size = pagesize;
37
	which = SB_VERT; 
37
	which = SB_VERT; 
38
	break;
38
	break;
39
    default: 
39
    default: 
40
	obj->max = max;
40
	obj->max = max;
41
	obj->size = pagesize;
41
	obj->size = pagesize;
42
	which = SB_CTL; 
42
	which = SB_CTL; 
43
	break;
43
	break;
44
    }
44
    }
45
    si.cbSize = sizeof(si);
45
    si.cbSize = sizeof(si);
46
    si.fMask  = disablenoscroll ? (SIF_ALL | SIF_DISABLENOSCROLL) : SIF_ALL;
46
    si.fMask  = disablenoscroll ? (SIF_ALL | SIF_DISABLENOSCROLL) : SIF_ALL;
47
    si.nMin   = 0;
47
    si.nMin   = 0;
48
    si.nMax   = max;
48
    si.nMax   = max;
49
    si.nPage  = pagesize;
49
    si.nPage  = pagesize;
50
    si.nPos   = where;
50
    si.nPos   = where;
51
    SetScrollInfo(hwnd, which, &si, 1);
51
    SetScrollInfo(hwnd, which, &si, 1);
52
}
52
}
53
 
53
 
54
void gsetcursor(drawing d, cursor c)
54
void gsetcursor(drawing d, cursor c)
55
{
55
{
56
    POINT pt;
56
    POINT pt;
57
 
57
 
58
    decrease_refcount(d->drawstate->crsr);
58
    decrease_refcount(d->drawstate->crsr);
59
    d->drawstate->crsr = c;
59
    d->drawstate->crsr = c;
60
    increase_refcount(c);
60
    increase_refcount(c);
61
    /* ensure new cursor is shown */
61
    /* ensure new cursor is shown */
62
    GetCursorPos(&pt);
62
    GetCursorPos(&pt);
63
    SetCursorPos(pt.x, pt.y);
63
    SetCursorPos(pt.x, pt.y);
64
}
64
}
65
 
65
 
66
control newtoolbar(int height)
66
control newtoolbar(int height)
67
{
67
{
68
    window c = current_window;
68
    window c = current_window;
69
    if (!ismdi() || !c || (c==MDIFrame)) return NULL;
69
    if (!ismdi() || !c || (c==MDIFrame)) return NULL;
70
    addto(MDIFrame);
70
    addto(MDIFrame);
71
    c->toolbar = newwindow("TOOLBAR", rect(0, 0, 100, height),
71
    c->toolbar = newwindow("TOOLBAR", rect(0, 0, 100, height),
72
			   ChildWindow | Border);
72
			   ChildWindow | Border);
73
    if (c->toolbar) {
73
    if (c->toolbar) {
74
        DWORD wcol = GetSysColor(COLOR_MENU);
74
        DWORD wcol = GetSysColor(COLOR_MENU);
75
	hide(c->toolbar);
75
	hide(c->toolbar);
76
	setbackground(c->toolbar, 
76
	setbackground(c->toolbar, 
77
                      rgb( (wcol >> 0) &  0x000000FFL,
77
                      rgb( (wcol >> 0) &  0x000000FFL,
78
                           (wcol >> 8) &  0x000000FFL,
78
                           (wcol >> 8) &  0x000000FFL,
79
                           (wcol >> 16) &  0x000000FFL));
79
                           (wcol >> 16) &  0x000000FFL));
80
    }
80
    }
81
    addto(c);
81
    addto(c);
82
    return (control) c->toolbar;
82
    return (control) c->toolbar;
83
}
83
}
84
 
84
 
85
/* Fix background color for image on the toolbar.
85
/* Fix background color for image on the toolbar.
86
   Designed to work with image in stdimc.c:
86
   Designed to work with image in stdimc.c:
87
   (a) background is pixel (0,0);
87
   (a) background is pixel (0,0);
88
   (b) image depth is 8 bits;
88
   (b) image depth is 8 bits;
89
   (c) image is changed not copied.
89
   (c) image is changed not copied.
90
*/
90
*/
91
button newtoolbutton(image img, rect r, actionfn fn) {
91
button newtoolbutton(image img, rect r, actionfn fn) {
92
   DWORD wcol = GetSysColor(COLOR_MENU);
92
   DWORD wcol = GetSysColor(COLOR_MENU);
93
   rgb    col = rgb( (wcol >> 0) &  0x000000FFL,
93
   rgb    col = rgb( (wcol >> 0) &  0x000000FFL,
94
                     (wcol >> 8) &  0x000000FFL,
94
                     (wcol >> 8) &  0x000000FFL,
95
                     (wcol >> 16) &  0x000000FFL);
95
                     (wcol >> 16) &  0x000000FFL);
96
   img->cmap[img->pixels[0]] = col;
96
   img->cmap[img->pixels[0]] = col;
97
   return newimagebutton(img, r, fn);
97
   return newimagebutton(img, r, fn);
98
}
98
}
99
    
99
    
100
 
100
 
101
void scrolltext(textbox c, int lines)
101
void scrolltext(textbox c, int lines)
102
{
102
{
103
    int linecount = sendmessage(c->handle, EM_GETLINECOUNT, 0, 0);
103
    int linecount = sendmessage(c->handle, EM_GETLINECOUNT, 0, 0);
104
    sendmessage(c->handle, EM_LINESCROLL, 0, linecount - lines);
104
    sendmessage(c->handle, EM_LINESCROLL, 0, linecount - lines);
105
}
105
}
106
 
106
 
107
 
107
 
108
int ggetkeystate()
108
int ggetkeystate()
109
{
109
{
110
  int k = 0;
110
  int k = 0;
111
  if (GetKeyState(VK_CONTROL)&0x8000) 
111
  if (GetKeyState(VK_CONTROL)&0x8000) 
112
    k |= CtrlKey;
112
    k |= CtrlKey;
113
  if (GetKeyState(VK_MENU)&0x8000)
113
  if (GetKeyState(VK_MENU)&0x8000)
114
    k |= AltKey;
114
    k |= AltKey;
115
  if (GetKeyState(VK_SHIFT)&0x8000)
115
  if (GetKeyState(VK_SHIFT)&0x8000)
116
    k |= ShiftKey;
116
    k |= ShiftKey;
117
  return k;
117
  return k;
118
}
118
}
119
 
119
 
120
 
120