aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-22 09:56:52 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-22 09:56:52 +0200
commitdb8450799255e2de37a9cd8c15610211673af6e1 (patch)
tree96295e53c051a7bfea4c75d972baf7107aa6d529
parent8ab9de15c7e52f8ab201412649f946b1922b1944 (diff)
disable forms while stylesheets are pending
To avoid lost user input on repush, we disable forms until all stylesheets have been loaded. Also open select widgets cause crashes on repush.
-rw-r--r--dw/fltkui.cc9
-rw-r--r--dw/ui.cc5
-rw-r--r--dw/ui.hh1
-rw-r--r--src/form.cc21
-rw-r--r--src/form.hh2
-rw-r--r--src/html.cc5
6 files changed, 36 insertions, 7 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index 4e39ad7d..44957848 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -235,7 +235,14 @@ bool FltkResource::isEnabled ()
void FltkResource::setEnabled (bool enabled)
{
- /** \bug Not implemented. */
+ for (Iterator <ViewAndWidget> it = viewsAndWidgets->iterator ();
+ it.hasNext(); ) {
+ ViewAndWidget *viewAndWidget = it.getNext ();
+ if (enabled)
+ viewAndWidget->widget->activate ();
+ else
+ viewAndWidget->widget->deactivate ();
+ }
}
// ----------------------------------------------------------------------
diff --git a/dw/ui.cc b/dw/ui.cc
index b2f9531d..b58669c5 100644
--- a/dw/ui.cc
+++ b/dw/ui.cc
@@ -101,6 +101,11 @@ void Embed::setDisplayed (bool displayed)
resource->setDisplayed (displayed);
}
+void Embed::setEnabled (bool enabled)
+{
+ resource->setEnabled (enabled);
+}
+
void Embed::draw (View *view, Rectangle *area)
{
drawWidgetBox (view, area, false);
diff --git a/dw/ui.hh b/dw/ui.hh
index 37724b52..29ee8916 100644
--- a/dw/ui.hh
+++ b/dw/ui.hh
@@ -244,6 +244,7 @@ public:
void setAscent (int ascent);
void setDescent (int descent);
void setDisplayed (bool displayed);
+ void setEnabled (bool displayed);
void draw (View *view, Rectangle *area);
Iterator *iterator (Content::Type mask, bool atEnd);
void setStyle (style::Style *style);
diff --git a/src/form.cc b/src/form.cc
index 9e4df408..7846c0be 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -76,6 +76,7 @@ class DilloHtmlForm {
DilloHtml *html;
bool showing_hiddens;
+ bool enabled;
void eventHandler(Resource *resource, EventButton *event);
DilloUrl *buildQueryUrl(DilloHtmlInput *active_input);
Dstr *buildQueryData(DilloHtmlInput *active_submit);
@@ -108,7 +109,8 @@ public: //BUG: for now everything is public
public:
DilloHtmlForm (DilloHtml *html,
DilloHtmlMethod method, const DilloUrl *action,
- DilloHtmlEnc content_type, const char *charset);
+ DilloHtmlEnc content_type, const char *charset,
+ bool enabled);
~DilloHtmlForm ();
DilloHtmlInput *getInput (Resource *resource);
DilloHtmlInput *getRadioInput (const char *name);
@@ -116,6 +118,7 @@ public:
void reset ();
void display_hiddens(bool display);
void addInput(DilloHtmlInput *input, DilloHtmlInputType type);
+ void setEnabled(bool enabled);
};
class DilloHtmlReceiver:
@@ -160,6 +163,7 @@ public:
~DilloHtmlInput ();
void appendValuesTo(Dlist *values, bool is_active_submit);
void reset();
+ void setEnabled(bool enabled) {if (embed) embed->setEnabled(enabled); };
};
class DilloHtmlSelect {
@@ -192,9 +196,10 @@ private:
DilloHtmlForm *a_Html_form_new (DilloHtml *html, DilloHtmlMethod method,
const DilloUrl *action,
- DilloHtmlEnc content_type, const char *charset)
+ DilloHtmlEnc content_type, const char *charset,
+ bool enabled)
{
- return new DilloHtmlForm (html, method, action, content_type, charset);
+ return new DilloHtmlForm (html, method, action, content_type, charset, enabled);
}
void a_Html_form_delete (DilloHtmlForm *form)
@@ -883,7 +888,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
DilloHtmlMethod method2,
const DilloUrl *action2,
DilloHtmlEnc content_type2,
- const char *charset)
+ const char *charset, bool enabled)
{
html = html2;
method = method2;
@@ -893,6 +898,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
inputs = new misc::SimpleVector <DilloHtmlInput*> (4);
num_entry_fields = 0;
showing_hiddens = false;
+ this->enabled = enabled;
form_receiver = new DilloHtmlReceiver (this);
}
@@ -1411,12 +1417,19 @@ void DilloHtmlForm::display_hiddens(bool display)
showing_hiddens = display;
}
+void DilloHtmlForm::setEnabled(bool enabled)
+{
+ for (int i = 0; i < inputs->size(); i++)
+ inputs->get(i)->setEnabled(enabled);
+}
+
/*
* Add a new input.
*/
void DilloHtmlForm::addInput(DilloHtmlInput *input, DilloHtmlInputType type)
{
input->connectTo (form_receiver);
+ input->setEnabled (enabled);
int ni = inputs->size ();
inputs->increase ();
inputs->set (ni,input);
diff --git a/src/form.hh b/src/form.hh
index 32ca88dd..a54cde56 100644
--- a/src/form.hh
+++ b/src/form.hh
@@ -34,7 +34,7 @@ DilloHtmlForm *a_Html_form_new(DilloHtml *html,
DilloHtmlMethod method,
const DilloUrl *action,
DilloHtmlEnc enc,
- const char *charset);
+ const char *charset, bool enabled);
void a_Html_form_delete(DilloHtmlForm* form);
void a_Html_input_delete(DilloHtmlInput* input);
diff --git a/src/html.cc b/src/html.cc
index db6f99d5..5b14101f 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -640,7 +640,10 @@ void DilloHtml::finishParsing(int ClientKey)
int DilloHtml::formNew(DilloHtmlMethod method, const DilloUrl *action,
DilloHtmlEnc enc, const char *charset)
{
- DilloHtmlForm *form = a_Html_form_new (this,method,action,enc,charset);
+ // avoid data loss on repush after CSS stylesheets have been loaded
+ bool enabled = bw->NumPendingStyleSheets == 0;
+ DilloHtmlForm *form = a_Html_form_new (this, method, action,
+ enc, charset, enabled);
int nf = forms->size ();
forms->increase ();
forms->set (nf, form);