diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | dw/fltkplatform.cc | 5 | ||||
-rw-r--r-- | dw/fltkplatform.hh | 3 | ||||
-rw-r--r-- | dw/fltkui.cc | 51 | ||||
-rw-r--r-- | dw/fltkui.hh | 7 | ||||
-rw-r--r-- | dw/ui.cc | 9 | ||||
-rw-r--r-- | dw/ui.hh | 6 | ||||
-rw-r--r-- | src/form.cc | 42 | ||||
-rw-r--r-- | src/form.hh | 1 | ||||
-rw-r--r-- | src/html.cc | 13 | ||||
-rw-r--r-- | src/html.hh | 1 | ||||
-rw-r--r-- | src/menu.cc | 33 | ||||
-rw-r--r-- | src/menu.hh | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 5 | ||||
-rw-r--r-- | src/uicmd.hh | 3 | ||||
-rw-r--r-- | test/dw_ui_test.cc | 4 |
16 files changed, 161 insertions, 25 deletions
@@ -23,6 +23,7 @@ dillo-2.1 - Ported the command line interface from dillo1 (XID not working yet). - Switched file dpi error messages to HTML. - Added a popup menu to form's submit button. + - Added a right-click menu to the form submit button (allows to show hiddens). Patches: place (AKA corvid) +- Switched SSL-enabled to configure.in (./configure --enable-ssl). - Standardised the installation of dpid/dpidrc with auto* tools. diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 337f4dba..1dc1c860 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -200,9 +200,10 @@ FltkPlatform::FltkResourceFactory::createOptionMenuResource () core::ui::EntryResource * FltkPlatform::FltkResourceFactory::createEntryResource (int maxLength, - bool password) + bool password, + const char *label) { - return new ui::FltkEntryResource (platform, maxLength, password); + return new ui::FltkEntryResource (platform, maxLength, password, label); } core::ui::MultiLineTextResource * diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 7b3d3e73..7f430ee3 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -81,7 +81,8 @@ private: createListResource (core::ui::ListResource::SelectionMode selectionMode); core::ui::OptionMenuResource *createOptionMenuResource (); core::ui::EntryResource *createEntryResource (int maxLength, - bool password); + bool password, + const char *label); core::ui::MultiLineTextResource *createMultiLineTextResource (int cols, int rows); core::ui::CheckButtonResource *createCheckButtonResource (bool diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 9d9b8107..f4090521 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -199,7 +199,35 @@ void FltkResource::setWidgetStyle (::fltk::Widget *widget, } } } - + +void FltkResource::setDisplayed(bool displayed) +{ + for (Iterator <ViewAndWidget> it = viewsAndWidgets->iterator (); + it.hasNext(); ) { + ViewAndWidget *viewAndWidget = it.getNext (); + if (displayed) + viewAndWidget->widget->show(); + else + viewAndWidget->widget->hide(); + } +} + +bool FltkResource::displayed() +{ + bool ret; + Iterator <ViewAndWidget> it = viewsAndWidgets->iterator (); + + if (it.hasNext()) { + ViewAndWidget *viewAndWidget = it.getNext (); + // visible() is not the same thing as being show()n exactly, but + // show()/hide() set it appropriately for our purposes. + ret = viewAndWidget->widget->visible(); + } else { + ret = false; + } + return ret; +} + bool FltkResource::isEnabled () { /** \bug Not implemented. */ @@ -487,11 +515,12 @@ int FltkComplexButtonResource::reliefYThickness () // ---------------------------------------------------------------------- FltkEntryResource::FltkEntryResource (FltkPlatform *platform, int maxLength, - bool password): + bool password, const char *label): FltkSpecificResource <dw::core::ui::EntryResource> (platform) { this->maxLength = maxLength; this->password = password; + this->label = label ? strdup(label) : NULL; initText = NULL; editable = false; @@ -503,6 +532,8 @@ FltkEntryResource::~FltkEntryResource () { if (initText) delete initText; + if (label) + delete label; } ::fltk::Widget *FltkEntryResource::createNewWidget (core::Allocation @@ -518,6 +549,10 @@ FltkEntryResource::~FltkEntryResource () input->callback (widgetCallback, this); input->when (::fltk::WHEN_ENTER_KEY_ALWAYS); + if (label) { + input->label(label); + input->set_flag(::fltk::ALIGN_INSIDE_LEFT); + } if (viewsAndWidgets->isEmpty ()) { // First widget created, attach the set text. if (initText) @@ -529,9 +564,15 @@ FltkEntryResource::~FltkEntryResource () return input; } +void FltkEntryResource::setDisplayed(bool displayed) +{ + FltkResource::setDisplayed(displayed); + queueResize(true); +} + void FltkEntryResource::sizeRequest (core::Requisition *requisition) { - if (style) { + if (displayed() && style) { FltkFont *font = (FltkFont*)style->font; ::fltk::setfont(font->font,font->size); requisition->width = @@ -541,8 +582,8 @@ void FltkEntryResource::sizeRequest (core::Requisition *requisition) requisition->ascent = font->ascent + RELIEF_Y_THICKNESS; requisition->descent = font->descent + RELIEF_Y_THICKNESS; } else { - requisition->width = 1; - requisition->ascent = 1; + requisition->width = 0; + requisition->ascent = 0; requisition->descent = 0; } } diff --git a/dw/fltkui.hh b/dw/fltkui.hh index 4de99d27..3d19fc63 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -195,6 +195,8 @@ protected: virtual ::fltk::Widget *createNewWidget (core::Allocation *allocation) = 0; void setWidgetStyle (::fltk::Widget *widget, core::style::Style *style); + void setDisplayed (bool displayed); + bool displayed(); public: ~FltkResource (); @@ -298,15 +300,18 @@ private: int maxLength; bool password; const char *initText; + char *label; bool editable; static void widgetCallback (::fltk::Widget *widget, void *data); + void setDisplayed (bool displayed); protected: ::fltk::Widget *createNewWidget (core::Allocation *allocation); public: - FltkEntryResource (FltkPlatform *platform, int maxLength, bool password); + FltkEntryResource (FltkPlatform *platform, int maxLength, bool password, + const char *label); ~FltkEntryResource (); void sizeRequest (core::Requisition *requisition); @@ -97,6 +97,11 @@ void Embed::setDescent (int descent) resource->setDescent (descent); } +void Embed::setDisplayed (bool displayed) +{ + resource->setDisplayed (displayed); +} + void Embed::draw (View *view, Rectangle *area) { drawWidgetBox (view, area, false); @@ -196,6 +201,10 @@ void Resource::setDescent (int descent) { } +void Resource::setDisplayed (bool displayed) +{ +} + void Resource::draw (View *view, Rectangle *area) { } @@ -243,6 +243,7 @@ public: void setWidth (int width); void setAscent (int ascent); void setDescent (int descent); + void setDisplayed (bool displayed); void draw (View *view, Rectangle *area); Iterator *iterator (Content::Type mask, bool atEnd); void setStyle (style::Style *style); @@ -336,6 +337,7 @@ public: virtual void setWidth (int width); virtual void setAscent (int ascent); virtual void setDescent (int descent); + virtual void setDisplayed (bool displayed); virtual void draw (View *view, Rectangle *area); virtual Iterator *iterator (Content::Type mask, bool atEnd) = 0; virtual void setStyle (style::Style *style); @@ -539,8 +541,8 @@ public: virtual ListResource *createListResource (ListResource::SelectionMode selectionMode) = 0; virtual OptionMenuResource *createOptionMenuResource () = 0; - virtual EntryResource *createEntryResource (int maxLength, - bool password) = 0; + virtual EntryResource *createEntryResource (int maxLength, bool password, + const char *label) = 0; virtual MultiLineTextResource *createMultiLineTextResource (int cols, int rows) = 0; virtual CheckButtonResource *createCheckButtonResource (bool activated) = 0; diff --git a/src/form.cc b/src/form.cc index 76f2c32b..b20e5a95 100644 --- a/src/form.cc +++ b/src/form.cc @@ -75,6 +75,7 @@ class DilloHtmlForm { friend class DilloHtmlInput; DilloHtml *html; + bool showing_hiddens; void eventHandler(Resource *resource, EventButton *event); DilloUrl *buildQueryUrl(DilloHtmlInput *active_input); Dstr *buildQueryData(DilloHtmlInput *active_submit); @@ -114,6 +115,7 @@ public: DilloHtmlInput *getRadioInput (const char *name); void submit(DilloHtmlInput *active_input, EventButton *event); void reset (); + void display_hiddens(bool display); void addInput(DilloHtmlInput *input, DilloHtmlInputType type); }; @@ -216,6 +218,11 @@ void a_Html_form_reset2(void *vform) ((DilloHtmlForm *)vform)->reset(); } +void a_Html_form_display_hiddens2(void *vform, bool display) +{ + ((DilloHtmlForm *)vform)->display_hiddens(display); +} + /* * Form parsing functions */ @@ -438,7 +445,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_PASSWORD; attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource (size, true); + resource = factory->createEntryResource (size, true, NULL); init_str = value; } else if (!dStrcasecmp(type, "checkbox")) { inp_type = DILLO_HTML_INPUT_CHECKBOX; @@ -457,6 +464,8 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } else if (!dStrcasecmp(type, "hidden")) { inp_type = DILLO_HTML_INPUT_HIDDEN; init_str = value; + int size = Html_input_get_size(html, NULL); + resource = factory->createEntryResource(size, false, name); } else if (!dStrcasecmp(type, "submit")) { inp_type = DILLO_HTML_INPUT_SUBMIT; init_str = (value) ? value : dStrdup("submit"); @@ -514,7 +523,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_TEXT; attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource(size, false); + resource = factory->createEntryResource(size, false, NULL); init_str = value; } else { /* Unknown input type */ @@ -531,6 +540,10 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) if (embed != NULL && inp_type != DILLO_HTML_INPUT_IMAGE && inp_type != DILLO_HTML_INPUT_UNKNOWN) { + if (inp_type == DILLO_HTML_INPUT_HIDDEN) { + /* TODO Perhaps do this with access to current form setting */ + embed->setDisplayed(false); + } if (inp_type == DILLO_HTML_INPUT_TEXT || inp_type == DILLO_HTML_INPUT_PASSWORD) { if (a_Html_get_attr(html, tag, tagsize, "readonly")) @@ -587,7 +600,7 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize) DW2TB(html->dw)->addText(attrbuf, S_TOP(html)->style); ResourceFactory *factory = HT2LT(html)->getResourceFactory(); - EntryResource *entryResource = factory->createEntryResource (20, false); + EntryResource *entryResource = factory->createEntryResource (20,false,NULL); embed = new Embed (entryResource); Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE); @@ -934,6 +947,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2, inputs = new misc::SimpleVector <DilloHtmlInput*> (4); num_entry_fields = 0; num_submit_buttons = 0; + showing_hiddens = false; form_receiver = new DilloHtmlReceiver (this); } @@ -955,7 +969,7 @@ void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event) { MSG("DilloHtmlForm::eventHandler\n"); if (event && (event->button == 3)) { - a_UIcmd_form_popup(html->bw, html->page_url, this); + a_UIcmd_form_popup(html->bw, html->page_url, this, showing_hiddens); } else { DilloHtmlInput *input = getInput(resource); if (input) { @@ -1438,6 +1452,21 @@ void DilloHtmlForm::reset () } /* + * Show/hide "hidden" form controls + */ +void DilloHtmlForm::display_hiddens(bool display) +{ + int size = inputs->size(); + for (int i = 0; i < size; i++) { + DilloHtmlInput *input = inputs->get(i); + if (input->type == DILLO_HTML_INPUT_HIDDEN) { + input->embed->setDisplayed(display); + } + } + showing_hiddens = display; +} + +/* * Add a new input. */ void DilloHtmlForm::addInput(DilloHtmlInput *input, DilloHtmlInputType type) @@ -1660,6 +1689,7 @@ void DilloHtmlInput::appendValuesTo(Dlist *values, bool is_active_submit) case DILLO_HTML_INPUT_TEXT: case DILLO_HTML_INPUT_PASSWORD: case DILLO_HTML_INPUT_INDEX: + case DILLO_HTML_INPUT_HIDDEN: { EntryResource *entryres = (EntryResource*)embed->getResource(); dList_append(values, dStr_new(entryres->getText())); @@ -1687,9 +1717,6 @@ void DilloHtmlInput::appendValuesTo(Dlist *values, bool is_active_submit) if (is_active_submit) dList_append(values, dStr_new(init_str)); break; - case DILLO_HTML_INPUT_HIDDEN: - dList_append(values, dStr_new(init_str)); - break; case DILLO_HTML_INPUT_SELECT: case DILLO_HTML_INPUT_SEL_LIST: { @@ -1738,6 +1765,7 @@ void DilloHtmlInput::reset () case DILLO_HTML_INPUT_TEXT: case DILLO_HTML_INPUT_PASSWORD: case DILLO_HTML_INPUT_INDEX: + case DILLO_HTML_INPUT_HIDDEN: { EntryResource *entryres = (EntryResource*)embed->getResource(); entryres->setText(init_str ? init_str : ""); diff --git a/src/form.hh b/src/form.hh index 910efe20..fd48a18d 100644 --- a/src/form.hh +++ b/src/form.hh @@ -40,6 +40,7 @@ void a_Html_form_delete(DilloHtmlForm* form); void a_Html_input_delete(DilloHtmlInput* input); void a_Html_form_submit2(void *v_form); void a_Html_form_reset2(void *v_form); +void a_Html_form_display_hiddens2(void *v_form, bool display); /* diff --git a/src/html.cc b/src/html.cc index 1c3652ba..77128927 100644 --- a/src/html.cc +++ b/src/html.cc @@ -258,6 +258,19 @@ void a_Html_form_reset(void *v_html, void *v_form) } /* + * Used by the "Show/Hide hiddens" form menuitem. + */ +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display) +{ + DilloHtml *html = (DilloHtml*)v_html; + + if (Html_contains_form(html, v_form)) { + /* it's still valid */ + a_Html_form_display_hiddens2(v_form, (display != 0)); + } +} + +/* * Set the URL data for image maps. */ static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y) diff --git a/src/html.hh b/src/html.hh index b742261c..5b18c1a8 100644 --- a/src/html.hh +++ b/src/html.hh @@ -13,6 +13,7 @@ extern "C" { void a_Html_load_images(void *v_html, DilloUrl *pattern); void a_Html_form_submit(void *v_html, void *v_form); void a_Html_form_reset(void *v_html, void *v_form); +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display); #ifdef __cplusplus } diff --git a/src/menu.cc b/src/menu.cc index a95ed0ec..002d970f 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -250,6 +250,29 @@ static void Menu_form_reset_cb(Widget*, void *v_form) } } +/* + * Toggle display of 'hidden' form controls. + */ +static void Menu_form_hiddens_cb(Widget *w, void *user_data) +{ + void *v_form = w->parent()->user_data(); + bool visible = *((bool *) user_data); + + if (popup_bw && popup_bw->Docs) { + if (dList_find_custom(popup_bw->PageUrls, popup_url, + (dCompareFunc)a_Url_cmp)){ + /* HTML page is still there */ + int n = dList_length(popup_bw->Docs); + if (n == 1) { + a_Html_form_display_hiddens(dList_nth_data(popup_bw->Docs, 0), + v_form, !visible); + } else if (n > 1) { + MSG ("Menu_form_hiddens_cb multiple Docs not implemented\n"); + } + } + } +} + /* * Validate URL with the W3C */ @@ -493,9 +516,11 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, * Form popup menu (construction & popup) */ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *formptr) + void *formptr, bool_t hidvis) { static PopupMenu *pm = 0; + static Item *hiddens_item = 0; + static bool hiddens_visible; popup_bw = bw; a_Url_free(popup_url); @@ -507,10 +532,16 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, i->callback(Menu_form_submit_cb); pm->add(i = new Item("Reset form")); i->callback(Menu_form_reset_cb); + pm->add(hiddens_item = new Item("")); + hiddens_item->callback(Menu_form_hiddens_cb); + hiddens_item->user_data(&hiddens_visible); pm->type(PopupMenu::POPUP123); } pm->user_data(formptr); + hiddens_visible = hidvis; + hiddens_item->label(hiddens_visible ? "Hide hiddens": "Show hiddens"); + a_Timeout_add(0.0, Menu_popup_cb, (void *)pm); } diff --git a/src/menu.hh b/src/menu.hh index 2b30e47d..be20bc49 100644 --- a/src/menu.hh +++ b/src/menu.hh @@ -13,7 +13,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *vform); + void *vform, bool_t showing_hiddens); void a_Menu_file_popup(BrowserWindow *bw, void *v_wid); void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_history_popup(BrowserWindow *bw, int direction); diff --git a/src/uicmd.cc b/src/uicmd.cc index f8869129..654f1277 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -668,9 +668,10 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, /* * Pop up the form menu */ -void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform) +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, + bool_t showing_hiddens) { - a_Menu_form_popup((BrowserWindow*)vbw, url, vform); + a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens); } /* diff --git a/src/uicmd.hh b/src/uicmd.hh index 3b5dc27e..6adb43ad 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -41,7 +41,8 @@ void a_UIcmd_page_popup(void *vbw, const DilloUrl *url, void a_UIcmd_link_popup(void *vbw, const DilloUrl *url); void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); -void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform); +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, + bool_t showing_hiddens); void a_UIcmd_file_popup(void *vbw, void *v_wid); void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr); void a_UIcmd_view_page_source(const DilloUrl *url); diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc index 5ce949ef..3815a868 100644 --- a/test/dw_ui_test.cc +++ b/test/dw_ui_test.cc @@ -79,10 +79,10 @@ int main(int argc, char **argv) // First of all, the resources. Later, they are embedded into the // widget tree. EntryResource *entryres1 = - layout->getResourceFactory()->createEntryResource (10, false); + layout->getResourceFactory()->createEntryResource (10, false, NULL); entryres1->setText ("Hi!"); EntryResource *entryres2 = - layout->getResourceFactory()->createEntryResource (10, true); + layout->getResourceFactory()->createEntryResource (10, true, NULL); MultiLineTextResource *textres = layout->getResourceFactory()->createMultiLineTextResource (15,3); RadioButtonResource *radiores1 = |