Beispiel #1
0
EDEFont fl_font_dialog(EDEFont current_font) 
{
	EDEFont return_font;

	create_the_forms();
	int numfonts = fl_list_fonts(all_fonts);

	// populate list of fonts
	Fl_String currentname = current_font.font->name();
	for(int i = 0; i < numfonts; i++) {
		Fl_String fontname = all_fonts[i]->name();
		fontobj->add(fontname);
 		if (currentname.lower_case().pos(fontname.lower_case())==0) // it's a substring
			fontobj->value(i);
	}

	// set bold, italic
	if (currentname.pos(" bold italic") == currentname.length()-12) {
		bold_button->value(true);
		italic_button->value(true);
	} else if (currentname.pos(" italic") == currentname.length()-7) {
		italic_button->value(true);
	} else if (currentname.pos(" bold") == currentname.length()-5) {
		bold_button->value(true);
	}

	// populate other lists
	textobj->encoding = current_font.encoding; // TODO: what if we're using XFT?
	font_cb(fontobj,0);
	for (int i=0; i < sizeobj->children(); i++) {
		if (atoi(sizeobj->text(i)) == current_font.size) {
			sizeobj->value(i);
			size_cb(sizeobj,0);
		}
	}

	form->exec();
	form->show();

	// we have to construct a proper EDEFont to return
	return_font.defined = false;
	if (return_value)
	{
		return_font.font = fl_find_font(fontobj->text(fontobj->value()));
		if (bold_button->value()) return_font.font = return_font.font->bold();
		if (italic_button->value()) return_font.font = return_font.font->italic();

		int size = atoi(sizeobj->text(sizeobj->value()));
		return_font.size = find_best_size(return_font.font, size);

		// on XFT encoding is always Unicode, so this field can be blank
		if (encobj->children() > 0) 
			return_font.encoding = encobj->text(encobj->value());
		else
			return_font.encoding = "";
		
		return_font.defined = true;
	}
	return return_font;
}
Beispiel #2
0
Fl_String Fl_String::operator + (const Fl_String& s) const
{
    int len = length() + s.length();
    char *temp = (char*)malloc(len+1);
    strncpy(temp, str_, length());
    if(s.length()) strncpy(temp+length(), s.c_str(), s.length());

    temp[len] = '\0';

    Fl_String s1(temp, len, true);
    return s1;
}
Beispiel #3
0
double Fl_String::to_double(double defvalue) const
{
    Fl_String t = trim();
    if (!t.length()) return defvalue;
    double value = strtod(t.c_str(), NULL);
    if (errno == ERANGE) return defvalue;
    return value;
}
Beispiel #4
0
float Fl_String::to_float(float defvalue) const
{
    Fl_String t = trim();
    if(!t.length()) return defvalue;
    float value = (float)strtod(t.c_str(), NULL);
    if(errno == ERANGE) return defvalue;
    return value;
}
Beispiel #5
0
int Fl_String::to_int(int defvalue) const
{
    Fl_String t = trim();
    if (!t.length()) return defvalue;
    int value = strtol(t.c_str(), NULL, 10);
    if(errno == ERANGE) return defvalue;
    if(value == 0 && t != "0") return defvalue;
    return value;
}
Beispiel #6
0
Fl_String MainMenu::get_item_name(Fl_XmlNode *node)
{
    Fl_String name;
    for(uint n=0; n<node->children(); n++) {
        Fl_XmlNode *np = node->child(n);
        if(np->is_element() && np->name()=="Name") {
            Fl_String &lang = np->get_attribute("Lang");
            if(lang=="" && name.length()==0) {
                name.clear();
                np->text(name);
            } else if(lang==locale()) {
                name.clear();
                np->text(name);
                break;
            }
        }
    }
    return name;
}
Beispiel #7
0
void parse_header(Fl_Buffer &buf)
{
	if(!header.empty()) return;

	char *ptr = buf.data();
	char *header_end = strstr(ptr, "\r\n\r\n");
	if(header_end) {
		header = Fl_String(ptr, header_end-ptr);		
		int hlen = header.length()+4;
		buf.set(buf.data()+hlen, buf.bytes()-hlen);

		printf("HEADER (%s)\n", header.c_str());
		int pos = header.pos("Content-Length");
		if(pos>-1) {
			pos += 15;
			int pos2 = header.pos("\r\n", pos);
			content_len = header.sub_str(pos, pos2-pos).to_int();	
			p_bar->range(0, content_len);
		}		
	}
}