Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Random Code source code (version 4.1)

 

Random Code source code (version 4.1).

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ToolRandomCodeDesktop.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-12-23T14:15:51
#
#-------------------------------------------------
QT       += core gui
TARGET = ToolRandomCodeDesktop
TEMPLATE = app
INCLUDEPATH += \
    ../../Classes/CppAbout \
    ../../Classes/CppQtAboutDialog \
    ../../Classes/CppRandomCode

SOURCES += qtmain.cpp \
    ../../Classes/CppAbout/about.cpp \
    ../../Classes/CppQtAboutDialog/qtaboutdialog.cpp \
    ../../Classes/CppRandomCode/randomcode.cpp \
    randomcodemenudialog.cpp \
    qtrandomcodegeneratedialog.cpp

HEADERS += \
    ../../Classes/CppAbout/about.h \
    ../../Classes/CppRandomCode/randomcode.h \
    ../../Classes/CppQtAboutDialog/qtaboutdialog.h \
    qtrandomcodegeneratedialog.h \
    randomcodemenudialog.h

FORMS += \
    qtrandomcodegeneratedialog.ui \
    ../../Classes/CppQtAboutDialog/qtaboutdialog.ui

RESOURCES += \
    ToolRandomCode.qrc

OTHER_FILES +=

 

 

 

 

 

Qt project file: ToolRandomCodeDesktopConsole.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-07-24T16:04:35
#
#-------------------------------------------------
QT += core gui
TARGET = ToolRandomCodeDesktopConsole
TEMPLATE = app
SOURCES +=  main \
    ../../Classes/CppRandomCode/randomcode.cpp
HEADERS += \
    ../../Classes/CppRandomCode/randomcode.h

 

 

 

 

 

Qt project file: ToolRandomCodeWebsite.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-07-24T16:04:35
#
#-------------------------------------------------
QT += core gui
TARGET = ToolRandomCodeWebsite
LIBS += -lwt -lwthttp
QMAKE_CXXFLAGS += -DNDEBUG
TEMPLATE = app

INCLUDEPATH += \
    ../../Classes/CppAbout \
    ../../Classes/CppRandomCode \
    ../../Classes/CppWtAboutDialog \
    ../../Classes/CppWtAutoConfig

SOURCES += wtmain.cpp \
    ../../Classes/CppAbout/about.cpp \
    ../../Classes/CppRandomCode/randomcode.cpp \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.cpp \
    ../../Classes/CppWtAutoConfig/wtautoconfig.cpp \
    randomcodemenudialog.cpp \
    wtrandomcodegeneratedialog.cpp \
    wtrandomcodemenudialog.cpp

HEADERS += \
    ../../Classes/CppAbout/about.h \
    ../../Classes/CppRandomCode/randomcode.h \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.h \
    ../../Classes/CppWtAutoConfig/wtautoconfig.h \
    randomcodemenudialog.h \
    wtrandomcodegeneratedialog.h \
    wtrandomcodemenudialog.h

RESOURCES += \
    ToolRandomCode.qrc

 

 

 

 

 

main.cpp

 

//---------------------------------------------------------------------------
/*
RandomCodeDesktopConsole, tool to generate random C++ code
Copyright (C) 2010  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <ctime>
#include <iostream>
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
//---------------------------------------------------------------------------
#include "../../Classes/CppRandomCode/randomcode.h"
//---------------------------------------------------------------------------
///From http://www.richelbilderbeek.nl/CppRandomizeTimer.htm
void RandomizeTimer()
{
  std::srand(std::time(0));
}
//---------------------------------------------------------------------------
int main()
{
  ///Randomize on timer
  RandomizeTimer();

  //Create the random code
  const std::vector<std::string> v
    = RandomCode::CreateRandomCode();

  //Display the random code
  std::copy(
    v.begin(),
    v.end(),
    std::ostream_iterator<std::string>(std::cout,"\n"));
}

 

 

 

 

 

qtmain.cpp

 

//---------------------------------------------------------------------------
/*
RandomCodeDesktopGui, tool to generate random C++ code
Copyright (C) 2010  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <QtGui/QApplication>
#include "qtrandomcodegeneratedialog.h"
//---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QtRandomCodeGenerateDialog w;
    w.show();
    return a.exec();
}
//---------------------------------------------------------------------------

 

 

 

 

 

qtrandomcodegeneratedialog.cpp

 

//---------------------------------------------------------------------------
/*
RandomCodeDesktopGui, tool to generate random C++ code
Copyright (C) 2007  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <string>
#include <vector>
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
//---------------------------------------------------------------------------
#include <QDesktopWidget>
//---------------------------------------------------------------------------
#include "about.h"
#include "qtaboutdialog.h"
#include "qtrandomcodegeneratedialog.h"
#include "ui_qtrandomcodegeneratedialog.h"
#include "randomcode.h"
#include "randomcodemenudialog.h"
//---------------------------------------------------------------------------
QtRandomCodeGenerateDialog::QtRandomCodeGenerateDialog(QWidget *parent) :
    QDialog(parent,Qt::Window),
    ui(new Ui::QtRandomCodeGenerateDialog)
{
  ui->setupUi(this);

  //Put the dialog in the screen center
  const QRect screen = QApplication::desktop()->screenGeometry();
  this->move( screen.center() - this->rect().center() );

  ui->button_generate->click();
}
//---------------------------------------------------------------------------
QtRandomCodeGenerateDialog::~QtRandomCodeGenerateDialog()
{
  delete ui;
}
//---------------------------------------------------------------------------
void QtRandomCodeGenerateDialog::changeEvent(QEvent *e)
{
  QDialog::changeEvent(e);
  switch (e->type()) {
  case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
  default:
    break;
  }
}
//---------------------------------------------------------------------------
void QtRandomCodeGenerateDialog::on_button_generate_clicked()
{
  const std::vector<std::string> v = RandomCode::CreateRandomCode();
  ui->textEdit->clear();
  BOOST_FOREACH(const std::string& s, v)
  {
    ui->textEdit->append(s.c_str());
  }
}
//---------------------------------------------------------------------------
void QtRandomCodeGenerateDialog::on_button_about_clicked()
{
  About about = RandomCodeMenuDialog::GetAbout();
  //about.AddLibrary("QtConnectThreeWidget version: " + QtConnectThreeWidget::GetVersion());
  QtAboutDialog d(about);
  this->hide();
  d.exec();
  this->show();
}
//---------------------------------------------------------------------------

 

 

 

 

 

qtrandomcodegeneratedialog.h

 

//---------------------------------------------------------------------------
/*
RandomCodeDesktopGui, tool to generate random C++ code
Copyright (C) 2010  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#ifndef RANDOMCODEDIALOG_H
#define RANDOMCODEDIALOG_H
//---------------------------------------------------------------------------
#include <QDialog>
//---------------------------------------------------------------------------
namespace Ui {
  class QtRandomCodeGenerateDialog;
}
//---------------------------------------------------------------------------
class QtRandomCodeGenerateDialog : public QDialog
{
  Q_OBJECT

public:
  explicit QtRandomCodeGenerateDialog(QWidget *parent = 0);
  ~QtRandomCodeGenerateDialog();

protected:
  void changeEvent(QEvent *e);

private:
  Ui::QtRandomCodeGenerateDialog *ui;

private slots:
  void on_button_about_clicked();
  void on_button_generate_clicked();
};
//---------------------------------------------------------------------------
#endif // RANDOMCODEDIALOG_H

 

 

 

 

 

randomcodemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include "randomcode.h"
#include "randomcodemenudialog.h"
//---------------------------------------------------------------------------
About RandomCodeMenuDialog::GetAbout()
{
  About a(
    "Richel Bilderbeek",
    "RandomCode",
    "tool to generate random C++ code",
    "the 24th of April 2011",
    "2007-2011",
    "http://www.richelbilderbeek.nl/ToolRandomCode.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("RandomCode version: " + RandomCode::GetVersion());
  return a;
}
//---------------------------------------------------------------------------
const std::string RandomCodeMenuDialog::GetVersion()
{
  return "4.1";
}
//---------------------------------------------------------------------------
const std::vector<std::string> RandomCodeMenuDialog::GetVersionHistory()
{
  std::vector<std::string> v;
  v.push_back("2007-xx-xx: version 1.0: initial version in C++ Builder");
  v.push_back("2010-12-03: version 2.0: port to Qt Creator");
  v.push_back("2011-01-07: version 3.0: added menu, reworked file architecture");
  v.push_back("2011-04-24: version 4.0: major architectural change, created web version");
  v.push_back("2011-08-31: version 4.1: added Welcome picture for web version");
  return v;
}
//---------------------------------------------------------------------------

 

 

 

 

 

randomcodemenudialog.h

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#ifndef RANDOMCODEMENUDIALOG_H
#define RANDOMCODEMENUDIALOG_H
//---------------------------------------------------------------------------
#include <string>
#include <vector>
//---------------------------------------------------------------------------
#include "about.h"
//---------------------------------------------------------------------------
struct RandomCodeMenuDialog
{
  static About GetAbout();
  static const std::string GetVersion();
  static const std::vector<std::string> GetVersionHistory();
};
//---------------------------------------------------------------------------
#endif // RANDOMCODEMENUDIALOG_H

 

 

 

 

 

wtmain.cpp

 

//---------------------------------------------------------------------------
/*
RandomCodeWt, web application to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
//---------------------------------------------------------------------------
#include "wtautoconfig.h"
#include "wtrandomcodemenudialog.h"
//---------------------------------------------------------------------------
struct WtRandomCodeApplication : public Wt::WApplication
{
  WtRandomCodeApplication(const Wt::WEnvironment& env)
  : Wt::WApplication(env)
  {
    this->setTitle("RandomCode");
    this->useStyleSheet("wt.css");
    root()->addWidget(new WtRandomCodeMenuDialog);
  }
};
//---------------------------------------------------------------------------
Wt::WApplication * createApplication(const Wt::WEnvironment& env)
{
  return new WtRandomCodeApplication(env);
}
//---------------------------------------------------------------------------
int main(int argc, char **argv)
{
  WtAutoConfig a(argc,argv,createApplication);
  WtAutoConfig::SaveDefaultStylesheet();
  return a.Run();
}
//---------------------------------------------------------------------------


 

 

 

 

 

wtrandomcodegeneratedialog.cpp

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
//---------------------------------------------------------------------------
#include <Wt/WBreak>
#include <Wt/WPushButton>
#include <Wt/WTextArea>
//---------------------------------------------------------------------------
#include "wtrandomcodegeneratedialog.h"
#include "randomcode.h"
//---------------------------------------------------------------------------
WtRandomCodeGenerateDialog::WtRandomCodeGenerateDialog()
  : m_button_generate(new Wt::WPushButton),
    m_text_area(new Wt::WTextArea)
{
  this->setContentAlignment(Wt::AlignCenter);
  this->addWidget(m_text_area);
  this->addWidget(new Wt::WBreak());
  this->addWidget(m_button_generate);
  m_text_area->setMinimumSize(800,400);

  m_button_generate->setText("Generate");

  m_button_generate->clicked().connect(
    this, &WtRandomCodeGenerateDialog::OnGenerateClick);

  OnGenerateClick();
}
//---------------------------------------------------------------------------
void WtRandomCodeGenerateDialog::OnGenerateClick()
{
  const std::vector<std::string> v = RandomCode::CreateRandomCode();
  std::string s;
  BOOST_FOREACH(const std::string& line,v)
  {
    s += line + '\n';
  }
  m_text_area->setText(s);
}
//---------------------------------------------------------------------------

 

 

 

 

 

wtrandomcodegeneratedialog.h

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#ifndef WTRANDOMCODEGENERATEDIALOG_H
#define WTRANDOMCODEGENERATEDIALOG_H
//---------------------------------------------------------------------------
#include <Wt/WContainerWidget>
//---------------------------------------------------------------------------
namespace Wt
{
  struct WPushButton;
  struct WTextArea;
}
//---------------------------------------------------------------------------
struct WtRandomCodeGenerateDialog : public Wt::WContainerWidget
{
  WtRandomCodeGenerateDialog();
  private:
  Wt::WPushButton * const m_button_generate;
  Wt::WTextArea * const m_text_area;
  void OnGenerateClick();
};
//---------------------------------------------------------------------------
#endif // WTRANDOMCODEGENERATEDIALOG_H

 

 

 

 

 

wtrandomcodemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#include <cassert>
//---------------------------------------------------------------------------
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
//---------------------------------------------------------------------------
#include <Wt/WBreak>
#include <Wt/WImage>
#include <Wt/WLabel>
#include <Wt/WText>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
//---------------------------------------------------------------------------
#include "about.h"
#include "randomcodemenudialog.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "wtrandomcodemenudialog.h"
#include "wtrandomcodegeneratedialog.h"
//---------------------------------------------------------------------------
//QFile must be #included after Wt header files
#include <QFile>
//---------------------------------------------------------------------------
WtRandomCodeMenuDialog::WtRandomCodeMenuDialog()
{
  CheckResources();
  this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WText * const title = new Wt::WText("RandomCode");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    //Using CSS styleclass is the best (only?) way to display the menu well
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewGenerateDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}
//---------------------------------------------------------------------------
void WtRandomCodeMenuDialog::CheckResources()
{
//Create resources
  std::vector<std::string> image_names;
  image_names.push_back("ToolRandomCodeWelcome.png");

  BOOST_FOREACH(const std::string& filename,image_names)
  {
    if (!(QFile::exists(filename.c_str())))
    {
      QFile f( (std::string(":/images/") + filename).c_str() );
      f.copy(filename.c_str());
    }
    if (!QFile::exists(filename.c_str()))
    {
      const std::string s = "File not found: " + filename;
      throw std::logic_error(s.c_str());
    }
    assert(QFile::exists(filename.c_str()));
  }
}
//---------------------------------------------------------------------------
WtAboutDialog * WtRandomCodeMenuDialog::CreateNewAboutDialog()
{
  About a = RandomCodeMenuDialog::GetAbout();
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}
//---------------------------------------------------------------------------
WtRandomCodeGenerateDialog * WtRandomCodeMenuDialog::CreateNewGenerateDialog() const
{
  WtRandomCodeGenerateDialog * const d = new WtRandomCodeGenerateDialog;
  assert(d);
  return d;
}
//---------------------------------------------------------------------------
Wt::WWidget * WtRandomCodeMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to RandomCode!",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("The goal of RandomCode is to generate random C++ code",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WImage("ToolRandomCodeWelcome.png",dialog);
  return dialog;
}
//---------------------------------------------------------------------------

 

 

 

 

 

wtrandomcodemenudialog.h

 

//---------------------------------------------------------------------------
/*
RandomCode, tool to generate random C++ code
Copyright (C) 2010-2011  Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRandomCode.htm
//---------------------------------------------------------------------------
#ifndef WTRANDOMCODEMENUDIALOG_H
#define WTRANDOMCODEMENUDIALOG_H
//---------------------------------------------------------------------------
#include <boost/signals2.hpp>
//---------------------------------------------------------------------------
#include <Wt/WContainerWidget>
#include <Wt/WPushButton>
//---------------------------------------------------------------------------
namespace Wt
{
  struct WWidget;
}
//---------------------------------------------------------------------------
struct WtAboutDialog;
struct WtRandomCodeGenerateDialog;
//---------------------------------------------------------------------------
struct WtRandomCodeMenuDialog : public Wt::WContainerWidget
{
  WtRandomCodeMenuDialog();
  private:
  void CheckResources();
  WtAboutDialog * CreateNewAboutDialog();
  WtRandomCodeGenerateDialog * CreateNewGenerateDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;
};
//---------------------------------------------------------------------------
#endif // WTRANDOMCODEMENUDIALOG_H

 

 

 

 

 

zip.sh

 

#!/bin/sh
#zip packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#  * Classes
#    * CppAbout
#    * CppQtAboutDialog
#    * CppRandomCode
#    * CppWtAboutDialog
#    * CppWtAutoConfig
#  * Tools
#    * ToolRandomCode

rm *.user


echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppQtAboutDialog
mkdir temp_zip/Classes/CppRandomCode
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolRandomCode

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppQtAboutDialog/*.* temp_zip/Classes/CppQtAboutDialog
cp ../../Classes/CppRandomCode/*.* temp_zip/Classes/CppRandomCode
cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog
cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig
cp ../../Tools/ToolRandomCode/*.* temp_zip/Tools/ToolRandomCode

FILENAME=ToolRandomCodeSource_4_1
ZIP_FILENAME=$FILENAME".zip"

echo "Compressing files"
cd temp_zip
zip -r $FILENAME Classes
#zip -r $FILENAME Libraries
#zip -r $FILENAME Projects
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppQtAboutDialog/*.*
rm temp_zip/Classes/CppRandomCode/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppQtAboutDialog
rmdir temp_zip/Classes/CppRandomCode
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Classes
rm temp_zip/Tools/ToolRandomCode/*.*
rmdir temp_zip/Tools/ToolRandomCode
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict