Пример #1
0
void TaskButton::draw(void) {
	Fl_Color col = value() ? selection_color() : color();
	draw_box(value() ? (down_box() ? down_box() : fl_down(box())) : box(), col);

	if(image()) {
		int X, Y, lw, lh;

		X = x() + 5;
		Y = (y() + h() / 2) - (image()->h() / 2);
		image()->draw(X, Y);

		X += image()->w() + 5;

		if(label()) {
			fl_font(labelfont(), labelsize());
			fl_color(labelcolor());

			lw = lh = 0;
			fl_measure(label(), lw, lh, 0);

			/* use clipping so long labels do not be drawn on the right border, which looks ugly */
			fl_push_clip(x() + Fl::box_dx(box()), 
						 y() + Fl::box_dy(box()), 
						 w() - Fl::box_dw(box()) - 5, 
						 h() - Fl::box_dh(box()));

			Y = (y() + h() / 2) - (lh / 2);
			fl_draw(label(), X, Y, lw, lh, align(), 0, 0);

			fl_pop_clip();
		}
	} else {
		draw_label();
	}

	if(Fl::focus() == this)
		draw_focus();
}
Пример #2
0
 FL_EXPORT_C(Fl_Boxtype, fl_downC)(Fl_Boxtype b) { return fl_down(b);}
Пример #3
0
void myscroll::draw() {
	draw_box();

	int X = x()+Fl::box_dx(box());
	int Y = y()+Fl::box_dy(box());
	int W = w()-Fl::box_dw(box());
	int H = h()-Fl::box_dh(box());

	if (horizontal()) {
		if (W < 3*H) {Fl_Slider::draw(X,Y,W,H); return;}
		Fl_Slider::draw(X+H,Y,W-2*H,H);

		// Buttons
		draw_box(button1 ? fl_down(slider()) : slider(),
			 X, Y, H, H, selection_color());
		draw_box(button2 ? fl_down(slider()) : slider(),
			 X+W-H, Y, H, H, selection_color());
		if (active_r())
			fl_color(labelcolor());
		else
			fl_color(fl_inactive(labelcolor()));
		int w1 = (H-4)/3; if (w1 < 1) w1 = 1;
		int x1 = X+(H-w1-1)/2;
		int yy1 = Y+(H-2*w1-1)/2;
		if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1-1, yy1+w1,
					x1+w1, yy1);
			x1 += (W-H);
			fl_polygon(x1, yy1, x1+1, yy1+w1, x1, yy1+2*w1, x1+w1,
					yy1+w1);
		} else {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1, yy1);
			x1 += (W-H);
			fl_polygon(x1, yy1, x1, yy1+2*w1, x1+w1, yy1+w1);
		}
	} else { // vertical
		if (H < 3*W) {Fl_Slider::draw(X,Y,W,H); return;}
		Fl_Slider::draw(X,Y+W,W,H-2*W);

		// Buttons
		draw_box(button1 ? fl_down(slider()) : slider(),
			 X, Y, W, W, selection_color());
		draw_box(button2 ? fl_down(slider()) : slider(),
			 X, Y+H-W, W, W, selection_color());
		if (active_r())
			fl_color(labelcolor());
		else
			fl_color(fl_inactive(labelcolor()));
		int w1 = (W-4)/3; if (w1 < 1) w1 = 1;
		int x1 = X+(W-2*w1-1)/2;
		int yy1 = Y+(W-w1-1)/2;
		if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+w1-1, x1+2*w1, yy1+w1, x1+w1,
					yy1);
			yy1 += H-W;
			fl_polygon(x1, yy1, x1+w1, yy1+1, x1+w1, yy1+w1);
			fl_polygon(x1+w1, yy1+1, x1+2*w1, yy1, x1+w1, yy1+w1);
		} else {
			fl_polygon(x1, yy1+w1, x1+2*w1, yy1+w1, x1+w1, yy1);
			yy1 += H-W;
			fl_polygon(x1, yy1, x1+w1, yy1+w1, x1+2*w1, yy1);
		}
	}
}