本文整理汇总了C++中Fl_Image::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Image::draw方法的具体用法?C++ Fl_Image::draw怎么用?C++ Fl_Image::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Image
的用法示例。
在下文中一共展示了Fl_Image::draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw() {
if(!(damage()&FL_DAMAGE_ALL)) return;
int X=0,Y=0,W=w(),H=h();
box()->inset(X,Y,W,H);
if(image()) {
draw_frame();
fl_push_clip(X,Y,W,H);
Fl_Image *im = image();
W=im->width();
H=im->height();
int pbw = w() - 10;
int pbh = h() - 10;
if(W > pbw || H > pbh) {
W = pbw;
H = W * im->height() / im->width();
if(H > pbh) {
H = pbh;
W = H * im->width() / im->height();
}
}
X=(w()/2)-W/2;
Y=(h()/2)-H/2;
if(X<5) X=5;
if(Y<5) Y=5;
im->mask_type(MASK_NONE);
im->draw(X,Y,W,H,FL_ALIGN_SCALE);
fl_clip_out(X,Y,W,H);
X=0,Y=0,W=w(),H=h();
box()->inset(X,Y,W,H);
fl_color(color());
fl_rectf(X,Y,W,H);
fl_pop_clip();
} else {
draw_box();
if(w()<=120) label_size(8);
if(w()>120) label_size(10);
if(w()>180) label_size(12);
if(w()>250) label_size(14);
if(label()[0]=='?'&&label()[1]=='\0') label_size(100);
draw_label(X, Y, W, H, align());
}
}
示例2: draw
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());
}
示例3: draw
void DesktopIcon::draw(void) {
// draw_box(FL_UP_BOX, FL_BLACK);
if(image() && (damage() & FL_DAMAGE_ALL)) {
Fl_Image* im = image();
/* center image in the box */
int ix = (w()/2) - (im->w()/2);
int iy = (h()/2) - (im->h()/2);
ix += x();
iy += y();
/* darker_img is always present if image() is present */
if(is_focused())
darker_img->draw(ix, iy);
else
im->draw(ix, iy);
E_DEBUG(E_STRLOC ": DesktopIcon icon redraw\n");
}
if(gsettings->label_draw && (damage() & (FL_DAMAGE_ALL | EDAMAGE_CHILD_LABEL))) {
int X = x() + w()-(w()/2)-(lwidth/2);
int Y = y() + h() + LABEL_OFFSET;
Fl_Color old = fl_color();
if(!gsettings->label_transparent) {
fl_color(gsettings->label_background);
fl_rectf(X, Y, lwidth, lheight);
}
int old_font = fl_font();
int old_font_sz = fl_size();
/* draw with icon's font */
fl_font(labelfont(), labelsize());
/* pseudo-shadow */
fl_color(FL_BLACK);
fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);
fl_color(gsettings->label_foreground);
fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);
/* restore old font */
fl_font(old_font, old_font_sz);
if(is_focused()) {
/* draw focused box on our way so later this can be used to draw customised boxes */
fl_color(gsettings->label_foreground);
fl_line_style(FL_DOT);
fl_push_matrix();
fl_begin_loop();
fl_vertex(X, Y);
fl_vertex(X + lwidth, Y);
fl_vertex(X + lwidth, Y + lheight);
fl_vertex(X, Y + lheight);
fl_vertex(X, Y);
fl_end_loop();
fl_pop_matrix();
/* revert to default line style */
fl_line_style(0);
}
/* revert to old color whatever that be */
fl_color(old);
E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
}
}
示例4: draw
void tabbar::draw() {
const u32 startx = x();
const u32 endx = x() + w() - 1;
const u32 gradarea = h() - 2;
u32 i, j;
// bg
u32 r1 = 63, g1 = 72, b1 = 81;
u32 r2 = 38, g2 = 48, b2 = 59;
for (i = 0; i <= gradarea; i++) {
const float pos = i / (float) gradarea;
fl_color(mix(r1, r2, pos),
mix(g1, g2, pos),
mix(b1, b2, pos));
const u32 posy = y() + 1 + i;
fl_line(startx, posy, endx, posy);
}
// Borders
fl_color(37, 46, 52);
fl_line(startx, y(), endx, y());
fl_line(startx, y() + h() - 1, endx, y() + h() - 1);
// Tabs
u32 max;
u32 tabw = calctabw(&max, w());
bool highborder = false;
if ((mousex - x()) % tabw > tabw / 2)
highborder = true;
u32 posx = x();
const u32 lowy = y();
const u32 highy = y() + h() - 1;
for (i = 0; i < max; i++) {
bool hover = false;
// Borders
fl_color(FL_BLACK);
if (!i)
fl_line(posx, lowy, posx, highy);
fl_line(posx + tabw, lowy, posx + tabw, highy);
// Bg
r1 = 83, g1 = 92, b1 = 101;
r2 = 58, g2 = 68, b2 = 79;
if (i == g->curtab) {
r1 = 100, g1 = 160, b1 = 191;
r2 = 42, g2 = 100, b2 = 125;
} else if ((mousein && mousex >= posx && mousex <= (posx + tabw - 1)) ||
(!firstpress && longorder.size() && longorder[longpress] == i)) {
r1 = 150, g1 = 150, b1 = 191;
r2 = 100, g2 = 100, b2 = 155;
hover = true;
}
if (dragging && mousein && mousex >= posx && mousex <= (posx + tabw - 1)) {
fl_color(FL_WHITE);
if (!highborder)
fl_line(posx, lowy, posx, highy);
else
fl_line(posx + tabw, lowy, posx + tabw, highy);
}
for (j = 0; j <= gradarea; j++) {
const float pos = j / (float) gradarea;
fl_color(mix(r1, r2, pos),
mix(g1, g2, pos),
mix(b1, b2, pos));
const u32 posy = y() + 1 + j;
fl_line(posx + 1, posy, posx + tabw - 1, posy);
}
// Icon
Fl_Image *img = g->tabs[i].icon;
if (!img)
img = Fl_Shared_Image::get("newtab.png");
const u32 imgy = y() + (h() - 16) / 2;
img->draw(posx + 4, imgy, 16, 16);
// Text
fl_color(200, 200, 200);
if (i == g->curtab)
fl_color(FL_WHITE);
else if (hover)
fl_color(230, 230, 230);
fl_font(labelfont(), labelsize());
char tmp[80];
memset(tmp, 0, 80);
strncpy(tmp, g->tabs[i].title(), 79);
int textw = 0, texth = 0;
fl_measure(tmp, textw, texth, 0);
//.........这里部分代码省略.........