36 #include "ctk/ctk-filedialog.h"
42 #define MAX_NUMFILES 40
43 #define FILES_WIDTH 17
45 #define FILES_HEIGHT FILES_CONF_HEIGHT
47 #define FILES_HEIGHT 14
51 static char leftptr[FILES_HEIGHT];
52 static struct ctk_label leftptrlabel =
53 {
CTK_LABEL(0, 1, 1, FILES_HEIGHT, leftptr)};
55 static char files[FILES_WIDTH * MAX_NUMFILES];
56 static struct ctk_label fileslabel =
58 FILES_WIDTH, FILES_HEIGHT, files)};
60 static char rightptr[FILES_HEIGHT];
61 static struct ctk_label rightptrlabel =
62 {
CTK_LABEL(1 + FILES_WIDTH, 1, 1, FILES_HEIGHT, rightptr)};
64 static char filename[FILES_WIDTH + 1];
65 static struct ctk_textentry filenameentry =
69 static struct ctk_button button;
71 #define STATE_CLOSED 0
73 static char state = STATE_CLOSED;
74 static unsigned char fileptr, dirfileptr;
75 static struct cfs_dir dir;
80 leftptr[fileptr] =
' ';
81 rightptr[fileptr] =
' ';
87 leftptr[fileptr] =
'>';
88 rightptr[fileptr] =
'<';
91 &files[fileptr * FILES_WIDTH],
102 state = STATE_CLOSED;
107 const char *buttontext, process_event_t event)
109 ctk_dialog_new(&dialog, 20, 5 + FILES_HEIGHT);
114 CTK_BUTTON_NEW(&button, 1, 4 + FILES_HEIGHT, strlen(buttontext), (
char *)buttontext);
116 ctk_dialog_open(&dialog);
118 memset(filename, 0,
sizeof(filename));
119 memset(leftptr,
' ',
sizeof(leftptr));
120 memset(rightptr,
' ',
sizeof(rightptr));
121 memset(files, 0,
sizeof(files));
131 ctk_filedialog_eventhandler(
struct ctk_filedialog_state *s,
132 process_event_t ev, process_data_t data)
134 static struct cfs_dirent dirent;
136 if(state == STATE_OPEN) {
138 data == (process_data_t)&button) {
140 state = STATE_CLOSED;
143 }
else if(ev == PROCESS_EVENT_CONTINUE &&
144 (process_data_t)s == data) {
146 dirfileptr < MAX_NUMFILES) {
147 strncpy(&files[dirfileptr * FILES_WIDTH],
148 dirent.name, FILES_WIDTH);
167 if(fileptr < FILES_HEIGHT - 1) {
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
#define CTK_WIDGET_ADD(win, widg)
Add a widget to a window.
char ctk_arch_key_t
The keyboard character type of the system.
#define CTK_TEXTENTRY(x, y, w, h, text, len)
Instantiating macro for the ctk_textentry widget.
int cfs_readdir(struct cfs_dir *dir, struct cfs_dirent *record)
Read a directory entry.
int process_post(struct process *p, process_event_t ev, process_data_t data)
Post an asynchronous event.
#define CTK_LABEL(x, y, w, h, text)
Instantiating macro for the ctk_label widget.
process_event_t ctk_signal_keypress
Emitted for every key being pressed.
void cfs_closedir(struct cfs_dir *dir)
Close a directory opened with cfs_opendir().
process_event_t ctk_signal_widget_activate
Emitted when a widget is activated (pressed).
#define CC_REGISTER_ARG
Configure if the C compiler supports the "register" keyword for function arguments.
int cfs_opendir(struct cfs_dir *dir, const char *name)
Open a directory for reading directory entries.
Representation of a CTK window.
#define CTK_WIDGET_REDRAW(widg)
Add a widget to the redraw queue.