コード例 #1
0
ファイル: edeskicon.cpp プロジェクト: GustavoMOG/ede12
void Icon::update_all()
{
    Fl_Config &iconConfig = *cfg;
    iconConfig.read_file(false);
    iconConfig.set_section("Desktop Entry");

    // Icon Label:
    icon_name = get_localized_name(iconConfig);
    tooltip(icon_name);
    label(icon_name);

    label_color(label_foreground);
    label_size(label_fontsize);

    lwidth = label_maxwidth; // This is a bit strange, but otherwise we get mysterious crashes...
    lheight= 0;
    fl_font(label_font(), label_size());
    fl_measure(icon_name, lwidth, lheight, FL_ALIGN_WRAP);
    lwidth += 4; //  height+= 4;

    // Icon file:
    iconConfig.read("Icon", icon_file, "folder.png");

    update_icon();

    redraw();
    //desktop->redraw();
}
コード例 #2
0
ファイル: mainmenu.cpp プロジェクト: edeproject/svn
void MainMenu::draw()
{
    Fl_Boxtype box = this->box();
    Fl_Flags flags;
    Fl_Color color = this->color();
    Fl_Color lcolor = label_color();

    if (!active_r())
        flags = FL_INACTIVE;
    else if (m_open)
        flags = FL_VALUE;
    else
        flags = 0;

    if (belowmouse()) {
        flags = flags|FL_HIGHLIGHT;
        color = fl_lighter(color);
        lcolor = fl_lighter(label_color());
        if(!color) color = this->color();
        if(!lcolor) color = this->label_color();
    } 
    box->draw(0, 0, this->w(), this->h(), color, flags);

    int X=0, Y=0, W=w(), H=h();
    box->inset(X,Y,W,H);

    if(image()) {
        int imY = (h()/2)-(image()->height()/2);
        image()->draw(6, imY, image()->width(), image()->height(), flags);
        X+=image()->width()+6;
    } else {
        X += 4;
        W -= 4;
    }

    fl_font(label_font(), label_size());
    label_type()->draw(label(), X, Y, W-X, H, lcolor, flags|FL_ALIGN_LEFT);
}
コード例 #3
0
ファイル: Button.cpp プロジェクト: JPGygax68/libCppGUI
    void Button_base::render(Canvas *c, const Point &offs)
    {
        auto p = offs + position();

        //draw_background_and_border(c, p, bounds(), visual_states());

        c->set_text_color(label_color(visual_states()));
        c->render_text(_font.get(), p.x /*+ _x_offs*/, p.y, _label.data(), _label.size());

        if (this->has_focus())
        {
            auto r = Rectangle{_label_bbox};
            r.inflate(2, 2); // TODO: make this configurable somewhere
            c->draw_stippled_rectangle_outline(p.x + r.pos.x, p.y + r.pos.y, r.ext.w, r.ext.h, {0, 0, 0.5f, 1});
        }
    }
コード例 #4
0
ファイル: edeskicon.cpp プロジェクト: GustavoMOG/ede12
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());
}
コード例 #5
0
ファイル: edeskicon.cpp プロジェクト: edeproject/svn
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());
    }
}
コード例 #6
0
ファイル: fl_labeltype.cpp プロジェクト: GustavoMOG/efltk
// 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);
			}
		}
	}
コード例 #7
0
ファイル: Fl_Slider.cpp プロジェクト: edeproject/efltk
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();
    }
}
コード例 #8
0
ファイル: edeskicon.cpp プロジェクト: edeproject/svn
Icon::Icon(const GlobalIconSettings* gs, IconSettings* s) : Fl_Widget(s->x, s->y, ICONSIZE, ICONSIZE, "")
{
	assert(gs != NULL);
	assert(s != NULL);

	/* GlobalIconSettings and IconSettings are shared
	 * via single object who is changed from eiconman.
	 * Since IconSettings are used more, we allocate for it.
	 */
	globals = gs;

	settings = new IconSettings;
	settings->name = s->name;
	settings->cmd  = s->cmd;
	settings->icon_path = s->icon_path;

	/* settings->x and settings->y are not needed
	 * since x() and y() have it.
	 */

	lwidth = lheight = 0;
	infocus = false;
	micon = NULL;

	popup = new Fl_Menu_Button(0, 0, 0, 0);
	// ?@?
	if(popup->parent())
		popup->parent()->remove(popup);
	popup->parent(0);
	popup->type(Fl_Menu_Button::POPUP3);
	popup->begin();

	const int off = 12;
	Fl_Item* openit = new Fl_Item(_("&Open"));
	openit->x_offset(off);

	Fl_Item* renameit = new Fl_Item(_("&Rename"));
	renameit->x_offset(off);
	renameit->callback(rename_cb, this);

	Fl_Item* deleteit = new Fl_Item(_("&Delete"));
	deleteit->x_offset(off);
	deleteit->callback(delete_cb, this);

	new Fl_Divider();

	Fl_Item* propit = new Fl_Item(_("&Properties"));
	propit->x_offset(off);
	propit->callback(prop_cb, this);

	popup->end();

	box(FL_NO_BOX);

	//tooltip(tt);

	copy_label(settings->name);
	label_color(globals->label_foreground);
	label_size(globals->label_fontsize);
	align(FL_ALIGN_CENTER|FL_ALIGN_WRAP);
	update_label_size();

	icon_img = Fl_Image::read(settings->icon_path, 0);
}
コード例 #9
0
void LLHUDNameTag::renderText(BOOL for_select)
{
	if (!mVisible || mHidden)
	{
		return;
	}

	// don't pick text that isn't bound to a viewerobject
	if (for_select && 
		(!mSourceObject || mSourceObject->mDrawable.isNull()))
	{
		return;
	}
	
	if (for_select)
	{
		gGL.getTexUnit(0)->disable();
	}
	else
	{
		gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
	}

	LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE);
	LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE);
	
	LLColor4 shadow_color(0.f, 0.f, 0.f, 1.f);
	F32 alpha_factor = 1.f;
	LLColor4 text_color = mColor;
	if (mDoFade)
	{
		if (mLastDistance > mFadeDistance)
		{
			alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange);
			text_color.mV[3] = text_color.mV[3]*alpha_factor;
		}
	}
	if (text_color.mV[3] < 0.01f)
	{
		return;
	}
	shadow_color.mV[3] = text_color.mV[3];

	mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));

	// *TODO: cache this image
	// <FS:Ansariel> Performance improvement
	//LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Rect");

	// *TODO: make this a per-text setting
	//LLColor4 bg_color = LLUIColorTable::instance().getColor("NameTagBackground");
	//bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor);

	static LLUIColor s_bg_color = LLUIColorTable::instance().getColor("NameTagBackground");
	static LLCachedControl<F32> chatBubbleOpacity(gSavedSettings, "ChatBubbleOpacity");
	LLColor4 bg_color = s_bg_color.get();
	F32 color_alpha = chatBubbleOpacity * alpha_factor;
	bg_color.setAlpha(color_alpha);
	// </FS:Ansariel>

	// scale screen size of borders down
	//RN: for now, text on hud objects is never occluded

	LLVector3 x_pixel_vec;
	LLVector3 y_pixel_vec;
	
	LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec);

	LLVector3 width_vec = mWidth * x_pixel_vec;
	LLVector3 height_vec = mHeight * y_pixel_vec;

	mRadius = (width_vec + height_vec).magVec() * 0.5f;

	LLCoordGL screen_pos;
	LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE);

	LLVector2 screen_offset = updateScreenPos(mPositionOffset);

	LLVector3 render_position = mPositionAgent  
			+ (x_pixel_vec * screen_offset.mV[VX])
			+ (y_pixel_vec * screen_offset.mV[VY]);

	LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
	LLRect screen_rect;
	screen_rect.setCenterAndSize(0, static_cast<S32>(lltrunc(-mHeight / 2 + mOffsetY)), static_cast<S32>(lltrunc(mWidth)), static_cast<S32>(lltrunc(mHeight)));
	// <FS:Ansariel> Performance improvement
	//imagep->draw3D(render_position, x_pixel_vec, y_pixel_vec, screen_rect, bg_color);
	mRoundedRectImg->draw3D(render_position, x_pixel_vec, y_pixel_vec, screen_rect, bg_color);
	// </FS:Ansariel>
	if (mLabelSegments.size())
	{
		// <FS:Ansariel> Performance improvement
		//LLUIImagePtr rect_top_image = LLUI::getUIImage("Rounded_Rect_Top");
		LLRect label_top_rect = screen_rect;
		const S32 label_height = ll_round((mFontp->getLineHeight() * (F32)mLabelSegments.size() + (VERTICAL_PADDING / 3.f)));
		label_top_rect.mBottom = label_top_rect.mTop - label_height;
		LLColor4 label_top_color = text_color;
		// <FS:Ansariel> Performance improvement
		//label_top_color.mV[VALPHA] = gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor;
		label_top_color.mV[VALPHA] = color_alpha;
		// </FS:Ansariel>

		// <FS:Ansariel> Performance improvement
		//rect_top_image->draw3D(render_position, x_pixel_vec, y_pixel_vec, label_top_rect, label_top_color);
		mRoundedRectTopImg->draw3D(render_position, x_pixel_vec, y_pixel_vec, label_top_rect, label_top_color);
		// </FS:Ansariel>
	}

	F32 y_offset = (F32)mOffsetY;
		
	// Render label
	{
		//gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);

		for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin();
			segment_iter != mLabelSegments.end(); ++segment_iter )
		{
			// Label segments use default font
			const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp;
			y_offset -= fontp->getLineHeight();

			F32 x_offset;
			if (mTextAlignment == ALIGN_TEXT_CENTER)
			{
				x_offset = -0.5f*segment_iter->getWidth(fontp);
			}
			else // ALIGN_LEFT
			{
				x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f);
			}

			LLColor4 label_color(0.f, 0.f, 0.f, 1.f);
			label_color.mV[VALPHA] = alpha_factor;
			hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, FALSE);
		}
	}

	// Render text
	{
		// -1 mMaxLines means unlimited lines.
		S32 start_segment;
		S32 max_lines = getMaxLines();

		if (max_lines < 0) 
		{
			start_segment = 0;
		}
		else 
		{
			start_segment = llmax((S32)0, (S32)mTextSegments.size() - max_lines);
		}

		for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment;
			 segment_iter != mTextSegments.end(); ++segment_iter )
		{
			const LLFontGL* fontp = segment_iter->mFont;
			y_offset -= fontp->getLineHeight();
			y_offset -= LINE_PADDING;

			U8 style = segment_iter->mStyle;
			LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW;
	
			F32 x_offset;
			if (mTextAlignment== ALIGN_TEXT_CENTER)
			{
				x_offset = -0.5f*segment_iter->getWidth(fontp);
			}
			else // ALIGN_LEFT
			{
				x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f);

				// *HACK
				x_offset += 1;
			}

			text_color = segment_iter->mColor;
			text_color.mV[VALPHA] *= alpha_factor;

			hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, FALSE);
		}
	}
	/// Reset the default color to white.  The renderer expects this to be the default. 
	gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f);
	if (for_select)
	{
		gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
	}
}
コード例 #10
0
ファイル: listbox_factory.cpp プロジェクト: Syntaf/GG
    void create_widget(const dictionary_t& parameters,
                       size_enum_t,
                       listbox_t*& listbox)
    {
        std::string name;
        std::string alt_text;
        long characters(25);
        long rows(0);
        bool sort(false);
        name_t sort_order("ascending");
        name_t selections("single");
        bool user_delete(false);
        bool browse_updates(false);
        array_t items;
        listbox_t::item_set_t item_set;
        GG::Clr color(GG::CLR_GRAY);
        GG::Clr interior_color(GG::CLR_ZERO);
        GG::Clr hilite_color(GG::CLR_SHADOW);
        GG::Clr label_color(GG::CLR_BLACK);
        GG::Clr item_text_color(GG::CLR_BLACK);
        name_t signal_id;
        array_t allowed_drop_types;

        implementation::get_localized_string(parameters, key_name, name);
        implementation::get_localized_string(parameters, key_alt_text, alt_text);
        get_value(parameters, key_characters, characters);
        get_value(parameters, static_name_t("rows"), rows);
        get_value(parameters, static_name_t("sort"), sort);
        get_value(parameters, static_name_t("sort_order"), sort_order);
        get_value(parameters, static_name_t("selections"), selections);
        get_value(parameters, static_name_t("user_delete"), user_delete);
        get_value(parameters, static_name_t("browse_updates"), browse_updates);
        get_value(parameters, key_items, items);
        implementation::get_color(parameters, static_name_t("color"), color);
        implementation::get_color(parameters, static_name_t("interior_color"), interior_color);
        implementation::get_color(parameters, static_name_t("hilite_color"), hilite_color);
        implementation::get_color(parameters, static_name_t("label_color"), label_color);
        implementation::get_color(parameters, static_name_t("item_text_color"), item_text_color);
        get_value(parameters, static_name_t("signal_id"), signal_id);
        get_value(parameters, static_name_t("allowed_drop_types"), allowed_drop_types);

        GG::Flags<GG::ListBoxStyle> style;
        if (!sort)
            style |= GG::LIST_NOSORT;

        get_sort_order_style(sort_order, style);
        get_selection_style(selections, style);

        if (user_delete)
            style |= GG::LIST_USERDELETE;

        if (browse_updates)
            style |= GG::LIST_BROWSEUPDATES;

        for (array_t::iterator first(items.begin()), last(items.end()); first != last; ++first) {
            item_set.push_back(any_regular_t(first->cast<dictionary_t>()));
            dictionary_t& back = item_set.back().cast<dictionary_t>();
            get_value(back, key_value);
            dictionary_t::iterator it = back.find(key_name);
            if (it != back.end() && it->second.type_info() == type_info<adobe::string_t>()) {
                it->second.assign(localization_invoke(it->second.cast<std::string>()));
            }
        }

        if (!rows && items.empty())
            rows = 8;

        std::vector<std::string> drop_types;
        for (array_t::iterator first(allowed_drop_types.begin()), last(allowed_drop_types.end()); first != last; ++first) {
            drop_types.push_back(first->cast<std::string>());
        }

        listbox = new listbox_t(name,
                                alt_text,
                                characters,
                                rows,
                                style,
                                item_set,
                                color,
                                interior_color,
                                hilite_color,
                                label_color,
                                item_text_color,
                                drop_types,
                                signal_id);
    }