void Fl_Input_Browser::draw() { Fl_Flags f = flags(); if (!active_r()) f.set(FL_INACTIVE); //minw_ = w(); if (damage()&FL_DAMAGE_ALL) draw_frame(); int X = 0, Y = 0, W = w(), H = h(); box()->inset(X, Y, W, H); int W1 = H*4/5; if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_CHILD)) { input()->resize(X, Y, W-W1, H); input()->set_damage(FL_DAMAGE_ALL); input()->copy_style(style()); // force it to use this style input()->box(FL_FLAT_BOX); // fix for relative coordinates fl_push_matrix(); fl_translate(X,Y); input()->draw(); fl_pop_matrix(); input()->set_damage(0); } if(damage()&(FL_DAMAGE_ALL|FL_DAMAGE_VALUE|FL_DAMAGE_HIGHLIGHT)) { if(over_now) f.set(FL_HIGHLIGHT); X += W-W1; W = W1; button_box(FL_DIV_UP_BOX); // draw the little mark at the right: draw_glyph(FL_GLYPH_DOWN_BUTTON, X, Y, W, H, f); over_last = over_now; } }
void Fl_Tool_Bar::draw() { int n; if(opened()) { // make it not draw the inside label: int saved = flags(); align(FL_ALIGN_TOP); if(damage() & ~FL_DAMAGE_CHILD) { draw_frame(); fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh()); for (n = children(); n--;) draw_child(*child(n)); draw_box(); draw_inside_label(); fl_pop_clip(); if(m_menubut->visible()) { fl_push_clip(w()-box()->dw()-(m_menubut->visible()?20:0), box()->dy(), 30, h()-box()->dh()); draw_child(*m_menubut); draw_box(); fl_pop_clip(); } for (n = 0; n < children(); n++) draw_outside_label(*child(n)); } else { fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh()); for(n = 0; n < children(); n++) { Fl_Widget& w = *child(n); if (w.damage() & FL_DAMAGE_CHILD_LABEL) { draw_outside_label(w); w.set_damage(w.damage() & ~FL_DAMAGE_CHILD_LABEL); } update_child(w); } fl_pop_clip(); } flags(saved); if (damage() & (FL_DAMAGE_EXPOSE|FL_DAMAGE_HIGHLIGHT|FL_DAMAGE_ALL)) { Fl_Flags f = 0; if (pushed) f.set(FL_VALUE); if (highlighted) f.set(FL_HIGHLIGHT); draw_glyph(0, 0, 0, glyph_size(), h(), f); } } else Fl_Bar::draw(); }
static void glyph(const Fl_Widget* widget, int glyph, int x,int y,int w,int h, Fl_Flags flags) { if (!glyph) flags.clear(FL_VALUE); Fl_Widget::default_glyph(widget, glyph, x, y, w, h, flags); // draw the divider line into slider: if (!glyph) { if (w < 4 || h < 4) return; // ignore FILL widgets if (!((Fl_Slider*)widget)->slider_size()) return; if (widget->type()&1) // horizontal { x = x+(w+1)/2; fl_color(FL_DARK3); fl_line(x-1, y+1, x-1, y+h-2); fl_color(FL_LIGHT3); fl_line(x, y+1, x, y+h-2); } else { y = y+(h+1)/2; fl_color(FL_DARK3); fl_line(x+1, y-1, x+w-2, y-1); fl_color(FL_LIGHT3); fl_line(x+1, y, x+w-2, y); } } }
// Anybody can call this to force the label to draw anywhere, this is // used by Fl_Group and Fl_Tabs to draw outside labels: void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Flags flags) const { fl_font(label_font(), float(label_size())); if (!active_r()) flags.set(FL_INACTIVE); Fl_Color color; // Figure out if alignment puts the label inside the widget: if (!(this->flags()&15) || (this->flags() & FL_ALIGN_INSIDE)) { // yes, inside label is affected by selection or highlight: if (flags&FL_SELECTED) color = selection_text_color(); else if (flags&FL_HIGHLIGHT && highlight_label_color()) color = highlight_label_color(); else color = label_color(); if (focused()) flags.set(FL_SELECTED); } else { color = label_color(); } if (flags & FL_ALIGN_CLIP) fl_push_clip(X, Y, W, H); if (image_) { fl_color(fl_inactive(color, flags)); if(flags & FL_ALIGN_TILED || flags & FL_ALIGN_SCALE) { image_->draw(X, Y, W, H, flags); } else { int w = W; int h = H; image_->measure(w, h); // If all the flags are off, draw the image and label centered "nicely" // by measuring their total size and centering that rectangle: if (!(flags & (FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM| FL_ALIGN_INSIDE)) && !label_.empty()) { int d = (H-int(h+fl_height()))>>1; if (d >= 0) { // put the image atop the text Y += d; H -= d; flags.set(FL_ALIGN_TOP); } else { // put image to left int text_w = W; int text_h = H; fl_measure(label_.c_str(), text_w, text_h, flags); int d = (W-(h+text_w))>>1; if (d > 0) {X += d; W -= d;} flags.set(FL_ALIGN_LEFT); } } int cx,cy; // point in image to put at X,Y if (flags & FL_ALIGN_RIGHT) { cx = w-W; if (flags & FL_ALIGN_LEFT && cx < 0) cx = 0; } else if (flags & FL_ALIGN_LEFT) cx = 0; else cx = w/2-W/2; if (flags & FL_ALIGN_BOTTOM) { cy = h-H; if (flags & FL_ALIGN_TOP && cy < 0) cy = 0; } else if (flags & FL_ALIGN_TOP) cy = 0; else cy = h/2-H/2; image_->draw(X-cx, Y-cy, W, H, 0,0,0,0,flags); // figure out the rectangle that remains for text: if (flags & FL_ALIGN_LEFT) { X += (w+2); W -= (w+4); } else if (flags & FL_ALIGN_RIGHT) W -= (w+4); else if (flags & FL_ALIGN_TOP) {Y += h; H -= h;} else if (flags & FL_ALIGN_BOTTOM) H -= h; else { /*flags |= FL_ALIGN_TOP;*/ Y += (h-cy); H -= (h-cy); } } }
bool Fl_Slider::draw(int ix, int iy, int iw, int ih, Fl_Flags flags, bool slot) { // for back compatability, use type flag to set slider size: if (type()&FILL) slider_size(0); // if user directly set selected_color we use it: if (style()->selection_color) flags.set(FL_SELECTED); // figure out where the slider should be: int sx = ix, sy = iy, sw = iw, sh = ih; int sp; if (horizontal()) { sx = sp = ix+slider_position(value(),iw); sw = slider_size_; if (!sw) // fill slider { sw = sx-ix; sx = ix; } } else { sy = sp = iy+slider_position(value(),ih); sh = slider_size_; if (!sh) sh = iy+ih-sy; // fill slider } if (damage()&FL_DAMAGE_ALL) { fl_push_clip(0, 0, w(), h()); // draw the slider draw_glyph(0, sx, sy, sw, sh, flags); // clip out the area of the slider fl_clip_out(sx, sy, sw, sh); } else if (sp != old_position) { // update a moving slider: // draw slider in new position draw_glyph(0, sx, sy, sw, sh, flags); // clip to the region the old slider was in: if (horizontal()) { if (slider_size_) fl_push_clip(old_position, sy, sw, sh); else fl_push_clip(ix, iy, old_position, ih); } else { if (slider_size_) fl_push_clip(sx, old_position, sw, sh); else fl_push_clip(ix, old_position, iw, iy+ih-old_position); } // don't erase new slider fl_clip_out(sx, sy, sw, sh); } else { // update for the highlight turning on/off if (damage() & FL_DAMAGE_HIGHLIGHT) draw_glyph(0, sx, sy, sw, sh, flags); // otherwise no changes return false; } old_position = sp; // we draw a slot if it seems the box has no border: if (slot) { const int slot_size_ = 6; int slx, sly, slw, slh; int dx = (slider_size_-slot_size_)/2; if (dx < 0) dx = 0; if (horizontal()) { slx = dx; slw = iw-2*dx; slx += ix; sly = iy+(ih-slot_size_+1)/2; slh = slot_size_; } else { sly = dx; slh = ih-2*dx; sly += iy; slx = ix+(iw-slot_size_+1)/2; slw = slot_size_; } button_box()->draw(slx, sly, slw, slh, FL_BLACK, flags&FL_INACTIVE|FL_VALUE); fl_clip_out(slx, sly, slw, slh); } return true; }
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(); } }
// Draw button-like widgets with an optional glyph. The glyph is given // a size (negative to put it on the right) void Fl_Button::draw(int glyph, int glyph_width) const { // Figure out the colors to use. The flags are used by the label and // glyph functions to figure out their colors: Fl_Flags flags; Fl_Color color; if (!active_r()) { flags = FL_INACTIVE; color = this->color(); } else if (belowmouse()) { flags = FL_HIGHLIGHT; color = highlight_color(); if (!color) color = this->color(); } else { flags = 0; color = this->color(); } Fl_Flags glyph_flags = flags; if (glyph_width) { if (this == held_down) flags.set(FL_VALUE); if (value()) glyph_flags.set(FL_VALUE); } else if (value()) { flags.set(FL_VALUE); // Use the pushed-in color if the user has explicitly set it // on this widget: if (style()->selection_color) { color = style()->selection_color; flags.set(FL_SELECTED); // this makes label use selected_text_color() } } bool draw_label = true; int x = 0, y = 0, w = this->w(), h = this->h(); if (box() == FL_NO_BOX) { // If the box is FL_NO_BOX we need to avoid drawing the label so // that it does not blink and does not draw multiple times (which // will make it look bold if antialiasing is on). /* if (!label()) { // don't do anything if no label, so buttons that are an image // only will redraw correctly and with minimum blinking. } else */ if ((damage()&FL_DAMAGE_EXPOSE) || (damage()&FL_DAMAGE_HIGHLIGHT) && !focused()) { // erase the background behind where the label will draw: fl_push_clip(0, 0, w, h); parent()->draw_group_box(); fl_pop_clip(); } else { // Don't draw the label unnecessarily: draw_label = false; } } else { bool drawed = false; if(image() && !image()->get_mask()) { if((align()&FL_ALIGN_TILED || align()&FL_ALIGN_SCALE) && ( !(align()&(FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM)) || (align()&FL_ALIGN_INSIDE) ) ) { // We can draw only frame, if drawing image tiled or scale // And no mask defined to image... draw_frame(); drawed = true; } } if(!drawed) { if (damage()&FL_DAMAGE_EXPOSE && !box()->fills_rectangle()) { fl_push_clip(0, 0, w, h); parent()->draw_group_box(); fl_pop_clip(); } // Draw the box: box()->draw(0, 0, w, h, color, flags); } box()->inset(x,y,w,h); } if (glyph_width < 0) { int g = -glyph_width; draw_glyph(glyph, x+w-g-3, y+((h-g)>>1), g, g, glyph_flags); if (draw_label) draw_inside_label(x, y, w-g-3, h, flags); }
static void glyph(const Fl_Widget* widget, int glyph, int x,int y,int w,int h, Fl_Flags flags) { if (!glyph) flags.clear(FL_VALUE); Fl_Widget::default_glyph(widget, glyph, x, y, w, h, flags); }