Filter:   InfoImg
download Fl_FileChooser.cxx
Language: C++
LOC: 208
Project Info
Fast Light Tool Kit(fltk)
Server: SourceForge
Type: cvs
...Forge\f\fltk\fltk\fltk\src\
   allfiles.xbm
   ARRAY.h
   browser_minus.xbm
   browser_plus.xbm
   cmap.cxx
   CycleButton.cxx
   d1.xbm
   d1_mask.xbm
   dlload_osx.cxx
   dump_compose.c
   ew.xbm
   ew_mask.xbm
   fastarrow.h
   filename_absolute.cxx
   filename_expand.cxx
   filename_ext.cxx
   filename_isdir.cxx
   filename_list.cxx
   filename_match.cxx
   filename_setext.cxx
   Fl.cxx
   Fl_abort.cxx
   Fl_add_idle.cxx
   Fl_Adjuster.cxx
   Fl_Align_Group.cxx
   fl_arc.cxx
   fl_arci.cxx
   Fl_arg.cxx
   fl_ask.cxx
   Fl_Bar.cxx
   Fl_Bitmap.cxx
   fl_bmp.cxx
   Fl_Box.cxx
   Fl_Boxtype.cxx
   Fl_Browser.cxx
   Fl_Browser_load.cxx
   Fl_Button.cxx
   fl_call_main.c
   Fl_Check_Button.cxx
   Fl_Choice.cxx
   fl_clip.cxx
   Fl_Clock.cxx
   fl_cmap.h
   fl_color.cxx
   Fl_Color_Chooser.cxx
   fl_color_mac.cxx
   fl_color_win32.cxx
   fl_color_x.cxx
   Fl_compose.cxx
   fl_cursor.cxx
   fl_curve.cxx
   Fl_Dial.cxx
   fl_diamond_box.cxx
   Fl_display.cxx
   fl_dnd.cxx
   fl_dnd_mac.cxx
   fl_dnd_win32.cxx
   fl_dnd_x.cxx
   fl_draw.cxx
   fl_draw_image.cxx
   fl_draw_image_mac.cxx
   fl_draw_image_win32.cxx
   fl_draw_image_x.cxx
   fl_draw_pixmap.cxx
   fl_engraved_label.cxx
   fl_file_chooser.cxx
   Fl_FileBrowser.cxx
   Fl_FileChooser.cxx
   Fl_FileChooser.fl
   Fl_FileChooser2.cxx
   Fl_FileIcon.cxx
   Fl_FileIcon2.cxx
   Fl_FileInput.cxx
   Fl_Float_Input.cxx
   fl_font.cxx
   fl_font_mac.cxx
   fl_font_win32.cxx
   fl_font_x.cxx
   fl_font_xft.cxx
   Fl_get_key.cxx
   Fl_get_key_mac.cxx
   Fl_get_key_win32.cxx
   fl_gif.cxx
   fl_glyph.cxx
   Fl_Group.cxx
   Fl_Help_Dialog.cxx
   Fl_Help_View.cxx
   Fl_Highlight_Button.cxx
   Fl_Image.cxx
   Fl_Input.cxx
   Fl_Input_Browser.cxx
   Fl_Item.cxx
   Fl_key_name.cxx
   fl_labeltype.cxx
   Fl_Light_Button.cxx
   fl_list_fonts.cxx
   fl_list_fonts_mac.cxx
   fl_list_fonts_win32.cxx
   fl_list_fonts_x.cxx
   fl_load_plugin.cxx
   Fl_lock.cxx
   Fl_mac.cxx
   Fl_Menu.cxx
   Fl_Menu_.cxx
   Fl_Menu_add.cxx
   Fl_Menu_Bar.cxx
   Fl_Menu_Button.cxx
   Fl_Menu_global.cxx
   Fl_Menu_Item.cxx
   Fl_Menu_Window.cxx
   Fl_Multi_Image.cxx
   Fl_Numeric_Input.cxx
   Fl_Output.cxx
   fl_oval_box.cxx
   fl_overlay.cxx
   fl_overlay_visual.cxx
   Fl_own_colormap.cxx
   Fl_Pack.cxx
   Fl_Pixmap.cxx
   fl_plastic_box.cxx
   Fl_ProgressBar.cxx
   Fl_Radio_Button.cxx
   fl_rect.cxx
   Fl_Repeat_Button.cxx
   Fl_Return_Button.cxx
   fl_rgb.cxx
   Fl_RGB_Image.cxx
   Fl_Roller.cxx
   fl_round_box.cxx
   fl_rounded_box.cxx
   Fl_Scroll.cxx
   fl_scroll_area.cxx
   Fl_Scrollbar.cxx
   fl_set_fonts_mac.cxx
   fl_shadow_box.cxx
   Fl_Shaped_Window.cxx
   Fl_Shared_Image.cxx
   fl_show_colormap.cxx
   Fl_Single_Window.cxx
   Fl_Slider.cxx
   Fl_String_List.cxx
   Fl_Style.cxx
   Fl_Style_Set.cxx
   fl_symbols.cxx
   Fl_Tabs.cxx
   Fl_Text_Buffer.cxx
   Fl_Text_Display.cxx
   Fl_Text_Editor.cxx
   Fl_Tile.cxx
   Fl_Tiled_Image.cxx
   Fl_Tooltip.cxx
   Fl_Valuator.cxx
   Fl_Value_Input.cxx
   Fl_Value_Slider.cxx
   fl_vertex.cxx
   Fl_visual.cxx
   Fl_Widget.cxx
   Fl_win32.cxx
   Fl_Window.cxx
   Fl_Window_fullscreen.cxx
   Fl_Window_hotspot.cxx
   Fl_Window_iconize.cxx
   Fl_x.cxx
   Fl_XColor.h
   fl_xpm.cxx
   fltk_theme.cxx
   fltk_theme_win32.cxx
   fltk_theme_x.cxx
   IFont.h
   mediumarrow.h
   new.xbm
   ns.xbm
   ns_mask.xbm
   pktdef.h
   scandir.c
   scandir_win32.c
   shortcuts.cxx
   slowarrow.h
   string.c
   up.xbm
   utf.c
   ValueOutput.cxx
   vsnprintf.c
   wintab.h
   wintabx.h
   XColorMap.h
   xutf8.cxx

// generated by Fast Light User Interface Designer (fluid) version 2.0000

#include <fltk/FileChooser.h>
#include <fltk/string.h>
#include <fltk/xbmImage.h>
using namespace fltk;

inline void FileChooser::cb_window_i(Window*, void*) {
  fileList->deselect();
  fileName->value("");
  window->hide();
}
void FileChooser::cb_window(Window* o, void* v) {
  ((FileChooser*)(o->user_data()))->cb_window_i(o,v);
}

inline void FileChooser::cb_dirMenu_i(Choice*, void*) {
  Widget* w = dirMenu->get_item();
  // dirMenu reserved zero for "My Computer"
  directory((dirMenu->value() > 0 && w) ? w->label() : "");
}
void FileChooser::cb_dirMenu(Choice* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_dirMenu_i(o,v);
}

inline void FileChooser::cb_upButton_i(Button*, void*) {
  up();
}
void FileChooser::cb_upButton(Button* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_upButton_i(o,v);
}

static unsigned char bits_up[] =
"\0\0x\0\204\0\2\1""1\376y\200\375\200""1\200""1\200""1\200""1\200""1\200\1\
\200\1\200\377\377\0\0";
static xbmImage bitmap_up(bits_up, 16, 16);

inline void FileChooser::cb_newButton_i(Button*, void*) {
  newdir();
}
void FileChooser::cb_newButton(Button* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_newButton_i(o,v);
}

static unsigned char bits_new[] =
"\0\0x\0\204\0\2\1\1\376\1\200""1\200""1\200\375\200\375\200""1\200""1\200\1\
\200\1\200\377\377\0\0";
static xbmImage bitmap_new(bits_new, 16, 16);

inline void FileChooser::cb__i(Button*, void*) {
  fileList->filter("*");;
  rescan();
}
void FileChooser::cb_(Button* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb__i(o,v);
}

static unsigned char bits_allfiles[] =
"\374?\4 \4 \4 \204!\244%\304#\364/\364/\304#\244%\204!\4 \4 \4 \374?";
static xbmImage bitmap_allfiles(bits_allfiles, 16, 16);

inline void FileChooser::cb_fileList_i(FileBrowser*, void*) {
  fileListCB();
}
void FileChooser::cb_fileList(FileBrowser* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_fileList_i(o,v);
}

inline void FileChooser::cb_fileName_i(FileInput*, void*) {
  fileNameCB();
}
void FileChooser::cb_fileName(FileInput* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_fileName_i(o,v);
}

inline void FileChooser::cb_okButton_i(ReturnButton*, void*) {
  char pathname[1024];

  snprintf(pathname, sizeof(pathname), "%s/%s",
	   fileList->directory(), fileName->value());
  if (filename_isdir(pathname))
    directory(pathname);
  else
    window->hide();
}

void FileChooser::cb_okButton(ReturnButton* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_okButton_i(o,v);
}

inline void FileChooser::cb_Cancel_i(Button*, void*) {
  fileList->deselect();
  fileName->value("");
  window->hide();
}
void FileChooser::cb_Cancel(Button* o, void* v) {
  ((FileChooser*)(o->parent()->user_data()))->cb_Cancel_i(o,v);
}

FileChooser::FileChooser(const char *d, const char *p, int t, const char *title) {
  { Window* o = window = new Window(375, 315, "Pick a File");
  o->begin();
    o->callback((Callback*)cb_window, (void*)(this));
    ((Window*)(o))->hotspot(o);
    { Choice* o = dirMenu = new Choice(65, 10, 210, 25, "Directory:"); o->begin();
      o->callback((Callback*)cb_dirMenu);
      o->tooltip("Click to access directory tree.");
      o->set_flag(ALIGN_LEFT | ALIGN_RIGHT);
        o->align(ALIGN_LEFT | ALIGN_RIGHT);
      o->end();
    }
    { Button* o = upButton = new Button(280, 10, 25, 25);
      o->image(bitmap_up);
      o->labelsize(8);
      o->callback((Callback*)cb_upButton);
      o->tooltip("Click to display parent directory.");
    }
    { Button* o = newButton = new Button(310, 10, 25, 25);
      o->image(bitmap_new);
      o->labelsize(8);
      o->callback((Callback*)cb_newButton);
      o->tooltip("Click to create a new directory.");
    }
    { Button* o = new Button(340, 10, 25, 25);
      o->image(bitmap_allfiles);
      o->labelcolor((Color)4);
      o->labelsize(28);
      o->callback((Callback*)cb_);
      o->align(ALIGN_CENTER|ALIGN_INSIDE);
      o->tooltip("Click to show all files.");
    }
    { FileBrowser* o = fileList = new FileBrowser(10, 45, 355, 180);
      o->callback((Callback*)cb_fileList);
      o->when(o->when() | fltk::WHEN_ENTER_KEY);
      Group::current()->resizable(o);
      o->tooltip("Double-click to change directories.");
    }
    { FileInput* o = fileName = new FileInput(10, 245, 355, 25, "Filename:");
      o->callback((Callback*)cb_fileName);
      o->align(ALIGN_TOP | ALIGN_LEFT);
      o->when(WHEN_ENTER_KEY);
      o->tooltip("Type a filename or directory name here.");
      fileName->when(WHEN_CHANGED | WHEN_ENTER_KEY_ALWAYS);
    }
    { ReturnButton* o = okButton = new ReturnButton(240, 280, 55, 25, "OK");
      o->shortcut(0xff0d);
      o->callback((Callback*)cb_okButton);
    }
    { Button* o = new Button(300, 280, 65, 25, "Cancel");
      o->callback((Callback*)cb_Cancel);
    }
    if (title) window->label(title);
    o->end();
  }
  window->size_range(345, 270, 345);
  fileList->filter(p);
  type(t);
  value(d);
}

void FileChooser::color(Color c) {
  fileList->color(c);
}

Color FileChooser::color() {
  return (fileList->color());
}

char * FileChooser::directory() {
  return directory_;
}

void FileChooser::filter(const char *p) {
  fileList->filter(p);
  rescan();
}

const char * FileChooser::filter() {
  return (fileList->filter());
}

void FileChooser::hide() {
  window->hide();
}

void FileChooser::icon_size(uchar s) {
  fileList->icon_size(s);
}

uchar FileChooser::icon_size() {
  return (fileList->icon_size());
}

void FileChooser::label(const char *l) {
  window->label(l);
}

const char * FileChooser::label() {
  return (window->label());
}

void FileChooser::exec() {
  window->exec();
  fileList->deselect();
}

void FileChooser::textcolor(Color c) {
  fileList->textcolor(c);
}

Color FileChooser::textcolor() {
  return (fileList->textcolor());
}

void FileChooser::textfont(Font* f) {
  fileList->textfont(f);
}

Font* FileChooser::textfont() {
  return (fileList->textfont());
}

void FileChooser::textsize(uchar s) {
  fileList->textsize(s);
}

void FileChooser::type(int t) {
  type_ = t;
  if (t == MULTI)
    fileList->type(Browser::MULTI);
  else
    fileList->type(Browser::NORMAL);
  if (t != CREATE)
    newButton->deactivate();
  else
    newButton->activate();
}

int FileChooser::type() {
  return (type_);
}

int FileChooser::visible() {
  return window->visible();
}