Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsAnchor.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2006-Today Guy Deleeuw
3 *
4 * See the LICENSE file for terms of use.
5 */
6 
7 #include <dlfcn.h>
8 #include <stdio.h>
9 
10 #include <iostream>
11 
12 #include <boost/filesystem.hpp>
13 
14 #include <Wt/WLogger>
15 #include <Wt/WText>
16 #include <Wt/WAnchor>
17 #include <Wt/WImage>
18 #include <Wt/WLink>
19 #include <Wt/WString>
20 
21 #include <gdcore/gdCore.h>
22 
23 #include <Logger/WsLogger.h>
24 
25 #include <Main/WsApplication.h>
26 
27 #include "WsAnchor.h"
28 
29 using namespace Wt;
30 
31 // Class WsAnchor
32 // ==================
33 WsAnchor::WsAnchor(WContainerWidget* parent)
34  : WContainerWidget(parent)
35 {
36  addStyleClass("WsAnchor");
37 }
38 
40 {
41 }
42 
44 {
45  Wt::WContainerWidget::load();
46  std::string linkType = asString(option("linkType")).toUTF8(); // Url, Resource, InternalPath
47  std::string link = asString(option("link")).toUTF8();
48  std::string text = asString(option("text")).toUTF8();
49  std::string icon = asString(option("icon")).toUTF8();
50  std::string iconText = asString(option("iconText")).toUTF8();
51  std::string target = asString(option("target")).toUTF8(); // TargetSelf, TargetThisWindow, TargetNewWindow
52  std::string title = asString(option("title")).toUTF8();
53  if ( linkType.size() < 1 ) linkType = "InternalPath";
54  if ( title.size() > 0 ) {
55  WText* ptext = new WText(title);
56  ptext->addStyleClass("WsTitle");
57  addWidget(new WText(title));
58  }
59  WLink wLink;
60  if ( linkType == "Url" ) wLink.setUrl(link);
61  // if ( linkType == "Resource" ) wLink.setResource(link);
62  if ( linkType == "InternalPath" ) wLink.setInternalPath(link);
63  WAnchor* pAnchor = new WAnchor(wLink, text);
64  if ( icon.size() > 0 ) {
65  WImage* pImage = new WImage(WLink(WLink::Url, icon), iconText, 0);
66  pAnchor->setImage(pImage);
67  }
68  if ( target == "TargetNewWindow" )
69  pAnchor->setTarget(Wt::TargetNewWindow);
70  if ( target == "TargetSelf" )
71  pAnchor->setTarget(Wt::TargetSelf);
72  if ( target == "TargetThisWindow" )
73  pAnchor->setTarget(Wt::TargetThisWindow);
74  addWidget(pAnchor);
75 }
76 
a wittyShare widget
const boost::any & option(const std::string &attribute) const
Get an options value.
Definition: WsOption.cpp:62
~WsAnchor()
Definition: WsAnchor.cpp:39
virtual void load()
Definition: WsAnchor.cpp:43
WsAnchor(Wt::WContainerWidget *parent=0)
CTor.
Definition: WsAnchor.cpp:33