Widget Set#1 Page  
by Curtis Edwards (c) 1998 ( Version Changes (Tested under fltk-19980910) )

Fl_File_Dialog     Fl_File_Input     Fl_Dir     Fl_Pack     Fl_Pix_Box     Fl_Pix_Button      Fl_Frametab
 

  • Fl_File_Dialog This Dialog provides a  easy method to choose files from large directories. Some of the unique features are-:
    Tab key completes filenames,Sorting Options,Filter Options,Pattern Match Options and Line Pattern Matching.
    (Unix - Colored listing of symbolic links, bolding of  exe files and pre-lookup before fstat call (very fast))

     
    #include <FL/Fl_File_Dialog.H>
    int  fl_file_dialog(const char* title, char* pathAndFile,  int sortType=0, int filterType=0,int Mode);

    The returned value will be FALSE if cancel pressed, else the value will be length to last slash in pathAndFile ,pathAndFile also will be set to NULL if no selection is valid or the cancel is pressed.

    Directory Bar (Slash Bar)
    This will maintain a division at each directory, pressing the button before will change the directory to the location represented by the division

    Quick Fix Menu (Right Mouse in input Field)
    This will present a list of quick directory locations

    Quick Fix Defaults
    Fl_Menu pulldown[] = {
      {"Up directory",     0},
      {"Root directory",   0},
      {"Home directory",   0},
    ... (rest are for stack of last accessed directories)

    SortType  (will slow to do fstat call if  sort is not alpha/numeric)

    Fl_Menu menuSort[] = {
     {"Alpha"        , 97,  0, 0, 0, 0, 3, 14, 0},
     {"Alpha NoCase" ,  0,  0, 0, 0, 0, 3, 14, 0},
     {"Alpha Reverse",  0,  0, 0, 0, 0, 3, 14, 0},
     {"Numeric"      ,  0,  0, 0, 0, 0, 3, 14, 0},
     {"Time"         ,  0,  0, 0, 0, 0, 3, 14, 0},
     {"Size"         ,  0,  0, 0, 0, 0, 3, 14, 0},
     {"None"         ,  0,  0, 0, 0, 0, 3, 14, 0},
     {"Directories"  ,  0,  0, 0, 0, 0, 3, 14, 0},
     {0}
    };

    FilterType - (will slow to do fstat call first if a filterType is set)

    Fl_Menu menuFilter[] = {
     {"Directories"        ,100, 0, 0, FL_MENU_CHECK|FL_MENU_BOX},
     {"Files"              ,0, 0, 0, FL_MENU_CHECK|FL_MENU_BOX},
     {"Hidden (Dot Files)" ,0, 0, 0, FL_MENU_CHECK|FL_MENU_BOX},
     {"Executables"        ,0, 0, 0, FL_MENU_CHECK|FL_MENU_BOX},
     {"Symbolic Links"     ,0, 0, 0, FL_MENU_CHECK|FL_MENU_BOX},
     {0}

     Default Patterns

    Fl_Menu menuPattern[] = {
    {"*"          ,49},
     {"*.*"        ,50},
     {"*.txt"      ,51},
     {"*.sgi"      ,52},
     {"*.bmp"      ,53},
     {"*.aiff"     ,54},
     {"*.wav"      ,55},
     {"*.html"     ,56},
     {"*.C*"       ,57},
     {"*.H*"       ,58},
     {0}
    }; Example:

       char selection[FL_MAX_PATH];
       int slash;
       strcpy(selection, "*.*");   //setlocation and/or path
       slash = fl_file_dialog("Open File",selection,0,0,1);
       if(slash) fl_message((char*)(selection+slash));           //the slash is 0 if nothing selected else it will be the length to the slash
     

    Fl_File_Input

    The main class for the directory stuff ,it combines both Fl_Dir and Fl_Input to provide a elegant solution for directories and files.
    It has Tab Completion and will turn Red if an error condition exists. i.e. invalid file /invalid directory.
    This gives the ability to show the directory without the browser or select from the File_Dialog and place the contents in this widget.
    this give the user the chance to change the information or directory and insuring that the new data is current.

    This also contains the Quick Fix menus
    "Up directory"
    "Root directory"
    "Home directory"
    "Current directory"
     

    Fl_Dir

    This Class is the main core of the directory managment for FL_File_Dialog & Fl_Input_File
    typedef struct Fl_Dir_File
    {
        char   name[FL_MAX_FILENAME];
        int    nameLen;                // index to lastchar in name
        int    type;
        long   size;
        time_t time;
        int display;                //the item should be hidded in the GUI from the user (pattern match)
    } Fl_Dir_File;

    Fl_Dir( char *pathAndFile, int sortType = FL_SORT_NAME, int filterType = 0 );

    int Fl_Input_File::getFilename(char *out)
    fillin out(path+file),return 0 if invalid selection else length to last slash

    int Fl_Input_File::setFilename(char *in)
    Use the input string to change directory and update input cd(string)
     
     Fl_Dir_File *fileList()
    return list of file entries (resets when reached nDirFiles total)

    Fl_Dir_File *fileListReset()
    force the reset for the fileList
     
    in Fl_Dir_File *fileListSet(int num){ dirListCount=num; return NULL;}
    set the list to a number(ie..tracking progress)

     Fl_Dir_File *fileInList(char *file,int filteronoff=1)
    check if file is currently shown in dir List,use Spec&filter TRUE/FALSE;

    int  dirSort(int type)
    main function to do sorting
     int  dirSetSort(int type)
    set the sort type
     int  dirSetFilter(int flags)
    set the Filter type
    int  dirToggelFilter(int flags)
    toggle the current flag Filter  ON/OFF
    int  dirIsFilter(int flags)
     return if Filter flag is set
     int  dirSetDisplay(char *dir);
     set the display flag for files maching pattern
     void dirHaltScan()
     request that the scan be stopped,done by GUI
    void dirResetScan()
     reset the scan to start from start.

    void  dir_callback1(Dir_Callback* c=NULL, void* p=0)
    callback when directory changed and needs refresh

    dir_callback_error_(this,dir_user_data_error_);}
    error ,callback when error condition

    cd(const char *buf);
     set the directory to this if needed
     int  cdUp();
     change up one directory
     int  cdRoot();
     goto root directory or NT C:
     int  cdHome();
     look for env HOME and change if exists
     int  cdCurrent();
     change to current directory
    int cdSub(char *);
    change to a subdirectory, off the current directory (dont need full path) you can scan if a directory/File exist's and change into it (sub) or process it (file). changing up or down the directory tree.  eg. cdSub("home");  if the user is in the root directory, it will try "/home"

     int  tabComplete(const char *dir,char *buf);
      try to do tab complete on the dir list
     int  lenSlashPattern(char *ch,int &slash=tmpInt,int &hasPattern=tmpInt,int &prevSlash=tmpInt);
     this function returns the length of str,slash,pattern,and prev slash (very usefull)
     int  simpleExp( const char *s, const char *e, int CaseSens = TRUE );
     Test for the pattern matching
    int  filename_expand(char *t,const char *f)
     check for ~,$HOME etc..

     see FL_File_Dialog example

    Fl_Pack

    This widget was designed to add the functionality of compressing and aligning widgets. It is now included in the main Fltk Library and should be referenced there.

    Fl_Pix_Box

    Fl_Pix_Box(int x,int y,int w,int h,const char *l = 0,Fl_Pixmap* bUp=0);
    The main use of the Fl_Pix_Box is to place a PIX in the box ,TILING the pix and cropping if the box size is bigger or smaller
    see PIX_BUTTON example.

    Fl_Pix_Button

    Fl_Pix_Button(int x,int y,int w,int h,const char *l = 0,Fl_Pixmap* bUp=0,Fl_Pixmap* bDown=0,Fl_Pixmap* bHilight=0);

    Fl_Frametab

    Fl_Frametab(int x,int y,int w,int h, char *fname)

    Drop down Tab style group widget, can contain other widgets.
     

    Changes up to 1.3  

    FileDialog/File_Input/FL_Dir

  • Bug in Tab Complete Fixed
  • Is now Modal.
  • Message box replaced with message bar.
  • Sub directories now set to show when filter is on.
  • Sort bug fixed.
  • Dialog can now resize.
  • Executable files with * bug fixed.
  • Browser reset to top ,after a scan.
  • Startup WildCard set into top menu and selected.
  • Multi Select will not select sub directories.
  • Double Click is now the default.
  • Other widgets

  • Changes to upgrade to new Fltk Version (Labels/Font/Color)
  •