Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
MainMenu::MainMenu()
    : Fl_Menu_Button(0,0,0,0, "Start")
{
    layout_align(FL_ALIGN_LEFT);

    label_font(label_font()->bold());
    label_size(label_size()+2);

    m_modified = 0;
    e_image = 0;
    m_open = false;

    bool showusername;
    pGlobalConfig.get("Panel", "ShowUsernameOnMenu", showusername, false);
    struct passwd *PWD;
    /* Search for an entry with a matching user ID.  */
    PWD = getpwuid(getuid());
    if(showusername && PWD && PWD->pw_name && *PWD->pw_name) {
        label(PWD->pw_name);
    } else {
        label("EDE");
    }
    
    tooltip(_("Welcome to the Equinox Desktop Environment."));
}
Ejemplo n.º 3
0
    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());
        }
    }
Ejemplo n.º 4
0
void Panel3D::set_control_group(int xoffset, int yoffset, clan::Slider *&slider,
			clan::Spin *&spin, clan::Label *&label, const char *label_name, 
			float min_value, float max_value, float step_value, float initial_value)
{
	clan::Size label_size(100, 15);

	slider = new clan::Slider(this);
	slider->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 17)));
	slider->set_vertical(false);
	slider->set_horizontal(true);
	slider->set_min(0);
	slider->set_max(1000);
	slider->set_tick_count(2);
	slider->set_page_step(100);
	slider->set_position(50);
	slider->set_lock_to_ticks(false);
	slider->func_value_changed().set(this, &Panel3D::on_slider_changed, slider);

	spin = new clan::Spin(this);
	spin->set_geometry(clan::Rect(xoffset+115, yoffset, clan::Size(64, 21)));
	spin->set_number_of_decimal_places(2);
	spin->set_floating_point_mode(true);
	spin->set_value_float(initial_value);
	spin->set_step_size_float(step_value);
	spin->set_ranges_float(min_value, max_value);
	spin->func_value_changed().set(this, &Panel3D::on_spin_changed, spin);

	label = new clan::Label(this);
	label->set_geometry(clan::Rect(xoffset+185, yoffset, label_size));
	label->set_text(label_name);

	set_slider_to_spin(slider, spin);
}
Ejemplo n.º 5
0
void Fl_TooltipBox::layout()
{
    fl_font(label_font(), label_size());
    int ww, hh;
    ww = MAX_WIDTH;
    fl_measure(tip, ww, hh, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE);
    ww += 6; hh += 6;

    // find position on the screen of the widget:
    int ox = Fl::event_x_root();
    //int ox = X+W/2;
    int oy = Y + H+2;
    for (Fl_Widget* p = widget; p; p = p->parent())
    {
        //ox += p->x();
        oy += p->y();
    }
    if (ox+ww > Fl::w()) ox = Fl::w() - ww;
    if (ox < 0) ox = 0;
    if (H > 30)
    {
        oy = Fl::event_y_root()+13;
        if (oy+hh > Fl::h()) oy -= 23+hh;
    }
    else
    {
        if (oy+hh > Fl::h()) oy -= (4+hh+H);
    }
    if (oy < 0) oy = 0;

    resize(ox, oy, ww, hh);
    Fl_Menu_Window::layout();
}
Ejemplo n.º 6
0
void Icon::update_label_size(void)
{
    lwidth = globals->label_maxwidth;
    lheight= 0;
    fl_font(label_font(), label_size());
    fl_measure(label(), lwidth, lheight, FL_ALIGN_WRAP);

    lwidth += 8;
	lheight += 4;
}
Ejemplo n.º 7
0
textlabel_t	*make_label(char *str, double fontsize, char *fontname, char *fontcolor, graph_t *g)
{
	textlabel_t	*rv = NEW(textlabel_t);
	rv->text = str;
	rv->fontname = fontname;
	rv->fontcolor = fontcolor;
	rv->fontsize = (float)fontsize;
	label_size(str,rv,g);
	return rv;
}
Ejemplo n.º 8
0
PushButton::PushButton(GUI *gui) : 
	CL_Window(&gui->get_gui_manager(), CL_GUITopLevelDescription("PushButton", CL_Rect(256 + 16, 256 + 16, CL_Size(256, 180)), false)),
	gui(gui)
{
	CL_GraphicContext gc = gui->get_window()->get_gc();
	test_image = CL_Image(gc, "tux", &gui->get_resources_internal());

	set_draggable(true);

	CL_Rect client_area = get_client_area();

	pushbutton1 = new CL_PushButton(this);
	pushbutton1->set_geometry(CL_Rect(client_area.left + 11, client_area.top + 10, CL_Size(128, 40)));
	pushbutton1->set_text("Push Button");
	pushbutton1->set_flat(false);
	pushbutton1->func_clicked().set(this, &PushButton::on_clicked, pushbutton1);

	int label_xpos = client_area.left + 31;
	int yoffset = client_area.top + 80;
	CL_Size label_size(50, 15);
	const int gap = 16;

	checkbox_flat = new CL_CheckBox(this);
	checkbox_flat->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_flat->func_checked().set(this, &PushButton::on_checked_flat, checkbox_flat);
	checkbox_flat->func_unchecked().set(this, &PushButton::on_unchecked_flat, checkbox_flat);
	checkbox_flat->set_text("Flat");

	yoffset+=gap;
	checkbox_icon = new CL_CheckBox(this);
	checkbox_icon->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_icon->func_checked().set(this, &PushButton::on_checked_icon, checkbox_icon);
	checkbox_icon->func_unchecked().set(this, &PushButton::on_unchecked_icon, checkbox_icon);
	checkbox_icon->set_text("Icon");

	yoffset+=gap;
	checkbox_toggle = new CL_CheckBox(this);
	checkbox_toggle->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_toggle->func_checked().set(this, &PushButton::on_checked_toggle, checkbox_toggle);
	checkbox_toggle->func_unchecked().set(this, &PushButton::on_unchecked_toggle, checkbox_toggle);
	checkbox_toggle->set_text("Enable Toggle");

	yoffset+=gap;
	checkbox_disable = new CL_CheckBox(this);
	checkbox_disable->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_disable->func_checked().set(this, &PushButton::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &PushButton::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");

	int xoffset = client_area.left + 36;
	yoffset = client_area.top + 60;

	info_clicked = new Info(gui, this);
	info_clicked->set(xoffset, yoffset, "Clicked");
}
Ejemplo n.º 9
0
static int
ltext_size(lua_State *L) {
	struct sprite *s = self(L);
	if (s->type != TYPE_LABEL) {
		return luaL_error(L, "Ony label can get label_size");
	}
	int width = 0, height = 0;
	label_size(s->data.text, s->s.label, &width, &height);
	lua_pushinteger(L, width);
	lua_pushinteger(L, height);
	return 2;
}
Ejemplo n.º 10
0
/* make_label:
 * Assume str is freshly allocated for this instance, so it
 * can be freed in free_label.
 */
textlabel_t *make_label(int html, char *str, double fontsize,
			char *fontname, char *fontcolor, graph_t * g)
{
    textlabel_t *rv = NEW(textlabel_t);

    rv->text = str;
    rv->fontname = fontname;
    rv->fontcolor = fontcolor;
    rv->fontsize = fontsize;
    if (html)
	rv->html = TRUE;
    else if (GD_charset(g) == CHAR_LATIN1) {
#ifdef ENABLE_HTML //maks
	char* lstr = latin1ToUTF8(str);
#else
	char *lstr = str;
#endif
	label_size(lstr, rv, g);
	free(lstr);
    }
    else
	label_size(str, rv, g);
    return rv;
}
Ejemplo n.º 11
0
void CTmLine::WriteLabelCodeL(CTmFormatContext& aContext,MTmSource::TLabelType aLabelType)
	{
	// Format the label.
	CTmCode *label_code = new(ELeave) CTmCode;
	CleanupStack::PushL(label_code);
	TTmFormatParam param;
	param.iMaxLines = 1;	// labels have only one line
	TSize label_size(0, 0);
	TInt margin_size = 0;
	MFormLabelApi* labelApi = (MFormLabelApi*)aContext.iSource.GetExtendedInterface(KFormLabelApiExtensionUid);
	if (labelApi != NULL)
		labelApi->LabelMetrics(aLabelType, label_size, margin_size);
	param.iWrapWidth = label_size.iWidth;
	CTmFormatContext::TInfo info;
	info.iContextCharPerLine = NULL;
	CTmFormatContext::FormatL(aContext.iSource,param,*label_code,info, aContext.iTextLayout);

	// Make sure the main line's height and ascent are big enough to accommodate the label.
	TTmInterpreterParam interpreter_param(*label_code);
	interpreter_param.iWidth = info.iWidth;
	TTmInterpreter interpreter(interpreter_param);
	interpreter.LineNumberToLine(0);
	int label_ascent = interpreter.LineInfo().iBaseline - interpreter.LineInfo().iOuterRect.iTl.iY;
	int label_descent = interpreter.LineInfo().iOuterRect.Height() - label_ascent;
	int line_descent = iHeight - iAscent;
	iAscent = Max(iAscent,label_ascent);
	iHeight = iAscent + Max(line_descent,label_descent);

	// Insert the bytecode describing the label.
	CTmCode& code = aContext.iCode;
	code.AppendByteL(TTmInterpreter::EOpLabel | TTmInterpreter::EModCount);
	code.AppendNumberL(0);	// a label consumes no bytes from the main text source
	code.AppendNumberL(label_code->Size());
	TRect r;
	r.iTl.iX = -margin_size;
	r.iBr.iX = r.iTl.iX + info.iWidth;
	r.iBr.iY = iAscent + label_descent;
	r.iTl.iY = r.iBr.iY - info.iHeight;
	code.AppendRectL(r);
	code.AppendNumberL(aLabelType);

	// Insert the label bytecode.
	code.ChangeL(code.Size(),code.Size(),*label_code);

	// Clean up.
	CleanupStack::PopAndDestroy();	// label_code
	}
Ejemplo n.º 12
0
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());
}
Ejemplo n.º 13
0
void AudioDisplay::PaintTrackCursor(wxDC &dc) {
	wxDCPenChanger penchanger(dc, wxPen(*wxWHITE));
	dc.DrawLine(track_cursor_pos-scroll_left, audio_top, track_cursor_pos-scroll_left, audio_top+audio_height);

	if (track_cursor_label.empty()) return;

	wxDCFontChanger fc(dc);
	wxFont font = dc.GetFont();
	font.SetWeight(wxFONTWEIGHT_BOLD);
	dc.SetFont(font);

	wxSize label_size(dc.GetTextExtent(track_cursor_label));
	wxPoint label_pos(track_cursor_pos - scroll_left - label_size.x/2, audio_top + 2);
	label_pos.x = mid(2, label_pos.x, GetClientSize().GetWidth() - label_size.x - 2);

	int old_bg_mode = dc.GetBackgroundMode();
	dc.SetBackgroundMode(wxTRANSPARENT);

	// Draw border
	dc.SetTextForeground(wxColour(64, 64, 64));
	dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y+1);
	dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y-1);
	dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y+1);
	dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y-1);

	// Draw fill
	dc.SetTextForeground(*wxWHITE);
	dc.DrawText(track_cursor_label, label_pos.x, label_pos.y);
	dc.SetBackgroundMode(old_bg_mode);

	label_pos.x -= 2;
	label_pos.y -= 2;
	label_size.IncBy(4, 4);
	// If the rendered text changes size we have to draw it an extra time to make sure the entire thing was drawn
	bool need_extra_redraw = track_cursor_label_rect.GetSize() != label_size;
	track_cursor_label_rect.SetPosition(label_pos);
	track_cursor_label_rect.SetSize(label_size);
	if (need_extra_redraw)
		RefreshRect(track_cursor_label_rect, false);
}
Ejemplo n.º 14
0
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());
    }
}
Ejemplo n.º 15
0
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);
}
Ejemplo n.º 16
0
void MainMenu::layout()
{
    fl_font(label_font(), label_size());
    int W = int(fl_width(label())) + 12;
    int H = h();
    int im_size = H-6;

    if(!e_image || (e_image && e_image->height()!=im_size)) {
        if(e_image) delete e_image;
        if(ede_pix.height()==im_size) {
            e_image=0;
            image(ede_pix);
        }
        else {
            e_image = ede_pix.scale(im_size, im_size);
            image(e_image);
        }
    }
    if(image()) W+=image()->width();

    w(W);
    Fl_Menu_Button::layout();
}
Ejemplo n.º 17
0
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);
}
Ejemplo n.º 18
0
LineEdit::LineEdit(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("Line Edit", clan::Rect(512 + 24, 8, clan::Size(256, 256)), false))
{
	func_close().set(this, &LineEdit::on_close);


	clan::Rect client_area = get_client_area();

	lineedit1 = new clan::LineEdit(this);
	lineedit1->set_geometry(clan::Rect(client_area.left + 11, client_area.top + 10, clan::Size(128, 21)));
	lineedit1->set_text("Line Edit");

	lineedit1->func_before_edit_changed().set(this, &LineEdit::on_before_edit_changed, lineedit1);
	lineedit1->func_after_edit_changed().set(this, &LineEdit::on_after_edit_changed, lineedit1);
	lineedit1->func_selection_changed().set(this, &LineEdit::on_selection_changed, lineedit1);
	lineedit1->func_focus_gained().set(this, &LineEdit::on_focus_gained, lineedit1);
	lineedit1->func_focus_lost().set(this, &LineEdit::on_focus_lost, lineedit1);
	lineedit1->func_enter_pressed().set(this, &LineEdit::on_enter_pressed, lineedit1);

	int xoffset = client_area.left + 96;
	int yoffset = client_area.top + 40;
	const int gap = 16;

	info_before_edit_changed = new Info(this);
	info_before_edit_changed->set(xoffset, yoffset, "Before Edit Changed");
	yoffset += gap;
	info_after_edit_changed = new Info(this);
	info_after_edit_changed->set(xoffset, yoffset, "After Edit Changed");
	yoffset += gap;
	info_selection_changed = new Info(this);
	info_selection_changed->set(xoffset, yoffset, "Selection Changed");
	yoffset += gap;
	info_focus_gained = new Info(this);
	info_focus_gained->set(xoffset, yoffset, "Focus Gained");
	yoffset += gap;
	info_focus_lost = new Info(this);
	info_focus_lost->set(xoffset, yoffset, "Focus Lost");
	yoffset += gap;
	info_enter_pressed = new Info(this);
	info_enter_pressed->set(xoffset, yoffset, "Enter Pressed");
	yoffset += gap;

	xoffset = client_area.left + 1;
	yoffset = client_area.top + 195 - gap*8;
	clan::Size label_size(50, 15);

	checkbox_mask_hex = new clan::CheckBox(this);
	checkbox_mask_hex->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_mask_hex->func_checked().set(this, &LineEdit::on_checked_mask_hex, checkbox_mask_hex);
	checkbox_mask_hex->func_unchecked().set(this, &LineEdit::on_unchecked_mask_hex, checkbox_mask_hex);
	checkbox_mask_hex->set_text("Hex Mask");

	yoffset+=gap;
	checkbox_read_only = new clan::CheckBox(this);
	checkbox_read_only->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_read_only->func_checked().set(this, &LineEdit::on_checked_read_only, checkbox_read_only);
	checkbox_read_only->func_unchecked().set(this, &LineEdit::on_unchecked_read_only, checkbox_read_only);
	checkbox_read_only->set_text("Read Only");

	yoffset+=gap;
	checkbox_lowercase = new clan::CheckBox(this);
	checkbox_lowercase->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_lowercase->func_checked().set(this, &LineEdit::on_checked_lowercase, checkbox_lowercase);
	checkbox_lowercase->func_unchecked().set(this, &LineEdit::on_unchecked_lowercase, checkbox_lowercase);
	checkbox_lowercase->set_text("Lowercase");

	yoffset+=gap;
	checkbox_uppercase = new clan::CheckBox(this);
	checkbox_uppercase->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_uppercase->func_checked().set(this, &LineEdit::on_checked_uppercase, checkbox_uppercase);
	checkbox_uppercase->func_unchecked().set(this, &LineEdit::on_unchecked_uppercase, checkbox_uppercase);
	checkbox_uppercase->set_text("Uppercase");

	yoffset+=gap;
	checkbox_password_mode = new clan::CheckBox(this);
	checkbox_password_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_password_mode->func_checked().set(this, &LineEdit::on_checked_password_mode, checkbox_password_mode);
	checkbox_password_mode->func_unchecked().set(this, &LineEdit::on_unchecked_password_mode, checkbox_password_mode);
	checkbox_password_mode->set_text("Password Mode");

	yoffset+=gap;
	checkbox_numeric_mode = new clan::CheckBox(this);
	checkbox_numeric_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_numeric_mode->func_checked().set(this, &LineEdit::on_checked_numeric_mode, checkbox_numeric_mode);
	checkbox_numeric_mode->func_unchecked().set(this, &LineEdit::on_unchecked_numeric_mode, checkbox_numeric_mode);
	checkbox_numeric_mode->set_text("Numeric Mode");

	yoffset+=gap;
	checkbox_numeric_mode_decimals = new clan::CheckBox(this);
	checkbox_numeric_mode_decimals->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_numeric_mode_decimals->func_checked().set(this, &LineEdit::on_checked_numeric_mode_decimals, checkbox_numeric_mode_decimals);
	checkbox_numeric_mode_decimals->func_unchecked().set(this, &LineEdit::on_unchecked_numeric_mode_decimals, checkbox_numeric_mode_decimals);
	checkbox_numeric_mode_decimals->set_text("Numeric Mode Decimals");
	checkbox_numeric_mode_decimals->set_enabled(false);

	yoffset+=gap;
	pushbutton_resize = new clan::PushButton(this);
	pushbutton_resize->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(64, 20)));
	pushbutton_resize->set_text("Resize");
	pushbutton_resize->func_clicked().set(this, &LineEdit::on_resize_clicked, pushbutton_resize);

	yoffset+=gap+4;
	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked().set(this, &LineEdit::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &LineEdit::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");

	xoffset = client_area.left + 101;
	yoffset = client_area.top + 190;
	menu_settext.insert_item("(Settings)");
	menu_settext.insert_item("Set Align: Left");
	menu_settext.insert_item("Set Align: Centre");
	menu_settext.insert_item("Set Align: Right");
	menu_settext.insert_item("Set Text: Hello World");
	menu_settext.insert_item("Set Integer: 1234");
	menu_settext.insert_item("Set Float: 123.456");
	menu_settext.insert_item("Select: All");
	menu_settext.insert_item("Select: 2nd to 5th char");
	menu_settext.insert_item("Select: None");

	combo_settext = new clan::ComboBox(this);
	combo_settext->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(130, 20)));
	combo_settext->set_editable(false);
	combo_settext->set_dropdown_height(128);
	combo_settext->set_dropdown_minimum_width(64);
	combo_settext->set_popup_menu(menu_settext);
	combo_settext->set_selected_item(0);
	combo_settext->func_item_selected().set(this, &LineEdit::on_settext_selected, combo_settext);
}
Ejemplo n.º 19
0
MenuBar::MenuBar(CL_GUIManager &manager, CL_ResourceManager &application_resources) :
	CL_Window(&manager, CL_GUITopLevelDescription("Menu Bar & Status Bar", CL_Rect(512 + 24, 256 + 16, CL_Size(256, 180)), false))
{
	tux_image = CL_ImageProviderFactory::load("../CommonCode/Resources/tux.png");

	CL_GraphicContext gc = get_gc();
	tux_head = CL_Image(gc, "tux_head", &application_resources);

	set_draggable(true);

	CL_Rect client_area = get_client_area();

	menubar1 = new CL_MenuBar(this);
	menubar1->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top + 25));

	menu_file.insert_item("New").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_file.insert_item("Open").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_file.insert_item("Save").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem tux_item = menu_file.insert_item("Tux");
	tux_item.func_clicked().set(this, &MenuBar::on_item_selected);
	tux_item.set_icon(tux_image);

	menu_file.insert_item("Exit").func_clicked().set(this, &MenuBar::on_item_selected);
	menubar1->add_menu("File", menu_file);

	menu_edit.insert_item("Undo").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem redo_item = menu_edit.insert_item("Redo");
	redo_item.func_clicked().set(this, &MenuBar::on_item_selected);
	redo_item.set_enabled(false);
	menu_edit.insert_separator();
	menu_edit.insert_item("Cut").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_item("Copy").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	item_submenu = menu_edit.insert_item("Submenu");
	item_submenu.func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	menu_edit.insert_item("Paste").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_item("Delete").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	menu_edit.insert_item("Select All").func_clicked().set(this, &MenuBar::on_item_selected);

	menu_submenu.insert_item("foo").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_submenu.insert_item("bar").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_submenu.insert_item("foobar").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem check_item1 = menu_submenu.insert_item("Checkable 1");
	check_item1.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item1.set_checkable(true);
	check_item1.set_checked(true);
	CL_PopupMenuItem check_item2 = menu_submenu.insert_item("Checkable 2");
	check_item2.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item2.set_checkable(true);
	check_item2.set_checked(false);
	CL_PopupMenuItem check_item3 = menu_submenu.insert_item("Disabled Checkable 1");
	check_item3.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item3.set_checkable(true);
	check_item3.set_checked(true);
	check_item3.set_enabled(false);
	CL_PopupMenuItem check_item4 = menu_submenu.insert_item("Disabled Checkable 2");
	check_item4.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item4.set_checkable(true);
	check_item4.set_checked(false);
	check_item4.set_enabled(false);
	item_submenu.set_submenu(menu_submenu);

	menubar1->add_menu("Edit", menu_edit);

	int xoffset = client_area.left + 80;
	int yoffset = client_area.top + 30;
	const int gap = 16;
	CL_Size label_size(50, 15);

	info_item_selected = new Info(this);
	info_item_selected->set(xoffset, yoffset, "Item Selected");
	yoffset += gap;

	statusbar1 = new CL_StatusBar(this);
	int statusbar_height = statusbar1->get_preferred_height();
	CL_Rect statusbar_rect(0, client_area.get_height() - statusbar_height, CL_Size(client_area.get_width(), statusbar_height));
	statusbar_rect.translate(client_area.left, client_area.top);
	statusbar1->set_geometry(statusbar_rect);
	statusbar1->set_status_text("Status bar");
	statusbar1->show_size_grip(true);

	pushbutton1 = new CL_PushButton(statusbar1);
	pushbutton1->set_icon(tux_head);
	pushbutton1->func_clicked().set(this, &MenuBar::on_clicked, pushbutton1);
	statusbar1->add_part(0, 48, pushbutton1);
	statusbar1->func_part_double_clicked(0).set(this, &MenuBar::on_part_double_clicked_0, statusbar1);

	component1 = new CL_GUIComponent(statusbar1);
	statusbar1->add_part(1, 48, component1);
	statusbar1->set_part_text(1, "ClanTest");
	statusbar1->func_part_double_clicked(1).set(this, &MenuBar::on_part_double_clicked_1, statusbar1);

	CL_GUIComponent *component2 = (new CL_GUIComponent(statusbar1));
	statusbar1->add_part(2, 48, component2);
	statusbar1->set_part_text(2, tux_head, "");
	statusbar1->func_part_double_clicked(2).set(this, &MenuBar::on_part_double_clicked_2, statusbar1);

	xoffset = client_area.left + 5;
	yoffset = client_area.top + 40;

	label_status = new CL_Label(this);
	label_status->set_geometry(CL_Rect(xoffset, yoffset, label_size));
	label_status->set_text("Status Bar:");
	yoffset += gap;

	checkbox_status_size_grip = new CL_CheckBox(this);
	checkbox_status_size_grip->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_size_grip->func_checked().set(this, &MenuBar::on_checked_status_size_grip, checkbox_status_size_grip);
	checkbox_status_size_grip->func_unchecked().set(this, &MenuBar::on_unchecked_status_size_grip, checkbox_status_size_grip);
	checkbox_status_size_grip->set_text("Show Size Grip");
	checkbox_status_size_grip->set_checked(true);
	yoffset += gap;

	checkbox_status_text = new CL_CheckBox(this);
	checkbox_status_text->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_text->func_checked().set(this, &MenuBar::on_checked_status_text, checkbox_status_text);
	checkbox_status_text->func_unchecked().set(this, &MenuBar::on_unchecked_status_text, checkbox_status_text);
	checkbox_status_text->set_text("Change Status Text");
	checkbox_status_text->set_checked(true);
	yoffset += gap;

	checkbox_status_show_clantest = new CL_CheckBox(this);
	checkbox_status_show_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_show_clantest->func_checked().set(this, &MenuBar::on_checked_show_clantest, checkbox_status_show_clantest);
	checkbox_status_show_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_show_clantest, checkbox_status_show_clantest);
	checkbox_status_show_clantest->set_text("Show ClanTest");
	checkbox_status_show_clantest->set_checked(true);
	yoffset += gap;

	checkbox_status_remove_clantest = new CL_CheckBox(this);
	checkbox_status_remove_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_remove_clantest->func_checked().set(this, &MenuBar::on_checked_remove_clantest, checkbox_status_remove_clantest);
	checkbox_status_remove_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_remove_clantest, checkbox_status_remove_clantest);
	checkbox_status_remove_clantest->set_text("Remove ClanTest");
	checkbox_status_remove_clantest->set_checked(false);
	yoffset += gap;

	xoffset = client_area.left + 110;
	yoffset -= (gap*2);

	info_clicked = new Info(this);
	info_clicked->set(xoffset, yoffset, "Push Button Clicked");

	yoffset += gap;

	info_part_clicked = new Info(this);
	info_part_clicked->set(xoffset, yoffset, "Part Dbl Clicked");

}
Ejemplo n.º 20
0
Slider::Slider(clan::GUIManager &manager) : 
	clan::Window(&manager, clan::GUITopLevelDescription("Slider", clan::Rect(256 + 16, 8, clan::Size(256, 256)), false))
{

	func_close().set(this, &Slider::on_close);

	clan::Rect client_area = get_client_area();

	slider_vertical = new clan::Slider(this);
	slider_vertical->set_geometry(clan::Rect(client_area.left + 1, client_area.top + 10, clan::Size(17, 200)));
	slider_vertical->set_vertical(true);
	slider_vertical->set_horizontal(false);
	slider_vertical->set_min(0);
	slider_vertical->set_max(100);
	slider_vertical->set_tick_count(10);
	slider_vertical->set_page_step(40);
	slider_vertical->set_position(50);
	slider_vertical->set_lock_to_ticks(false);
	slider_vertical->func_value_changed().set(this, &Slider::on_value_changed, slider_vertical);
	slider_vertical->func_value_decremented().set(this, &Slider::on_value_decremented, slider_vertical);
	slider_vertical->func_value_incremented().set(this, &Slider::on_value_incremented, slider_vertical);
	slider_vertical->func_slider_moved().set(this, &Slider::on_slider_moved, slider_vertical);

	slider_horizontal = new clan::Slider(this);
	slider_horizontal->set_geometry(clan::Rect(client_area.left + 36, client_area.top + 10, clan::Size(200, 17)));
	slider_horizontal->set_vertical(false);
	slider_horizontal->set_horizontal(true);
	slider_horizontal->set_min(0);
	slider_horizontal->set_max(100);
	slider_horizontal->set_tick_count(10);
	slider_horizontal->set_page_step(40);
	slider_horizontal->set_position(50);
	slider_horizontal->set_lock_to_ticks(false);
	slider_horizontal->func_value_changed().set(this, &Slider::on_value_changed, slider_horizontal);
	slider_horizontal->func_value_decremented().set(this, &Slider::on_value_decremented, slider_horizontal);
	slider_horizontal->func_value_incremented().set(this, &Slider::on_value_incremented, slider_horizontal);
	slider_horizontal->func_slider_moved().set(this, &Slider::on_slider_moved, slider_horizontal);

	clan::Size lineedit_size(42, 20);
	clan::Size label_size(50, 15);
	int lineedit_xpos = client_area.left + 146;
	int label_xpos = client_area.left + 190;

	int lineedit_ypos = client_area.top + 40;
	const int lineedit_gap = 25;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("0");
	lineedit_min->set_numeric_mode(true);
	lineedit_min->func_enter_pressed().set(this, &Slider::on_min_enter_pressed, lineedit_min);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("100");
	lineedit_max->set_numeric_mode(true);
	lineedit_max->func_enter_pressed().set(this, &Slider::on_max_enter_pressed, lineedit_max);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;

	lineedit_tick_count = new clan::LineEdit(this);
	lineedit_tick_count->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_tick_count->set_text("10");
	lineedit_tick_count->func_enter_pressed().set(this, &Slider::on_tick_count_enter_pressed, lineedit_tick_count);

	lineedit_label_tick_count = new clan::Label(this);
	lineedit_label_tick_count->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_tick_count->set_text("Tick Count");
	lineedit_ypos += lineedit_gap;

	lineedit_page_step = new clan::LineEdit(this);
	lineedit_page_step->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_page_step->set_text("40");
	lineedit_page_step->func_enter_pressed().set(this, &Slider::on_page_step_enter_pressed, lineedit_page_step);

	lineedit_label_page_step = new clan::Label(this);
	lineedit_label_page_step->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_page_step->set_text("Page Step");
	lineedit_ypos += lineedit_gap;

	lineedit_position_vert = new clan::LineEdit(this);
	lineedit_position_vert->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_position_vert->set_text("50");
	lineedit_position_vert->func_enter_pressed().set(this, &Slider::on_position_enter_pressed_vert, lineedit_position_vert);

	lineedit_label_position_vert = new clan::Label(this);
	lineedit_label_position_vert->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_position_vert->set_text("Vertical");
	lineedit_ypos += lineedit_gap;

	lineedit_position_horiz = new clan::LineEdit(this);
	lineedit_position_horiz->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_position_horiz->set_text("50");
	lineedit_position_horiz->func_enter_pressed().set(this, &Slider::on_position_enter_pressed_horiz, lineedit_position_horiz);

	lineedit_label_position_horiz = new clan::Label(this);
	lineedit_label_position_horiz->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_position_horiz->set_text("Horizonal");
	lineedit_ypos += lineedit_gap;

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked().set(this, &Slider::on_apply_clicked, pushbutton_apply);

	int xoffset = client_area.left + 21;
	int yoffset = client_area.top + 35;
	const int gap = 16;

	info_value_changed = new Info(this);
	info_value_changed->set(xoffset, yoffset, "Value Changed");
	yoffset += gap;

	info_value_decremented = new Info(this);
	info_value_decremented->set(xoffset, yoffset, "Value Decr.");
	yoffset += gap;

	info_value_incremented = new Info(this);
	info_value_incremented->set(xoffset, yoffset, "Value Incr.");
	yoffset += gap;

	info_slider_moved = new Info(this);
	info_slider_moved->set(xoffset, yoffset, "Slider Moved");
	yoffset += gap;

	xoffset = client_area.left + 36;
	yoffset = client_area.top + 195 - gap;

	checkbox_lock_to_ticks = new clan::CheckBox(this);
	checkbox_lock_to_ticks->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_lock_to_ticks->func_checked().set(this, &Slider::on_checked_lock_to_ticks, checkbox_lock_to_ticks);
	checkbox_lock_to_ticks->func_unchecked().set(this, &Slider::on_unchecked_lock_to_ticks, checkbox_lock_to_ticks);
	checkbox_lock_to_ticks->set_text("Lock to Ticks");

	yoffset += gap;

	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked().set(this, &Slider::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &Slider::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");
}
Ejemplo n.º 21
0
// 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);
			}
		}
	}
Ejemplo n.º 22
0
void wxRibbonMetroArtProvider::DrawPanelBackground(
                        wxDC& dc,
                        wxRibbonPanel* wnd,
                        const wxRect& rect)
{
    DrawPartialPageBackground(dc, wnd, rect, false);

    wxRect true_rect(rect);
    RemovePanelPadding(&true_rect);
    bool has_ext_button = wnd->HasExtButton();

	// draw panel label
    {
		// int label_height;
        dc.SetFont(m_panel_label_font);
        dc.SetPen(*wxTRANSPARENT_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.SetTextForeground(m_panel_label_colour);

        wxRect label_rect(true_rect);
        wxString label = wnd->GetLabel();
        bool clip_label = false;
        wxSize label_size(dc.GetTextExtent(label));

        label_rect.SetX(label_rect.GetX() + 1);
        label_rect.SetWidth(label_rect.GetWidth() - 2);
        label_rect.SetHeight(label_size.GetHeight() + 2);
        label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight());
        // label_height = label_rect.GetHeight();

        wxRect label_bg_rect = label_rect;

        if(has_ext_button)
            label_rect.SetWidth(label_rect.GetWidth() - 13);

        if(label_size.GetWidth() > label_rect.GetWidth())
        {
            // Test if there is enough length for 3 letters and ...
            wxString new_label = label.Mid(0, 3) + wxT("...");
            label_size = dc.GetTextExtent(new_label);
            if(label_size.GetWidth() > label_rect.GetWidth())
            {
                // Not enough room for three characters and ...
                // Display the entire label and just crop it
                clip_label = true;
            }
            else
            {
                // Room for some characters and ...
                // Display as many characters as possible and append ...
                for(size_t len = label.Len() - 1; len >= 3; --len)
                {
                    new_label = label.Mid(0, len) + wxT("...");
                    label_size = dc.GetTextExtent(new_label);
                    if(label_size.GetWidth() <= label_rect.GetWidth())
                    {
                        label = new_label;
                        break;
                    }
                }
            }
        }

        dc.DrawRectangle(label_bg_rect);
        if(clip_label)
        {
            wxDCClipper clip(dc, label_rect);
            dc.DrawText(label, label_rect.x, label_rect.y +
                (label_rect.GetHeight() - label_size.GetHeight()) / 2);
        }
        else
        {
            dc.DrawText(label, label_rect.x +
                (label_rect.GetWidth() - label_size.GetWidth()) / 2,
                label_rect.y +
                (label_rect.GetHeight() - label_size.GetHeight()) / 2);
        }

        if(has_ext_button)
        {
            if(wnd->IsExtButtonHovered())
            {
                dc.SetPen(m_panel_hover_button_border_pen);
                dc.SetBrush(m_panel_hover_button_background_brush);
                dc.DrawRectangle(label_rect.GetRight(), label_rect.GetBottom() - 14, 14, 14);
                dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
            }
            else
                dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
        }
    }
	
	if (wnd->GetParent()->IsKindOf(CLASSINFO(wxFrame))) // expanded panels are in their own wxFrame otherwise normal panel
	{	
		wxRect shadow(rect);
		shadow.x +=4;
		shadow.y +=4;
		dc.SetPen(*wxRED);
		dc.DrawLine(shadow.GetBottomLeft(), shadow.GetBottomRight());
		dc.DrawLine(shadow.GetTopRight(), shadow.GetBottomRight());
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.SetPen(m_panel_border_pen);
		dc.DrawRoundedRectangle(rect, 1.0);
	}
	else
		DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
}
Ejemplo n.º 23
0
Spin::Spin(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("Spin", clan::Rect(256*3 + 32, 256 + 16, clan::Size(256, 180)), false))
{

	func_close() = bind_member(this, &Spin::on_close);

	clan::Rect client_area = get_client_area();

	spin1 = new clan::Spin(this);
	spin1->set_geometry(clan::Rect(client_area.left + 11, client_area.top + 10, clan::Size(128, 21)));
	spin1->set_number_of_decimal_places(2);
	spin1->set_value(500);
	spin1->set_step_size(50);
	spin1->set_ranges(200, 2000);
	spin1->set_floating_point_mode(false);
	spin1->func_value_changed() = bind_member(this, &Spin::on_value_changed);

	int xoffset = client_area.left + 16;
	int yoffset = client_area.top + 40;
	const int gap = 16;
	clan::Size label_size(50, 15);

	info_value_changed = new Info(this);
	info_value_changed->set(xoffset, yoffset, "Value Changed");
	yoffset += gap;

	clan::Size lineedit_size(48, 20);
	int lineedit_xpos = client_area.left + 6;
	int label_xpos = client_area.left + 56;
	int lineedit_ypos = client_area.top + 60;
	const int lineedit_gap = 25;

	lineedit_value = new clan::LineEdit(this);
	lineedit_value->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_value->set_text("500");
	lineedit_value->set_numeric_mode(true);
	lineedit_value->func_enter_pressed() = bind_member(this, &Spin::on_value_enter_pressed);

	lineedit_label_value = new clan::Label(this);
	lineedit_label_value->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_value->set_text("Value");
	lineedit_ypos += lineedit_gap;

	lineedit_decimal_places = new clan::LineEdit(this);
	lineedit_decimal_places->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_decimal_places->set_text("2");
	lineedit_decimal_places->set_numeric_mode(true, true);
	lineedit_decimal_places->func_enter_pressed() = bind_member(this, &Spin::on_decimal_places_enter_pressed);

	lineedit_label_decimal_places = new clan::Label(this);
	lineedit_label_decimal_places->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_decimal_places->set_text("Decimal Places");
	lineedit_ypos += lineedit_gap;
	lineedit_decimal_places->set_enabled(false);

	lineedit_xpos = client_area.left + 146;
	label_xpos = client_area.left + 196;
	lineedit_ypos = client_area.top + 10;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("200");
	lineedit_min->set_numeric_mode(true, true);
	lineedit_min->func_enter_pressed() = bind_member(this, &Spin::on_min_enter_pressed);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("2000");
	lineedit_max->set_numeric_mode(true, true);
	lineedit_max->func_enter_pressed() = bind_member(this, &Spin::on_max_enter_pressed);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;

	lineedit_step = new clan::LineEdit(this);
	lineedit_step->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_step->set_text("50");
	lineedit_step->set_numeric_mode(true, true);
	lineedit_step->func_enter_pressed() = bind_member(this, &Spin::on_step_enter_pressed);

	lineedit_label_step = new clan::Label(this);
	lineedit_label_step->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_step->set_text("Step");
	lineedit_ypos += lineedit_gap;

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked() = bind_member(this, &Spin::on_apply_clicked);

	xoffset = client_area.left + 1;
	yoffset = client_area.top + 126 - gap;

	checkbox_fp_mode = new clan::CheckBox(this);
	checkbox_fp_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_fp_mode->func_checked() = bind_member(this, &Spin::on_checked_fp_mode);
	checkbox_fp_mode->func_unchecked() = bind_member(this, &Spin::on_unchecked_fp_mode);
	checkbox_fp_mode->set_text("Floating Point Mode");

	yoffset += gap;

	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked() = bind_member(this, &Spin::on_checked_disable);
	checkbox_disable->func_unchecked() = bind_member(this, &Spin::on_unchecked_disable);
	checkbox_disable->set_text("Disable");
}
Ejemplo n.º 24
0
ProgressBar::ProgressBar(clan::GUIManager &manager) :
	clan::GUIComponent(&manager, clan::GUITopLevelDescription("Progress Bar", clan::Rect(24 + 256*2, 256*1 + 180*2 + 32, clan::Size(256, 180)), false), "window")
{


	clan::Rect client_area = get_content_box();

	progressbar1 = new clan::ProgressBar(this);
	progressbar1->set_geometry(clan::Rect(client_area.left + 5, client_area.top + 5, clan::Size(128, 32)));
	progressbar1->set_min(0);
	progressbar1->set_max(100);
	progressbar1->set_step_size(10);
	progressbar1->set_position(20);
	progressbar1->set_marquee_animation_speed(1000);
	progressbar1->set_marquee_mode(false);

	clan::Size lineedit_size(48, 20);
	clan::Size label_size(50, 15);
	int lineedit_xpos = client_area.left + 5;
	int lineedit_ypos = client_area.top + 40;
	int label_xpos = client_area.left + 55;
	const int lineedit_gap = 25;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("0");
	lineedit_min->set_numeric_mode(true);
	lineedit_min->func_enter_pressed().set(this, &ProgressBar::on_min_enter_pressed, lineedit_min);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("100");
	lineedit_max->set_numeric_mode(true);
	lineedit_max->func_enter_pressed().set(this, &ProgressBar::on_max_enter_pressed, lineedit_max);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;


	lineedit_step_size = new clan::LineEdit(this);
	lineedit_step_size->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_step_size->set_text("10");
	lineedit_step_size->func_enter_pressed().set(this, &ProgressBar::on_step_size_enter_pressed, lineedit_step_size);

	lineedit_label_step_size = new clan::Label(this);
	lineedit_label_step_size->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_step_size->set_text("Step Size");
	lineedit_ypos += lineedit_gap;

	lineedit_position = new clan::LineEdit(this);
	lineedit_position->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_position->set_text("20");
	lineedit_position->func_enter_pressed().set(this, &ProgressBar::on_position_enter_pressed, lineedit_position);

	lineedit_label_position = new clan::Label(this);
	lineedit_label_position->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_position->set_text("Position");
	lineedit_ypos += lineedit_gap;

	lineedit_xpos = client_area.left + 110;
	lineedit_ypos = client_area.top + 40;
	label_xpos = client_area.left + 160;


	checkbox_marquee_mode = new clan::CheckBox(this);
	checkbox_marquee_mode->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(100, 15)));
	checkbox_marquee_mode->func_checked().set(this, &ProgressBar::on_checked_marquee_mode, checkbox_marquee_mode);
	checkbox_marquee_mode->func_unchecked().set(this, &ProgressBar::on_unchecked_marquee_mode, checkbox_marquee_mode);
	checkbox_marquee_mode->set_text("Marquee Mode");

	lineedit_ypos += lineedit_gap;

	lineedit_marquee_speed = new clan::LineEdit(this);
	lineedit_marquee_speed->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_marquee_speed->set_text("1000");
	lineedit_marquee_speed->func_enter_pressed().set(this, &ProgressBar::on_marquee_speed_enter_pressed, lineedit_marquee_speed);

	lineedit_label_marquee_speed = new clan::Label(this);
	lineedit_label_marquee_speed->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_marquee_speed->set_text("Marquee Speed");
	lineedit_ypos += lineedit_gap;
	lineedit_marquee_speed->set_enabled(false);

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked().set(this, &ProgressBar::on_apply_clicked, pushbutton_apply);

	lineedit_ypos += lineedit_gap;

	pushbutton_step_position = new clan::PushButton(this);
	pushbutton_step_position->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(92, 20)));
	pushbutton_step_position->set_text("Step Position");
	pushbutton_step_position->func_clicked().set(this, &ProgressBar::on_step_position_clicked, pushbutton_step_position);

}