Wt examples
3.2.1
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
build
buildd
witty-3.2.1
examples
treelist
IconPair.C
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
3
*
4
* See the LICENSE file for terms of use.
5
*/
6
#include <Wt/WCssDecorationStyle>
7
#include <Wt/WContainerWidget>
8
#include <Wt/WImage>
9
10
#include "
IconPair.h
"
11
12
IconPair::IconPair
(
const
std::string icon1URI,
const
std::string icon2URI,
13
bool
clickIsSwitch,
Wt::WContainerWidget
*parent)
14
: Wt::WCompositeWidget(parent),
15
impl_(new Wt::WContainerWidget()),
16
icon1_(new Wt::WImage(icon1URI, impl_)),
17
icon2_(new Wt::WImage(icon2URI, impl_)),
18
icon1Clicked(icon1_->clicked()),
19
icon2Clicked(icon2_->clicked())
20
{
21
setImplementation
(
impl_
);
22
23
implementStateless
(&
IconPair::showIcon1
, &
IconPair::undoShowIcon1
);
24
implementStateless
(&
IconPair::showIcon2
, &
IconPair::undoShowIcon2
);
25
26
setInline
(
true
);
27
28
icon2_
->
hide
();
29
30
if
(clickIsSwitch) {
31
icon1_
->
clicked
().connect(
icon1_
, &
Wt::WImage::hide
);
32
icon1_
->
clicked
().connect(
icon2_
, &
Wt::WImage::show
);
33
34
icon2_
->
clicked
().connect(
icon2_
, &
Wt::WImage::hide
);
35
icon2_
->
clicked
().connect(
icon1_
, &
Wt::WImage::show
);
//
36
37
decorationStyle
().
setCursor
(
Wt::PointingHandCursor
);
38
}
39
}
//
40
41
void
IconPair::setState
(
int
num)
42
{
43
if
(num == 0) {
44
icon1_
->
show
();
45
icon2_
->
hide
();
46
}
else
{
47
icon1_
->
hide
();
48
icon2_
->
show
();
49
}
50
}
51
52
int
IconPair::state
()
const
53
{
54
return
(
icon1_
->
isHidden
() ? 1 : 0);
55
}
56
57
void
IconPair::showIcon1
()
58
{
59
previousState_
= (
icon1_
->
isHidden
() ? 1 : 0);
60
setState
(0);
61
}
62
63
void
IconPair::showIcon2
()
64
{
65
previousState_
= (
icon1_
->
isHidden
() ? 1 : 0);
66
setState
(1);
67
}
68
69
void
IconPair::undoShowIcon1
()
70
{
71
setState
(
previousState_
);
72
}
73
74
void
IconPair::undoShowIcon2
()
75
{
76
setState
(
previousState_
);
77
}
//
Generated on Wed Jun 13 2012 for
the C++ Web Toolkit (Wt)
by
1.8.1