Skip to content

Commit 352ee9d

Browse files
author
Koen Deforche
committed
Several changes:
- Fixed bug with input mask when value assigned before render - Fixed WCssStyleSheet bugs (#3229) - Implemented client's screen resolution to WEnvironment (#3215)
1 parent 1d93271 commit 352ee9d

File tree

15 files changed

+449
-394
lines changed

15 files changed

+449
-394
lines changed

examples/widgetgallery/approot/src.xml

Lines changed: 338 additions & 337 deletions
Large diffs are not rendered by default.

examples/widgetgallery/examples/ComboDelegateTable.cpp

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,62 @@
1919
*/
2020
class ComboDelegate : public Wt::WItemDelegate {
2121
public:
22-
ComboDelegate(Wt::WStringListModel* items)
23-
: items_(items)
24-
{}
25-
26-
void setModelData(const boost::any &editState, Wt::WAbstractItemModel* model,
27-
const Wt::WModelIndex &index) const
28-
{
29-
int stringIdx = Wt::asNumber(editState);
30-
model->setData(index, stringIdx, Wt::UserRole);
31-
model->setData(index, items_->stringList()[stringIdx], Wt::DisplayRole);
32-
}
33-
34-
boost::any editState(Wt::WWidget* editor) const
35-
{
36-
Wt::WComboBox* combo = dynamic_cast<Wt::WComboBox*>
37-
(dynamic_cast<Wt::WContainerWidget*>(editor)->widget(0));
38-
return combo->currentIndex();
39-
}
40-
41-
void setEditState(Wt::WWidget* editor, const boost::any &value) const
42-
{
43-
Wt::WComboBox* combo = dynamic_cast<Wt::WComboBox*>
44-
(dynamic_cast<Wt::WContainerWidget*>(editor)->widget(0));
45-
combo->setCurrentIndex(Wt::asNumber(value));
46-
}
22+
ComboDelegate(Wt::WAbstractItemModel* items)
23+
: items_(items)
24+
{ }
25+
26+
void setModelData(const boost::any &editState, Wt::WAbstractItemModel* model,
27+
const Wt::WModelIndex &index) const
28+
{
29+
int stringIdx = Wt::asNumber(editState);
30+
model->setData(index, stringIdx, Wt::UserRole);
31+
model->setData(index, items_->data(stringIdx, 0), Wt::DisplayRole);
32+
}
33+
34+
boost::any editState(Wt::WWidget* editor) const
35+
{
36+
Wt::WComboBox* combo = dynamic_cast<Wt::WComboBox*>
37+
(dynamic_cast<Wt::WContainerWidget*>(editor)->widget(0));
38+
return combo->currentIndex();
39+
}
40+
41+
void setEditState(Wt::WWidget* editor, const boost::any &value) const
42+
{
43+
Wt::WComboBox* combo = dynamic_cast<Wt::WComboBox*>
44+
(dynamic_cast<Wt::WContainerWidget*>(editor)->widget(0));
45+
combo->setCurrentIndex(Wt::asNumber(value));
46+
}
4747

4848
protected:
49-
virtual Wt::WWidget* createEditor(const Wt::WModelIndex &index,
50-
Wt::WFlags<Wt::ViewItemRenderFlag> flags) const
51-
{
52-
Wt::WContainerWidget* container = new Wt::WContainerWidget();
53-
Wt::WComboBox* combo = new Wt::WComboBox(container);
54-
combo->setModel(items_);
55-
combo->setCurrentIndex(Wt::asNumber(index.data(Wt::UserRole)));
56-
57-
combo->changed().connect(boost::bind(&ComboDelegate::doCloseEditor, this,
58-
container, true));
59-
combo->enterPressed().connect(boost::bind(&ComboDelegate::doCloseEditor,
49+
virtual Wt::WWidget* createEditor(const Wt::WModelIndex &index,
50+
Wt::WFlags<Wt::ViewItemRenderFlag> flags) const
51+
{
52+
Wt::WContainerWidget* container = new Wt::WContainerWidget();
53+
Wt::WComboBox* combo = new Wt::WComboBox(container);
54+
combo->setModel(items_);
55+
combo->setCurrentIndex(Wt::asNumber(index.data(Wt::UserRole)));
56+
57+
combo->changed().connect(boost::bind(&ComboDelegate::doCloseEditor, this,
58+
container, true));
59+
combo->enterPressed().connect(boost::bind(&ComboDelegate::doCloseEditor,
6060
this, container, true));
61-
combo->escapePressed().connect(boost::bind(&ComboDelegate::doCloseEditor,
62-
this, container, false));
61+
combo->escapePressed().connect(boost::bind(&ComboDelegate::doCloseEditor,
62+
this, container, false));
6363

64-
return container;
65-
}
64+
return container;
65+
}
6666

6767
private:
68-
Wt::WStringListModel* items_;
68+
Wt::WAbstractItemModel* items_;
6969

70-
void doCloseEditor(Wt::WWidget *editor, bool save) const
71-
{
72-
closeEditor().emit(editor, save);
73-
}
70+
void doCloseEditor(Wt::WWidget *editor, bool save) const
71+
{
72+
closeEditor().emit(editor, save);
73+
}
7474
};
7575

7676
SAMPLE_BEGIN(ComboDelegateTable)
77+
7778
Wt::WTableView *table = new Wt::WTableView();
7879

7980
// create model

src/Wt/WApplication

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ public:
366366
* External stylesheets are inserted after the internal style sheet,
367367
* and can therefore override default styles set by widgets in the
368368
* internal style sheet.
369+
* External stylesheets must have valid link.
369370
*
370371
* If not empty, \p condition is a string that is used to apply the
371372
* stylesheet to specific versions of IE. Only a limited subset of

src/Wt/WApplication.C

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ void WApplication::useStyleSheet(const WLink& link,
553553
void WApplication::useStyleSheet(const WCssStyleSheet& styleSheet,
554554
const std::string& condition)
555555
{
556+
557+
if (styleSheet.link().isNull())
558+
throw WException(
559+
"WApplication::useStyleSheet stylesheet must have valid link!");
560+
556561
bool display = true;
557562

558563
if (!condition.empty()) {

src/Wt/WCssStyleSheet

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public:
244244
*
245245
* Optionally, you may give a \p ruleName, which may later be
246246
* used to check if the rule was already defined.
247+
* Note: you may not pass the same rule to 2 diffrent applications.
247248
*
248249
* \sa isDefined()
249250
*/
@@ -284,6 +285,10 @@ private:
284285
std::vector<std::string> rulesRemoved_;
285286

286287
std::set<std::string> defined_;
288+
289+
bool isDirty();
290+
291+
friend class WebRenderer;
287292
};
288293

289294
}

src/Wt/WCssStyleSheet.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,10 @@ void WCssStyleSheet::clear()
335335
delete rules_.back();
336336
}
337337

338+
bool WCssStyleSheet::isDirty()
339+
{
340+
return !rulesAdded_.empty() || !rulesModified_.empty() ||
341+
!rulesRemoved_.empty();
342+
}
343+
338344
} // namespace Wt

src/Wt/WEnvironment

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ public:
254254

255255
bool webGL() const { return webGLsupported_; }
256256

257+
/*! \brief Returns the horizontal resolution of the client's screen.
258+
*
259+
* \sa screenHeight()
260+
*/
261+
int screenWidth() const { return screenWidth_; }
262+
263+
/*! \brief Returns the vertical resolution of the client's screen.
264+
*
265+
* \sa screenWidth()
266+
*/
267+
int screenHeight() const { return screenHeight_; }
268+
257269
/*! \brief Returns the browser-side DPI scaling factor
258270
*
259271
* Internet Explorer scales all graphics, fonts and other elements
@@ -651,6 +663,8 @@ protected:
651663
bool doesCookies_;
652664
bool hashInternalPaths_;
653665
UserAgent agent_;
666+
int screenWidth_;
667+
int screenHeight_;
654668
double dpiScale_;
655669
std::string queryString_;
656670
bool webGLsupported_;

src/Wt/WEnvironment.C

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ void WEnvironment::enableAjax(const WebRequest& request)
231231
if (s != 0)
232232
publicDeploymentPath_.clear(); // looks invalid
233233
}
234+
235+
236+
screenWidth_=boost::lexical_cast<int>(*request.getParameter("scrW"));
237+
screenHeight_=boost::lexical_cast<int>(*request.getParameter("scrH"));
234238
}
235239

236240
void WEnvironment::setUserAgent(const std::string& userAgent)

src/Wt/WGlobal

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,18 @@ namespace Wt {
291291
class Message;
292292
}
293293

294+
namespace Payment {
295+
class Address;
296+
class Customer;
297+
class Money;
298+
class Order;
299+
class OrderItem;
300+
class PayPalExpressCheckout;
301+
class PayPalService;
302+
class Result;
303+
class Approval;
304+
}
305+
294306
namespace Render {
295307
class WPdfRenderer;
296308
}

src/js/WLineEdit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ WT_DECLARE_WT_MEMBER
9696
caseMap = newCaseMap;
9797
spaceChar = newSpaceChar;
9898
displayValue = newDisplayValue;
99+
this.setValue(displayValue);
100+
edit.value = this.getValue();
99101
};
100102

101103
if (mask !== "") {
102104
this.setInputMask(mask, raw, displayValue, caseMap, spaceChar);
103-
this.setValue(this.getValue());
104105
}
105106

106107
function skippable(position) {

0 commit comments

Comments
 (0)