aboutsummaryrefslogtreecommitdiff
path: root/SrcUnix/espws-2.0/testfile.cxx
blob: c8f56bb721c6d8defff38926b8e638311b29c94a (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// "$Id: testfile.cxx,v 1.6 2000/01/04 13:45:55 mike Exp $"
//
//   File chooser test program.
//
//   Copyright 1997-2000 by Easy Software Products.
//
//   These coded instructions, statements, and computer programs are the
//   property of Easy Software Products and are protected by Federal
//   copyright law.  Distribution and use rights are outlined in the file
//   "COPYING" which should have been included with this file.  If this
//   file is missing or damaged please contact Easy Software Products
//   at:
//
//       Attn: ESP Licensing Information
//       Easy Software Products
//       44141 Airport View Drive, Suite 204
//       Hollywood, Maryland 20636-3111 USA
//
//       Voice: (301) 373-9600
//       EMail: info@easysw.com
//         WWW: http://www.easysw.com
//
// Contents:
//
//   main()           - Create a file chooser and wait for a selection to be
//                      made.
//   close_callback() - Close the main window...
//   show_callback()  - Show the file chooser...
//

//
// Include necessary headers...
//

#include <stdio.h>
#include "FileChooser.h"


//
// Globals...
//

Fl_Input	*filter;
FileChooser	*fc;


//
// Functions...
//

void	close_callback(void);
void	show_callback(void);


//
// 'main()' - Create a file chooser and wait for a selection to be made.
//

int			// O - Exit status
main(int  argc,		// I - Number of command-line arguments
     char *argv[])	// I - Command-line arguments
{
  Fl_Window	*window;// Main window
  Fl_Button	*button;// Buttons
  FileIcon	*icon;	// New file icon


  // Make the file chooser...
  FileIcon::load_system_icons();

  fc = new FileChooser(".", "*", FileChooser::MULTI, "FileChooser Test");
  fc->color((Fl_Color)196);

  // Make the main window...
  window = new Fl_Window(400, 80, "File Chooser Test");

  filter = new Fl_Input(50, 10, 315, 25, "Filter:");
  if (argc > 1)
    filter->value(argv[1]);

  button = new Fl_Button(365, 10, 25, 25);
  button->labelcolor(FL_YELLOW);
  button->callback((Fl_Callback *)show_callback);

  icon   = FileIcon::find(".", FileIcon::DIRECTORY);
  icon->label(button);

  button = new Fl_Button(340, 45, 50, 25, "Close");
  button->callback((Fl_Callback *)close_callback);

  window->end();
  window->show();

  Fl::run();

  return (0);
}


//
// 'close_callback()' - Close the main window...
//

void
close_callback(void)
{
  exit(0);
}


//
// 'show_callback()' - Show the file chooser...
//

void
show_callback(void)
{
  int		i;	// Looping var
  int		count;	// Number of files selected


  fc->show();
  if (filter->value()[0])
    fc->filter(filter->value());

  fc->show();

  while (fc->visible())
    Fl::wait();

  count = fc->count();
  printf("count = %d\n", count);
  for (i = 1; i <= count; i ++)
    printf("file %d = \"%s\"\n", i, fc->value(i));
}


//
// End of "$Id: testfile.cxx,v 1.6 2000/01/04 13:45:55 mike Exp $".
//