Wt examples
3.3.0
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
build
buildd
witty-3.3.0
examples
composer
OptionList.C
Go to the documentation of this file.
1
// This may look like C code, but it's really -*- C++ -*-
2
/*
3
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
4
*
5
* See the LICENSE file for terms of use.
6
*/
7
8
#include "
OptionList.h
"
9
#include "
Option.h
"
10
11
OptionList::OptionList
(
WContainerWidget
*parent)
12
:
WContainerWidget
(parent),
13
optionNeedReset_
(0)
14
{
15
resize
(WLength::Auto,
WLength
(2.5, WLength::FontEx));
16
}
17
18
void
OptionList::add
(
Option
*option)
19
{
20
addWidget(option);
21
option->
setOptionList
(
this
);
22
23
if
(!
options_
.empty()) {
24
options_
.back()->addSeparator();
25
}
26
27
options_
.push_back(option);
28
}
29
30
void
OptionList::update
()
31
{
32
if
(
optionNeedReset_
!= 0)
33
optionNeedReset_
->resetLearnedSlots();
34
35
optionNeedReset_
= 0;
36
}
37
38
void
OptionList::optionVisibilityChanged
(
Option
*opt,
bool
hidden)
39
{
40
/*
41
* Check if it was the last visible option, in that case the second last
42
* visible option loses its separator.
43
*/
44
for
(std::size_t i =
options_
.size() - 1; i > 0; --i) {
45
if
(
options_
[i] == opt) {
46
for
(
int
j = i - 1; j >= 0; --j) {
47
if
(!
options_
[j]->
isHidden
()) {
48
if
(hidden)
49
options_
[j]->hideSeparator();
50
else
51
options_
[j]->showSeparator();
52
break
;
53
}
54
}
55
break
;
56
}
else
57
if
(!
options_
[i]->
isHidden
())
58
break
;
59
}
60
61
/*
62
* The Option to the right needs to relearn its stateless
63
* slot code for hide() and show().
64
*/
65
for
(
unsigned
i = 0; i <
options_
.size(); ++i) {
66
if
(
options_
[i] == opt) {
67
for
(
unsigned
j = i + 1; j <
options_
.size(); ++j) {
68
if
(!
options_
[j]->
isHidden
()) {
69
optionNeedReset_
=
options_
[j];
70
break
;
71
}
72
}
73
74
break
;
75
}
76
}
77
}
78
Generated on Fri May 31 2013 for
the C++ Web Toolkit (Wt)
by
1.8.3.1