-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathStdWidgetItemImpl.C
More file actions
120 lines (94 loc) · 2.72 KB
/
StdWidgetItemImpl.C
File metadata and controls
120 lines (94 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Copyright (C) 2008 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include <cassert>
#include "DomElement.h"
#include "StdWidgetItemImpl.h"
#include "Wt/WApplication.h"
#include "Wt/WContainerWidget.h"
#include "Wt/WEnvironment.h"
#include "Wt/WLogger.h"
#include "Wt/WTheme.h"
#include "Wt/WWidgetItem.h"
#ifndef WT_DEBUG_JS
#include "js/WtResize.min.js"
#endif
namespace Wt {
LOGGER("WWidgetItem");
StdWidgetItemImpl::StdWidgetItemImpl(WWidgetItem *item)
: item_(item)
{ }
StdWidgetItemImpl::~StdWidgetItemImpl()
{ }
const char *StdWidgetItemImpl::childrenResizeJS()
{
WApplication *app = WApplication::instance();
LOAD_JAVASCRIPT(app, "js/WtResize.js", "ChildrenResize", wtjs10);
return WT_CLASS ".ChildrenResize";
}
const char *StdWidgetItemImpl::childrenGetPSJS()
{
WApplication *app = WApplication::instance();
LOAD_JAVASCRIPT(app, "js/WtResize.js", "ChildrenGetPS", wtjs11);
return WT_CLASS ".ChildrenGetPS";
}
const char *StdWidgetItemImpl::secondResizeJS()
{
WApplication *app = WApplication::instance();
LOAD_JAVASCRIPT(app, "js/WtResize.js", "LastResize", wtjs12);
return WT_CLASS ".LastResize";
}
const char *StdWidgetItemImpl::secondGetPSJS()
{
WApplication *app = WApplication::instance();
LOAD_JAVASCRIPT(app, "js/WtResize.js", "LastGetPS", wtjs13);
return WT_CLASS ".LastGetPS";
}
int StdWidgetItemImpl::minimumWidth() const
{
if (item_->widget()->isHidden())
return 0;
else
return static_cast<int>(item_->widget()->minimumWidth().toPixels());
}
int StdWidgetItemImpl::minimumHeight() const
{
if (item_->widget()->isHidden())
return 0;
else
return static_cast<int>(item_->widget()->minimumHeight().toPixels());
}
const std::string StdWidgetItemImpl::id() const
{
return item_->widget()->id();
}
DomElement *StdWidgetItemImpl::createDomElement(DomElement *parent,
bool fitWidth, bool fitHeight,
WApplication *app)
{
WWidget *w = item_->widget();
w->setInline(false);
DomElement *d = w->createSDomElement(app);
DomElement *result = d;
if (app->environment().agentIsIElt(9) &&
(d->type() == DomElementType::TEXTAREA ||
d->type() == DomElementType::SELECT ||
d->type() == DomElementType::INPUT ||
d->type() == DomElementType::BUTTON)) {
d->removeProperty(Property::StyleDisplay);
}
// FIXME IE9 does border-box perhaps ?
if (!app->environment().agentIsIElt(9) &&
w->javaScriptMember(WWidget::WT_RESIZE_JS).empty() &&
d->type() != DomElementType::TABLE /* buggy in Chrome, see #1856 */ &&
app->theme()->canBorderBoxElement(*d))
d->setProperty(Property::StyleBoxSizing, "border-box");
return result;
}
WLayoutItem *StdWidgetItemImpl::layoutItem() const
{
return item_;
}
}