void Icon::draw() { Fl_Flags f=0; Fl_Image *im = icon_im; if(focused()) { f=FL_SELECTED; } if(im) im->draw(0, 0, w(), h(),f); else { fl_color(FL_RED); fl_rect(0,0,w(),h()); fl_color(FL_BLACK); fl_rectf(1,1,w()-2,h()-2); fl_color(FL_WHITE); fl_font(label_font()->bold(), 10); fl_draw("NO ICON FOUND!", 1, 1, w()-2, h()-2, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP); } int X = w()-(w()/2)-(lwidth/2); int Y = h()+2; if(!label_trans) { fl_color(label_background); fl_rectf(X,Y,lwidth,lheight); } if(focused()) { focus_box()->draw(X, Y, lwidth, lheight, color(), 0); } fl_font(label_font(), label_size()); // A little shadow, from Dejan's request :) // SUCKS! /*fl_color(fl_darker(label_color())); fl_draw(label(), X-1, Y+1, lwidth, lheight, flags()); fl_draw(label(), X, Y+1, lwidth, lheight, flags()); */ fl_color(label_color()); fl_draw(label(), X, Y, lwidth, lheight, flags()); }
void Icon::draw(void) { Fl_Flags f = 0; if(is_focused()) f = FL_SELECTED; if(icon_img) icon_img->draw(0, 0, w(), h(),f); else { fl_color(FL_RED); fl_rect(0,0,w(),h()); fl_color(FL_BLACK); fl_rectf(1,1,w()-2,h()-2); fl_color(FL_WHITE); fl_font(label_font()->bold(), 10); fl_draw(_("NO ICON FOUND!"), 1, 1, w()-2, h()-2, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP); return; } if(globals->label_draw) { int X = w()-(w()/2)-(lwidth/2); int Y = h()+2; if(!globals->label_transparent) { fl_color(globals->label_background); fl_rectf(X,Y,lwidth,lheight); } if(is_focused()) focus_box()->draw(X, Y, lwidth, lheight, color(), 0); fl_font(label_font(), label_size()); fl_color(label_color()); fl_draw(label(), X, Y, lwidth, lheight, flags()); } }
void Fl_Roller::draw() { if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_HIGHLIGHT)) draw_box(); int X=0; int Y=0; int W=w(); int H=h(); box()->inset(X,Y,W,H); if (W<=0 || H<=0) return; double s = step(); if (!s) s = (maximum()-minimum())/100; int offset = int(value()/s); const double ARC = 1.5; // 1/2 the number of radians visible const double delta = .2; // radians per knurl if (type()==HORIZONTAL) { // draw shaded ends of wheel: int h1 = W/4+1; // distance from end that shading starts fl_color(button_color()); fl_rectf(X+h1,Y,W-2*h1,H); for (int i=0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X+h2,Y,h1-h2,H); fl_rectf(X+W-h1,Y,h1-h2,H); h1 = h2; } if (active_r()) { // draw ridges: double junk; for (double y = -ARC+modf(offset*sin(ARC)/(W/2)/delta,&junk)*delta;; y += delta) { int y1 = int((sin(y)/sin(ARC)+1)*W/2); if (y1 <= 0) continue; else if (y1 >= W-1) break; fl_color(FL_DARK3); fl_line(X+y1,Y+1,X+y1,Y+H-1); if (y < 0) y1--; else y1++; fl_color(FL_LIGHT1);fl_line(X+y1,Y+1,X+y1,Y+H-1); } // draw edges: h1 = W/8+1; // distance from end the color inverts fl_color(FL_DARK2); fl_line(X+h1,Y+H-1,X+W-h1,Y+H-1); fl_color(FL_DARK3); fl_line(X,Y+H,X,Y); fl_line(X,Y,X+h1,Y); fl_line(X+W-h1,Y,X+W,Y); fl_color(FL_LIGHT2); fl_line(X+h1,Y,X+W-h1,Y); fl_line(X+W,Y,X+W,Y+H); fl_line(X+W,Y+H,X+W-h1,Y+H); fl_line(X+h1,Y+H,X,Y+H); } } // vertical one else { offset = (1-offset); // draw shaded ends of wheel: int h1 = H/4+1; // distance from end that shading starts fl_color(button_color()); fl_rectf(X,Y+h1,W,H-2*h1); for (int i=0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X,Y+h2,W,h1-h2); fl_rectf(X,Y+H-h1,W,h1-h2); h1 = h2; } if (active_r()) { // draw ridges: double junk; for (double y = -ARC+modf(offset*sin(ARC)/(H/2)/delta,&junk)*delta; ; y += delta) { int y1 = int((sin(y)/sin(ARC)+1)*H/2); if (y1 <= 0) continue; else if (y1 >= H-1) break; fl_color(FL_DARK3); fl_line(X+1,Y+y1,X+W-1,Y+y1); if (y < 0) y1--; else y1++; fl_color(FL_LIGHT1);fl_line(X+1,Y+y1,X+W-1,Y+y1); } // draw edges: h1 = H/8+1; // distance from end the color inverts fl_color(FL_DARK2); fl_line(X+W-1,Y+h1,X+W-1,Y+H-h1); fl_color(FL_DARK3); fl_line(X+W,Y,X,Y); fl_line(X,Y,X,Y+h1); fl_line(X,Y+H-h1,X,Y+H); fl_color(FL_LIGHT2); fl_line(X,Y+h1,X,Y+H-h1); fl_line(X,Y+H,X+W,Y+H); fl_line(X+W,Y+H,X+W,Y+H-h1); fl_line(X+W,Y+h1,X+W,Y); } } if (focused()) { focus_box()->draw(0,0,w(),h(), FL_BLACK, FL_INVISIBLE); } }
void Fl_Slider::draw() { // figure out the inner size of the box: Fl_Boxtype box = this->box(); int ix = 0, iy = 0, iw = w(), ih = h(); box->inset(ix,iy,iw,ih); // figure out where to draw the slider, leaving room for tick marks: int sx = ix, sy = iy, sw = iw, sh = ih; if (tick_size_ && (type()&TICK_BOTH)) { if (horizontal()) { sh -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sy += tick_size_/2; break; case TICK_ABOVE: sy += tick_size_; break; } } else { sw -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sx += tick_size_/2; break; case TICK_ABOVE: sx += tick_size_; break; } } } Fl_Flags flags = 0; if (!active_r()) { flags.set(FL_INACTIVE); } else { if (Fl::pushed() == this) flags.set(FL_VALUE); if (belowmouse()) flags.set(FL_HIGHLIGHT); } if(!(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT)) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // minimal-update the slider, if it indicates the background needs // to be drawn, draw that. We draw the slot if the current box type // has no border: if (draw(sx, sy, sw, sh, flags, iy==0)) { if(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // draw the focus indicator inside the box: if (focused()) { focus_box()->draw(ix+1, iy+1, iw-2, ih-2, label_color(), FL_INVISIBLE); } if (type() & TICK_BOTH) { if (horizontal()) { switch (type()&TICK_BOTH) { case TICK_ABOVE: ih = sy+sh/2-iy; break; case TICK_BELOW: ih += iy; iy = sy+sh/2+(iy?0:3); ih -= iy; break; } } else { switch (type()&TICK_BOTH) { case TICK_ABOVE: iw = sx+sw/2-ix; break; case TICK_BELOW: iw += ix; ix = sx+sw/2+(iy?0:3); iw -= ix; break; } } Fl_Color color = text_color(); if (!active_r()) color = fl_inactive(color); fl_color(color); draw_ticks(ix, iy, iw, ih, (slider_size_+1)/2); } fl_pop_clip(); } }