Am Sonntag, 10. Oktober 2010, um 13:51:00 schrieb Jan Köster:
> Hi,
> 
> In the moment write I little Blogsoftware with witty. Now I have problem
> with internalpath changed, my problem is i got no reactions of my requests
> here is a code example.
> 
> [blog.cpp]
> #include <Wt/WApplication>
> #include <Wt/WBreak>
> #include <Wt/WStackedWidget>
> #include <Wt/WContainerWidget>
> #include <Wt/WLineEdit>
> #include <Wt/WPushButton>
> #include <Wt/WText>
> #include <Wt/WWidget>
> #include <Wt/WComboBox>
> #include <Wt/WTextArea>
> #include <Wt/WCssStyleSheet>
> #include <Wt/WColor>
> #include <Wt/WHBoxLayout>
> #include <Wt/WLength>
> #include <Wt/WJavaScript>
> #include <Wt/WImage>
> #include <Wt/WLogger>
> 
> #include "../../model/blog.h"
> #include "../../model/navbar.h"
> #include "../../model/viewposts.h"
> #include "../../model/categoryview.h"
> 
> using namespace std;
> 
> TuxistApp::TuxistApp(const Wt::WEnvironment& env)
> 
>     : Wt::WApplication(env)
> 
> {
>   setTitle("Tuxist.de");               // application title
>   useStyleSheet("style/main.css");
>   addAutoJavaScript("document.getElementsByClassName('navbar_right')
> [0].style.marginLeft =
> document.getElementsByClassName('logo')[0].offsetWidth-
> document.getElementsByClassName('navbar_right')[0].offsetWidth+'px';");
> Wt::WContainerWidget *data = new Wt::WContainerWidget();
>   Wt::WContainerWidget *navbar_right = new Wt::WContainerWidget();
>   Wt::WContainerWidget *login = new Wt::WContainerWidget();
>   Wt::WStackedWidget *categorynav = new Wt::WStackedWidget();
>   content= new Wt::WContainerWidget();
>   Logo();
>   CategoryView categoryView;
>   categoryView.setStack(categorynav);
>   categoryView.setWidget(navbar_right);
>   categoryView.getCategoryView();
>   navbar_right->setStyleClass("navbar_right");
>   root()->addWidget(navbar_right);
> //   getContent(0);
>   root()->addWidget(content);
>   login->setStyleClass("login");
>   internalPathChanged().connect(this, &TuxistApp::onInternalPathChange);
> //   root()->addWidget(data);
> //   root()->addWidget(login);
> }
> void TuxistApp::onInternalPathChange(){
>   if(internalPathMatches("/cat/")){
>     getContent(0);
>   }
> }
> 
> 
> void TuxistApp::getContent(int category)
> {
>   ViewPosts viewposts;
>   content->clear();
>   viewposts.getcontent_overview(content,category);
> }
> 
> 
> Wt::WApplication *createApplication(const Wt::WEnvironment& env)
> {
>     // You could read information from the environment to decide
>     // whether the user has permission to start a new application
>     return new TuxistApp(env);
> }
> 
> void TuxistApp::Logo()
> {
>   Wt::WContainerWidget *logo = new Wt::WContainerWidget();
>   Wt::WContainerWidget *topnav = new Wt::WContainerWidget();
>   logo->setStyleClass("logo");
>   Wt::WImage *logoimg_left = new Wt::WImage("style/images/logo_left.png",
> logo);
>   Wt::WImage *logoimg_center = new
> Wt::WImage("style/images/logo_center.png", logo);
>   Wt::WImage *logoimg_right = new Wt::WImage("style/images/logo_right.png",
> logo);
>   logoimg_left->setAlternateText("logoimg_left");
>   logoimg_center->setAlternateText("logoimg_center");
>   logoimg_right->setAlternateText("logoimg_right");
>   logoimg_left->setStyleClass("logoimg_left");
>   logoimg_center->setStyleClass("logoimg_center");
>   logoimg_right->setStyleClass("logoimg_right");
>   Navbar navbar;
>   navbar.setNavbar(topnav);
>   logo->addWidget(topnav);
>   root()->addWidget(logo);
> }
> 
> int main(int argc, char **argv)
> {
>   return WRun(argc, argv, &createApplication);
> }
> 
> 
> [blog.h]
> #ifndef BLOG_H_
> #define BLOG_H_
> 
> #include <Wt/Dbo/WtSqlTraits>
> #include <Wt/Dbo/Types>
> 
> class TuxistApp : public Wt::WApplication
> {
>   public:
>     TuxistApp(const Wt::WEnvironment& env);
>   private:
>     Wt::WLineEdit *nameEdit_;
>     Wt::WText *greeting_;
>     Wt::WContainerWidget *navbar_right;
>     Wt::WContainerWidget *content;
>     Wt::WApplication *resize;
>     void getcontent_overview(int category);
>     void Logo();
>     void getContent(int category);
>   public slots:
>     void onInternalPathChange();
> 
> };
> 
> #endif
> 
> [categoryview.cpp]
> #include <iostream>
> #include <string>
> 
> #include <Wt/WStackedWidget>
> #include <Wt/WText>
> #include <Wt/WWidgetItem>
> #include <Wt/WAnchor>
> 
> #include "../../model/categoryview.h"
> 
> void CategoryView::setStack(Wt::WStackedWidget  *category)
> {
>   Category = category;
> }
> 
> void CategoryView::setWidget(Wt::WContainerWidget *menubar)
> {
>   Menubar = menubar;
> }
> 
> void CategoryView::getCategoryView()
> {
>   Wt::Dbo::backend::Postgres db_con(getenv("TUXCMS_SQLCONFIG"));
>   Wt::Dbo::Session session;
>   session.setConnection(db_con);
>   session.mapClass<CategoryView>("blog_category");
>     try {
>     session.createTables();
>   }catch (...) { }
>   Wt::Dbo::Transaction transaction(session);
>   CategoryViews categoryviews = session.find<CategoryView>();
>   Wt::WMenu *navbar = new Wt::WMenu(Category, Wt::Vertical, Menubar);
>   navbar->setRenderAsList(true);
>   for (CategoryViews::const_iterator i =categoryviews.begin(); i !=
> categoryviews.end(); ++i){
>      std::stringstream s;
>      s << (*i)->id;
>      Wt::WAnchor *a = new Wt::WAnchor();
>      a->setRefInternalPath("/cat/"+s.str());
>      navbar->addItem((*i)->name,a);
>   }
>   transaction.commit();
> }
> 
> int CategoryView::getCategoryId(int id)
> {
>   return id;
> }
> 
> [categoryview.h]
> 
> #ifndef CATEGORYVIEW_H_
> #define CATEGORYVIEW_H_
> 
> #include <Wt/Dbo/backend/Postgres>
> #include <Wt/Dbo/Dbo>
> #include <Wt/Dbo/Query>
> #include <Wt/Dbo/WtSqlTraits>
> #include <Wt/Dbo/Types>
> #include <Wt/WMenu>
> 
> class CategoryView : public Wt::Dbo::Dbo<CategoryView>
> {
>   private:
>     Wt::WContainerWidget *Menubar;
>     Wt::WStackedWidget  *Category;
>     typedef Wt::Dbo::collection<Wt::Dbo::ptr<CategoryView>> CategoryViews;
>     Wt::Dbo::ptr<CategoryView> entry;
>   public:
>     int         id;
>     Wt::WString name;
> 
>     template<class Action>
>     void persist(Action& a)
>     {
>       Wt::Dbo::field(a, id, "id");
>       Wt::Dbo::field(a, name, "name");
>     }
>     void getCategoryView();
>     void setStack(Wt::WStackedWidget  *category);
>     void setWidget(Wt::WContainerWidget *menubar);
>     int getCategoryId(int id);
> };
> 
> #endif
> 
> ---------------------------------------------------------------------------
> --- Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest

the complete sourcecode from the blogsoftware

Attachment: blog.tar.gz
Description: application/compressed-tar

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to