Wt examples: /home/koen/project/wt/public-git/wt/examples/treelist/IconPair.C Source File

Wt examples 3.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

/home/koen/project/wt/public-git/wt/examples/treelist/IconPair.C
Go to the documentation of this file.

    00001 /*
    00002  * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
    00003  *
    00004  * See the LICENSE file for terms of use.
    00005  */
    00006 #include <Wt/WCssDecorationStyle>
    00007 #include <Wt/WContainerWidget>
    00008 #include <Wt/WImage>
    00009
    00010 #include "IconPair.h"
    00011
    00012 IconPair::IconPair(const std::string icon1URI, const std::string icon2URI,
    00013                    bool clickIsSwitch, Wt::WContainerWidget *parent)
    00014   : Wt::WCompositeWidget(parent),
    00015     impl_(new Wt::WContainerWidget()),
    00016     icon1_(new Wt::WImage(icon1URI, impl_)),
    00017     icon2_(new Wt::WImage(icon2URI, impl_)),
    00018     icon1Clicked(icon1_->clicked()),
    00019     icon2Clicked(icon2_->clicked())
    00020 {
    00021   setImplementation(impl_);
    00022
    00023   implementStateless(&IconPair::showIcon1, &IconPair::undoShowIcon1);
    00024   implementStateless(&IconPair::showIcon2, &IconPair::undoShowIcon2);
    00025
    00026   setInline(true);
    00027
    00028   icon2_->hide();
    00029
    00030   if (clickIsSwitch) {
    00031     icon1_->clicked().connect(icon1_, &Wt::WImage::hide);
    00032     icon1_->clicked().connect(icon2_, &Wt::WImage::show);
    00033
    00034     icon2_->clicked().connect(icon2_, &Wt::WImage::hide);
    00035     icon2_->clicked().connect(icon1_, &Wt::WImage::show); //
    00036
    00037     decorationStyle().setCursor(Wt::PointingHandCursor);
    00038   }
    00039 } //
    00040
    00041 void IconPair::setState(int num)
    00042 {
    00043   if (num == 0) {
    00044     icon1_->show();
    00045     icon2_->hide();
    00046   } else {
    00047     icon1_->hide();
    00048     icon2_->show();
    00049   }
    00050 }
    00051
    00052 int IconPair::state() const
    00053 {
    00054   return (icon1_->isHidden() ? 1 : 0);
    00055 }
    00056
    00057 void IconPair::showIcon1()
    00058 {
    00059   previousState_ = (icon1_->isHidden() ? 1 : 0);
    00060   setState(0);
    00061 }
    00062
    00063 void IconPair::showIcon2()
    00064 {
    00065   previousState_ = (icon1_->isHidden() ? 1 : 0);
    00066   setState(1);
    00067 }
    00068
    00069 void IconPair::undoShowIcon1()
    00070 {
    00071   setState(previousState_);
    00072 }
    00073
    00074 void IconPair::undoShowIcon2()
    00075 {
    00076   setState(previousState_);
    00077 } //