Widget Set #1 by Curtis Edwards (c) 1999
Version 1.3 ( Version Changes as of fltk-19990113 )

Fl_File_Dialog
Fl_File_Input
Fl_Dir
Fl_Pack
Fl_Pix_Box
Fl_Pix_Button
Fl_Frametab
Fl_NSlider

NOTE: STILL WORKING ON THIS FILE

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

 Fl_Input_File(int,int,int,int,const char *t,char *path_File,int st=0,int ty=0 );


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 a directory without the need for  browser or selection from the File_Dialog ,also the information from a Dialog can be place the contents in this widget and give the user the chance to change the information or directory while insuring that the new data is current.

 int getFilename(char *out);

  fillin out(path+file), return 0 if invalid selection else length to last slas
 int setFilename(char *in);
  set the path and filename to use
 void  input_callback_error(Dir_Callback* c=NULL, void* p=0)
  callback if error condition
This also contains the Quick Fix menus
"Up directory"
"Root directory"
"Home directory"
"Current directory"

example:

Fl_Input_File    tDir;
char path_file[FL_MAX_PATH];
....
tDir(20, 65, 405, 35, "Resources File", path_file)
tDir.color(50);
tDir.align(5);
....

Fl_Group_Window *w =  (Fl_Group_Window *)v;
 char selection[FL_MAX_PATH+200];
 strcpy(selection, "*");   //setlocation and/or path
 fl_file_dialog("Open File",selection,0,0,0);
 tDir.setFilename(selection);
....

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 );

  constructor,insure the pathAndFile has enough roomfot the return values
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
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. (resize itself to the size of its children) If a widget is hidden the Pack Widget will shrink and shift all other widgets to fill the space and adjusting its internal size. This widget is needed for the  Fl_Frametab .If the Pack is set to Fl_Pack:HORIZONTAL the width will change if Fl_Pack:VERTICAL the height be sure to align you widgets in the opposite direction correctly and Group objects you wish to remain in a certain order (This is the method Frametab works)

Fl_Pack(int x,int y,int w ,int h,const char *l = 0);
The usual X,Y,Width height and title
 int spacing()
return current spacing, This is the space between each widget
void spacing(int i)
Set the amout of spacing ,the default is 0.
uchar horizontal()
returns if the Pack is set horizontal.
type(int)
set the typeof the Pack this can be Fl_Pack::HORIZONTAL , Fl_Pack::VERTICAL
Note: this is in the Main Lib now.

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);

Example:

{Fl_Pix_Button* o = new Fl_Pix_Button(120, 40, 130, 30, "BUTTON1" ,&pixmap_rustNormal,&pixmap_rustDown,&pixmap_rustHilight);

  o->color(51);
  o->labelfont(4);
  o->labelcolor(131);
  o->callback(cb2,o);
  }
 {Fl_Pix_Button* o = new Fl_Pix_Button(120, 90, 130, 30, "BUTTON2" ,&pixmap_rustNormal,&pixmap_rustDown,&pixmap_rustHilight);
  o->color(51);
  o->labelfont(4);
  o->labelcolor(131);
  o->callback(cb2,o);
 }
Fl_Frametab
 Fl_Frametab(int x,int y,int w, int h, char *fname)
constructor

type();   enum { TRIANGLE = 0, BITMAP   = 1 (Netscape Style)};

void  close();
  Open the frame tab
void  open();
  Close the frametab
 int   isOpen()
  test for if the frametab is open
void  hilight_color(int col)
 Get or set the  hilight_color for the frametab
void  openSize(int siz)
   Get or set the open size (height) of the then frametab widget
void  openLabelHide(int yn)
   Get or set  if you want the lable to hide when the frame is open
 int   openDiff()
  Utility method to return the current  height difference if  when closed/open  (-height/+height)  - min frame
Example:
Fl_Pack* pko = (Fl_Pack*) v;
  pko->begin();
    Fl_Frametab* fto = new Fl_Frametab(0, 40, 240, 130, "Infomation #1");
 if(toggle_type == 1) toggle_type = 0;
 else {
  toggle_type =1;
        fto->labelsize(9);
 }
   fto->type(toggle_type);
      {Fl_Button* o = new Fl_Button(20, 130, 200, 30, "testButton");}
      {Fl_Input* o = new Fl_Input(120, 60, 100, 30, "input: 1"); }
      {Fl_Input* o = new Fl_Input(120, 95, 100, 30, "input: 2"); }
      fto->end();
      fto->close();
  pko->end();

Fl_NSlider

 Fl_NSlider(int x,int y,int w, int h, char *title)
 Fl_NSlider(uchar typ,int x,int y,int w, int h, char *title)
 void       hilight_color()
 Get or Set the current hilight color
 void       bounds(float a, float b)
 Set the bounds for this slider ,Min Max
Fl_Boxtype slider()
 Get or set the  type of box to draw for the moving part of the slider.
 The color of the moving part (or of the notch in it for the nice sliders) is controlled by
  selection_color(). Hilight color will draw when the mouse moves on to the widget.
void     calcButton(int &knob_x, int &knob_y, int &knob_w , int &knob_h,double val)
  Calculates wher the slider x,y,w,h is based on the value input
float   slider_size()
   Get or Set the dimensions of the moving piece of slider. This is the fraction of the size of the entire widget. If you set this to 1 then the slider cannot
   move. The default value is .06
void   alignTick( Fl_Align a)
   Get or  Set the alignment of the ticks void       colorTick( Fl_Color a)
  Set the color of the tick
void       majorTickFont( int p)
  Set the Font of the Tick
void       majorTickFontSize(int p)
 Set the Size of the font used fot the tick markings
void       majorTickPrecision(int p)
 Set the Precision of the tick (0-6)
void       minorTick(float tick)
Get or Set the minor Tick  increment


  void       majorTick(float tick)

Get or Set the major Tick  increment
 Example:
    { Fl_NSlider* o = dhoz = new Fl_NSlider(20, 30, 455, 30, "Demo Slider");
        o->type(1);
        o->labelsize(12);
        o->minimum(-100);
        o->maximum(1000);
        o->callback((Fl_Callback*)cb_dhoz);
        o->align(5);
        o->majorTick(10);
        o->minorTick(1);
        o->ramp(47,52);
      }


CHANGES
1.3


1.2