summaryrefslogtreecommitdiff
path: root/test/file_chooser.cxx
blob: e2b366ce2d02a4d0c6a5e8ebbf679ea750181f68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*	Test fl_file_chooser()	*/

#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/fl_file_chooser.H>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

Fl_Input *pattern, *current;

void pickfile(Fl_Widget *) {
  const char *p;
  p = fl_file_chooser("Pick a file",pattern->value(),current->value());
  if (p) current->value(p);
}

void thecb(const char *name) {
  printf("Callback '%s'\n",name);
}

int main(int argc, char **argv) {
  Fl_Window window(400,200);
  pattern = new Fl_Input(100,50,280,30,"Pattern:");
  pattern->static_value("*");
  current = new Fl_Input(100,90,280,30,"Current:");
  Fl_Button button(100,120,100,30,"&Choose file");
  button.callback(pickfile);
  window.end();
  window.show(argc, argv);
  fl_file_chooser_callback(thecb);
  return Fl::run();
}