static void draw_radio(control c, rect r) { int w; rect box, textrect; char *name; int style = (AlignLeft | AlignTop); font f; rgb old = currentcolour(); /* Calculate rectangles. */ f = gettextfont(c); setfont(f); w = strwidth(f,"W"); if (w > r.width) w = r.width; if (w > r.height) w = r.height; box = rect(r.x,r.y+1,w,w); if (w < getheight(f) - getdescent(f)) box.y += getheight(f) - getdescent(f) - w; textrect = rect(r.x+w+w/2,r.y,r.width-(w+w/2),r.height); /* Clear the check area. */ setlinewidth(1); setcolour(White); fillellipse(insetr(box,1)); /* Draw the check area */ if (isenabled(c)) setcolour(Black); else setcolour(Grey); drawellipse(box); /* Provide 'pressed button' effect by black border. */ if (ishighlighted(c)) { setlinewidth(2); drawellipse(box); setlinewidth(1); } /* Put o in circle if checked. */ if (ischecked(c)) fillellipse(insetr(box,3)); name = getname(c); if (isenabled(c)) { /* if (hasfocus(c)) { style |= Underline; setlinewidth(2); } */ setcolour(getforeground(c)); } drawtext(textrect, style, name); setcolour(old); }
static void draw_picture(control obj, rect r) { image img; bitmap store = NULL; rgb old = currentcolour(); img = obj->img; if (has_transparent_pixels(img)) { store = newbitmap(r.width, r.height, 0); drawto(store); setcolour(getbackground(obj)); fillrect(r); } if (img) { /* Draw the button image. */ if (ischecked(obj)) drawdarker(img, r, getrect(img)); else if (isenabled(obj)) drawimage(img, r, getrect(img)); else drawimage(img, r, getrect(img)); /* never grey */ } if (store != NULL) { drawto(obj); copyrect(store, pt(0,0), getrect(store)); del(store); } setcolour(old); }
static void draw_image_button(button obj, rect r) { image img; bitmap store = NULL; rect ir; rgb up, down; rgb old = currentcolour(); img = obj->img; if (has_transparent_pixels(img)) { store = newbitmap(r.width, r.height, 0); drawto(store); setcolour(getbackground(obj)); fillrect(r); } if (img) { ir = insetr(r,2); if (ishighlighted(obj)) /* button is pressed */ ir.x += 1, ir.y += 1; /* Draw the button image. */ if (ischecked(obj)) drawdarker(img, ir, getrect(img)); else if (isenabled(obj)) drawimage(img, ir, getrect(img)); else drawgreyscale(img, ir, getrect(img)); if (ishighlighted(obj)) { /* fill the gap */ ir.x -= 1, ir.y -= 1; setcolour(getbackground(obj)); drawline(topleft(ir),topright(ir)); drawline(topleft(ir),bottomleft(ir)); } } /* Draw button border. */ setcolour(getforeground(obj)); setlinewidth(1); drawrect(r); /* Draw button shadow. */ up = White, down = Grey; if (ishighlighted(obj)) up = Grey, down = LightGrey; draw_shadow(insetr(r,1), up, down, 1); if (store != NULL) { drawto(obj); copyrect(store, pt(0,0), getrect(store)); del(store); } setcolour(old); }
/* * Private label redraw function. */ static void draw_label(control c, rect r) { /* Draw the label. */ if (!isenabled(c)) setcolour(Grey); else setcolour(Black); setfont(gettextfont(c)); drawtext(r, getvalue(c), getname(c)); }
static void checkbox_mouseup(control c, int buttons, point xy) { if (! isenabled(c)) return; disarm(c); unhighlight(c); if (! ptinr(xy, getrect(c))) return; if (ischecked(c)) uncheck(c); else check(c); activatecontrol(c); }
PROTECTED int handle_menu_key(WPARAM wParam) { object win, obj; win = find_by_handle(GetFocus()); if (win) { if (win->kind != WindowObject) win = win->parent; obj = find_by_key(win, wParam); if (obj) { adjust_menus_top_down(obj); if (isenabled(obj)) /* Don't do menu actions which are greyed out. CJ */ activatecontrol(obj); return 1; } } return 0; }
static void draw_button(control c, rect r) { rect textrect; rgb up, down; font f; rgb old = currentcolour(); clear(c); /* Draw the button name. */ if (isenabled(c)) setcolour(getforeground(c)); else setcolour(Grey); f = gettextfont(c); setfont(f); textrect = r; if (ishighlighted(c)) textrect.x += 1, textrect.y += 1; drawtext(textrect, Center|VCenter, getname(c)); /* Draw button border. */ setlinewidth(1); drawrect(r); r = insetr(r,1); /* Draw button shadow. */ up = White, down = Grey; if (ishighlighted(c)) up = Grey, down = LightGrey; else if (hasfocus(c)) { setcolour(Black); drawrect(r); r = insetr(r,1); } draw_shadow(r, up, down, SHADOW_WIDTH); setcolour(old); }