37 #include "lib/ctk-filedialog.h"
43 #define MAX_NUMFILES 40
44 #define FILES_WIDTH 17
46 #define FILES_HEIGHT FILES_CONF_HEIGHT
48 #define FILES_HEIGHT 14
52 static char leftptr[FILES_HEIGHT];
53 static struct ctk_label leftptrlabel =
54 {
CTK_LABEL(0, 1, 1, FILES_HEIGHT, leftptr)};
56 static char files[FILES_WIDTH * MAX_NUMFILES];
57 static struct ctk_label fileslabel =
59 FILES_WIDTH, FILES_HEIGHT, files)};
61 static char rightptr[FILES_HEIGHT];
62 static struct ctk_label rightptrlabel =
63 {
CTK_LABEL(1 + FILES_WIDTH, 1, 1, FILES_HEIGHT, rightptr)};
65 static char filename[FILES_WIDTH + 1];
66 static struct ctk_textentry filenameentry =
70 static struct ctk_button button;
72 #define STATE_CLOSED 0
74 static char state = STATE_CLOSED;
75 static unsigned char fileptr, dirfileptr;
76 static struct cfs_dir dir;
81 leftptr[fileptr] =
' ';
82 rightptr[fileptr] =
' ';
88 leftptr[fileptr] =
'>';
89 rightptr[fileptr] =
'<';
92 &files[fileptr * FILES_WIDTH],
103 state = STATE_CLOSED;
108 const char *buttontext, process_event_t event)
110 ctk_dialog_new(&dialog, 20, 5 + FILES_HEIGHT);
115 CTK_BUTTON_NEW(&button, 1, 4 + FILES_HEIGHT, strlen(buttontext), (
char *)buttontext);
117 ctk_dialog_open(&dialog);
119 memset(filename, 0,
sizeof(filename));
120 memset(leftptr,
' ',
sizeof(leftptr));
121 memset(rightptr,
' ',
sizeof(rightptr));
122 memset(files, 0,
sizeof(files));
132 ctk_filedialog_eventhandler(
struct ctk_filedialog_state *s,
133 process_event_t ev, process_data_t data)
135 static struct cfs_dirent dirent;
137 if(state == STATE_OPEN) {
139 data == (process_data_t)&button) {
141 state = STATE_CLOSED;
144 }
else if(ev == PROCESS_EVENT_CONTINUE &&
145 (process_data_t)s == data) {
147 dirfileptr < MAX_NUMFILES) {
148 strncpy(&files[dirfileptr * FILES_WIDTH],
149 dirent.name, FILES_WIDTH);
168 if(fileptr < FILES_HEIGHT - 1) {