/*---------------------------------------------------------------------------*/ void ctk_filedialog_open(CC_REGISTER_ARG struct ctk_filedialog_state *s, const char *buttontext, process_event_t event) { ctk_dialog_new(&dialog, 20, 5 + FILES_HEIGHT); CTK_WIDGET_ADD(&dialog, &leftptrlabel); CTK_WIDGET_ADD(&dialog, &fileslabel); CTK_WIDGET_ADD(&dialog, &rightptrlabel); CTK_WIDGET_ADD(&dialog, &filenameentry); CTK_BUTTON_NEW(&button, 1, 4 + FILES_HEIGHT, strlen(buttontext), (char *)buttontext); CTK_WIDGET_ADD(&dialog, &button); ctk_dialog_open(&dialog); state = STATE_OPEN; memset(filename, 0, sizeof(filename)); memset(leftptr, ' ', sizeof(leftptr)); memset(rightptr, ' ', sizeof(rightptr)); memset(files, 0, sizeof(files)); fileptr = 0; dirfileptr = 0; showptr(); cfs_opendir(&dir, "."); process_post(PROCESS_CURRENT(), PROCESS_EVENT_CONTINUE, s); }
/*-----------------------------------------------------------------------------------*/ static void * add_pagewidget(char *text, unsigned char len, unsigned char type, unsigned char border) { register struct ctk_widget *lptr; register char *wptr; static unsigned char maxwidth; static void *dataptr; if(!loading) { return NULL; } if(len + border == 0) { return NULL; } maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border); /* If the text of the link is too long so that it does not fit into the width of the current window, counting from the current x coordinate, we first try to jump to the next line. */ if(len + x > maxwidth) { htmlparser_newline(); if(!loading) { return NULL; } } /* If the text of the link still is too long, we just chop it off! XXX: this is not really the right thing to do, we should probably either make a link into a multiline link, or add multiple buttons. But this will do for now. */ if(len > maxwidth) { text[maxwidth] = 0; len = maxwidth; } dataptr = NULL; if(firsty == pagey) { wptr = webpageptr; /* To save memory, we'll copy the widget text to the web page drawing area and reference it from there. */ wptr[0] = 0; wptr += border; memcpy(wptr, text, len); wptr[len] = 0; wptr[len + border] = ' '; if(pagewidgetptr < WWW_CONF_MAX_NUMPAGEWIDGETS) { dataptr = &pagewidgetattribs[pagewidgetptr]; lptr = &pagewidgets[pagewidgetptr]; switch(type) { case CTK_WIDGET_HYPERLINK: CTK_HYPERLINK_NEW((struct ctk_hyperlink *)lptr, x, y + 3, len, wptr, dataptr); break; case CTK_WIDGET_BUTTON: CTK_BUTTON_NEW((struct ctk_button *)lptr, x, y + 3, len, wptr); ((struct formattribs *)dataptr)->inputvalue = wptr; break; case CTK_WIDGET_TEXTENTRY: CTK_TEXTENTRY_NEW((struct ctk_textentry *)lptr, x, y + 3, len, 1, wptr, len); ((struct formattribs *)dataptr)->inputvalue = wptr; break; } CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE); CTK_WIDGET_ADD(&mainwindow, lptr); ++pagewidgetptr; } } /* Increase the x coordinate with the length of the link text plus the extra space behind it and the CTK button markers. */ len = len + 1 + 2 * border; x += len; if(firsty == pagey) { webpageptr += len; } if(x == WWW_CONF_WEBPAGE_WIDTH) { htmlparser_newline(); } return dataptr; }