Wt examples 3.3.12
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
12 : WContainerWidget(parent),
13 optionNeedReset_(0)
14{
16}
17
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
37
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)
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()) {
70 break;
71 }
72 }
73
74 break;
75 }
76 }
77}
78
void add(Option *option)
Add an Option to the list.
Definition OptionList.C:18
OptionList(WContainerWidget *parent=0)
Create an OptionList.
Definition OptionList.C:11
void optionVisibilityChanged(Option *opt, bool hidden)
An option changed visibility: possibly update the separators inbetween.
Definition OptionList.C:38
Option * optionNeedReset_
The option that needs its stateless code updated.
Definition OptionList.h:61
void update()
Updates the stateless implementations after an Option has been hidden or shown.
Definition OptionList.C:30
std::vector< Option * > options_
The list of options.
Definition OptionList.h:58
A clickable option.
Definition Option.h:32
void setOptionList(OptionList *l)
Definition Option.C:28
void hideSeparator()
Hide the separator.
Definition Option.C:39
virtual void addWidget(WWidget *widget)
static WLength Auto
void resetLearnedSlots()
virtual void resize(const WLength &width, const WLength &height)
virtual bool isHidden() const

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8