Пример #1
0
void update()
{
    int rot_val = (int)rot->value();
    int scale_val = (int)scale->value();
    for (int i = window->children(); i--; )
    {
        // all window children
        Fl_Widget *wc = window->child(i);

        if(wc==scale||wc==rot) continue;

        Fl_String str("@");
        if(scale_val>0) {
            str+="+"+Fl_String(scale_val);
        } else if(scale_val<0) {
            str+=Fl_String(scale_val);
        }
        if(rot_val>0) {
            str+=Fl_String(rot_val);
        }
        str+=(char*)wc->user_data();
        wc->copy_label(str.c_str());
    }
    window->redraw();
}
Пример #2
0
Fl_String Fl_String::sub_str(int start,int count) const
{
    if (start >= (int)len_)
        return Fl_String("");
    if (count > (int)len_ - start)
        count = len_ - start;
    return Fl_String(str_+start, count);
}
Пример #3
0
Fl_String Fl_String::upper_case() const
{
    char *temp = (char*)malloc(length()*3);
    int len = fl_utf_toupper((const uchar*)str_, length(), temp);
    temp[len] = '\0';
    return Fl_String(temp, len, true);
}
Пример #4
0
void clockRefresh(void *)
{
	// Handle user's format preference
	Fl_String timestr = Fl_Date_Time::Now().time_string();
	Fl_String timestrsec;
	Fl_String format;
	pGlobalConfig.get("Clock", "TimeFormat", format, "");
	Fl_String seconds = timestr.sub_str(6, 2);
	Fl_String minutes = timestr.sub_str(3, 2);
	int hours = atoi(timestr.sub_str(0, 2));
	if(format == "12") {
		if(hours > 12) {
			hours -= 12;
		}
	}
	timestr = Fl_String(hours) + ":" + minutes;
	timestrsec = timestr + ":" + seconds;
	mClockBox->label(timestr);

	strncpy(Fl_Date_Time::datePartsOrder, _("MDY"), 3);
	Fl_String pClockTooltip = Fl_Date_Time::Now().day_name() + ", ";
	pClockTooltip += Fl_Date_Time::Now().date_string() + ", " + timestrsec;
	mClockBox->tooltip(pClockTooltip);

	mClockBox->redraw();
	Fl::add_timeout(1.0, clockRefresh);
}
Пример #5
0
Fl_Date_Time::Fl_Date_Time (const char * dat) {

   int i;
   // NLS stuff
   for (i=0; i<7;i++) dayname[i]=_(dayname[i]);
   for (i=0; i<12;i++) mname[i]=_(mname[i]);   

   Fl_String  s1( Fl_String(dat).trim() );
   Fl_String  s2;

   if (!*dat) {
      m_dateTime = 0;
      return;
   }
   int      p = s1.pos(" ");
   if (p >= 0) {
      s2 = s1.sub_str(p+1,20).trim();
      s1[p] = 0;
   }
   if ( strchr(s1.c_str(),dateSeparator) ) {
      encode_date(m_dateTime, s1.c_str());
      if ( strchr(s2.c_str(),timeSeparator) ) {
         double dt;
         encode_time(dt, s2.c_str());
         m_dateTime += dt;
      }
   }
   else  encode_time(m_dateTime, s1.c_str());
}
Пример #6
0
int getshortcutfor(Fl_String action)
{
    for (int i=0; i<NR_HOTKEYS; i++)
        if (action == Fl_String(hotkeys[i].uiname)) return keycodes[i];

    return 0;
}
Пример #7
0
// FONT STUFF:
// returns nice name for a font
Fl_String font_nice_name(EDEFont font) {
	if (!font.defined)
		return Fl_String("Unknown");

	Fl_String nicename = font.font->name();

	// capitalize bold, italic
	nicename.sub_replace("bold","Bold");
	nicename.sub_replace("italic","Italic");

	nicename = nicename + " (";
	nicename = nicename + Fl_String(font.size);
	nicename = nicename + ")";
	
	return nicename;
}
Пример #8
0
// Returns absolute path of selected filename.
Fl_String Fl_File_Browser::filename_full() const
{
    if(item() && item()!=up_item()) {
        return directory()+item()->label(1);
    }
    return Fl_String("");
}
Пример #9
0
Fl_String MainMenu::get_item_dir(Fl_XmlNode *node)
{
    Fl_String dir( node->get_attribute("Dir") );

    if(dir=="$DEFAULT_PROGRAMS_DIR")
        dir = Fl_String(PREFIX"/share/ede/programs");

    return fl_file_expand(dir);
}
Пример #10
0
void removeShortcut(Fl_String action)
{
	for (int i=0; i<NR_HOTKEYS; i++)
		if (action == Fl_String(hotkeys[i].uiname)) {
			keycodes[i]=0;
			if (strncmp(hotkeys[i].systemname,"App",3) == 0)
				strcpy(hotkeys[i].uiname,"");
		}
}
Пример #11
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);
		}		
	}
}
Пример #12
0
Fl_String operator +(const char*s, const Fl_String& rhs) {
    return Fl_String(s) + rhs;
}
Пример #13
0
Fl_String Fl_Date_Time::time_string() const {
   char  buffer[32];
   format_time(buffer,!time24Mode);
   return Fl_String(buffer);
}
Пример #14
0
// 'Fl_FileBrowser::load()' - Load a directory into the browser.
int                                         // O - Number of files loaded
    Fl_File_Browser::load(const Fl_String &dir) // I - Directory to load
{   
    Fl_String old_dir(directory());
    m_dir_ds.directory(dir);

    clear();
    clear_columns();
    sort_col(1);
    m_up_item = 0;

    if(dir.empty()) {
        header()->add_column("", 20);

        // No directory specified:
        //  - For UNIX list all mount points.
        //  - For Win32 list all valid drive letters.

        //icon      = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE);
        //if (icon == (Fl_FileIcon *)0)
        //  icon = Fl_FileIcon::find("any", Fl_FileIcon::DIR);

        begin();
        char filename[FL_PATH_MAX];
#ifdef _WIN32
        header()->add_column(_("File"), 100);
        header()->add_column(_("Type"), 100);
        header()->add_column(_("Capacity"), 100);
        header()->add_column(_("Free Space"), 100);

        // Drive available bits
        DWORD drives = GetLogicalDrives();
        for(int i = 'A'; i <= 'Z'; i ++, drives >>= 1) {
            if (drives & 1) {
                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                snprintf(filename, sizeof(filename)-1, "%c:\\", i);
                item->label(1, filename);

                Fl_File_Attr *attr = fl_file_attr(filename);
                if(attr->flags & Fl_File_Attr::DEVICE)
                {
                    uint type = GetDriveTypeA(filename);
                    const char *typestr=_(types[0]);

                    if (type==DRIVE_CDROM)      { typestr=_(types[4]); item->image(&cd_pix); }
                    else if (type==DRIVE_REMOVABLE) { typestr=_(types[5]); item->image(&floppy_pix); }
                    else if (type==DRIVE_FIXED)     typestr=_(types[6]);
                    else if (type==DRIVE_REMOTE)        typestr=_(types[7]);
                    else if (type==DRIVE_RAMDISK)   typestr=_(types[8]);

                    item->label(2, typestr);

                    uint s = 0;
                    Fl_String suffix;
                    if((s = get_dev_size(attr->capacity, suffix))>0) {
                        item->label(3, Fl_String(s)+" "+suffix);
                    }
                    if((s = get_dev_size(attr->free, suffix))>0) {
                        item->label(4, Fl_String(s)+" "+suffix);
                    }

                    /*
                     //TOO SLOW!!!
                     char drivename[255];
                     if(GetVolumeInformation(
                     filename, drivename, sizeof(drivename)-1,
                     NULL, NULL, NULL, NULL, 0))
                     {
                     if(drivename[0])
                     snprintf(fname, sizeof(fname)-1, "%s (%s)", filename, drivename);
                     }
                     */
                }

            }
        }
#else
        header()->add_column(_("File"), 100);
        header()->add_column(_("Device"), 100);
        header()->add_column(_("Type"), 100);

        FILE    *mtab = 0;      // /etc/mtab or /etc/mnttab file
        char    line[1024];     // Input line
        char    dev[256];       // Device name
        char    fstype[256];    // Filesystem type

        // Open the file that contains a list of mounted filesystems...
#  if defined(__hpux) || defined(__sun)
        // Fairly standard
        mtab = fl_fopen("/etc/mnttab", "r");
#  elif defined(__sgi) || defined(linux)
        // More standard
        mtab = fl_fopen("/etc/mtab", "r");
#  endif
        // Otherwise fallback to full list
        if(mtab == NULL) mtab = fl_fopen("/etc/fstab", "r");
        if(mtab == NULL) mtab = fl_fopen("/etc/vfstab", "r");

        if (mtab != NULL)
        {
            while (fgets(line, sizeof(line), mtab) != NULL)
            {
                if (line[0] == '#' || line[0] == '\n')
                    continue;
                if (sscanf(line, "%255s%4095s%255s", dev, filename, fstype) != 3)
                    continue;
                if(!strcasecmp(dev, "none"))
                    continue;

                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                item->label(1, filename);
                item->label(2, dev);
                item->label(3, fstype);
            }
            fclose(mtab);
        }
#endif // _WIN32
        end();
        resizable_col(0, false);
        return children();

    } else {
Пример #15
0
int name_to_svalue(char *hotkey)
{
	static struct {
		char *name;
		int value;
	} keys[] = {
		{"alt",  	FL_ALT},
		{"ctrl",  	FL_CTRL},
		{"shift",  	FL_SHIFT},
		{"win",  	FL_WIN},
		{"space",  	FL_Space},
		{"backspace",	FL_BackSpace},
		{"tab",  	FL_Tab},
		{"enter",  	FL_Enter},
		{"escape",  	FL_Escape},
		{"home",  	FL_Home},
		{"left",  	FL_Left},
		{"up",  	FL_Up},
		{"right",  	FL_Right},
		{"down",  	FL_Down},
		{"pageup",  	FL_Page_Up},
		{"pagedown",  	FL_Page_Down},
		{"end",  	FL_End},
		{"insert",  	FL_Insert},
		{"delete",  	FL_Delete},
		{"f1",  	FL_F(1)},
		{"f2",  	FL_F(2)},
		{"f3",  	FL_F(3)},
		{"f4",  	FL_F(4)},
		{"f5",  	FL_F(5)},
		{"f6",  	FL_F(6)},
		{"f7",  	FL_F(7)},
		{"f8",  	FL_F(8)},
		{"f9",  	FL_F(9)},
		{"f10",  	FL_F(10)},
		{"f11",  	FL_F(11)},
		{"f12",  	FL_F(12)},
		{0, 0}
	};
	int parsed = 0;
	char f[20];

	// The parser - case insensitive and hopefully robust
	Fl_String_List elements(hotkey, "+");
	for (unsigned int i=0; i<elements.count(); i++) {
		bool found = false;
		for (int j=0; keys[j].value; j++) {
			Fl_String buf = Fl_String(keys[j].name);
			if (!elements.item(i).casecmp(buf)) {
				parsed += keys[j].value;
				found = true;
			}
		}

		if (!found) {
		// use first letter as shortcut key
			strcpy(f, elements.item(i));
			if ((f[0] >= 'a') && (f[0] <= 'z')) {
				parsed += f[0];
			} else if ((f[0] >= 'A') && (f[0] <= 'Z')) {
				parsed += (f[0] - 'A' + 'a');
			}
		}
	}

	return parsed;
}
Пример #16
0
void setshortcutfor(Fl_String action, int svalue)
{
    for (int i=0; i<NR_HOTKEYS; i++)
        if (action == Fl_String(hotkeys[i].uiname)) keycodes[i] = svalue;
}
Пример #17
0
void dialog_callback(Fl_Widget *widget,void *data) {
    // we only want to process user-defined buttons here
    if (widget->argument() > Fl_Dialog::BTN_HELP) {
        fl_alert("User defined button clicked.\nButton id is "+Fl_String((int)widget->argument()));
    }
}
Пример #18
0
Fl_String Fl_Date_Time::date_string() const {	
   char  buffer[32];
   format_date(buffer);
   return Fl_String(buffer);
}