Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2008-02-05 00:44:12


Author: srajko
Date: 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
New Revision: 43109
URL: http://svn.boost.org/trac/boost/changeset/43109

Log:
add cppgui example
Added:
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.cpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.cpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.hpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.hpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.cpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.cpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.hpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.hpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.cpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.cpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.hpp
      - copied, changed from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.hpp
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/cppgui_example.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 | 1
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.cpp | 57 ++++++++++++++++++-------
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.hpp | 29 +++++++-----
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.cpp | 91 ++++++++++++++++++++-------------------
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.hpp | 30 +++++-------
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.cpp | 89 +++++++++++++++++---------------------
   sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.hpp | 36 +++++++-------
   sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/fltk_gui_example.cpp | 17 ------
   8 files changed, 177 insertions(+), 173 deletions(-)

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -7,6 +7,7 @@
 build-project signals ;
 build-project blueprint ;
 build-project fltk_gui ;
+build-project cppgui_gui ;
 
 project dataflow/example
     : requirements

Added: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/Jamfile.v2 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -0,0 +1,26 @@
+# Copyright 2007 Stjepan Rajko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os ;
+
+use-project gui
+ : /Development/cppgui
+ ;
+
+project dataflow/example/cppgui_gui
+ : requirements
+ <include>../../../..
+ <library>/gui//gui/<link>static
+ <define>BOOST_ALL_NO_LIB=1
+ ;
+
+local sources =
+ cppgui_example
+ blueprint_bank
+ blueprint_window
+ blueprint_component
+ ;
+
+exe cppgui_example : $(sources).cpp ;

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.cpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.cpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.cpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -3,29 +3,54 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include "BlueprintBank.hpp"
-#include "BlueprintWindow.hpp"
-#include <fltk/Button.h>
+#include <gui/gui.hpp>
+#include "blueprint_bank.hpp"
+#include "blueprint_window.hpp"
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+namespace boost { namespace dataflow { namespace cppgui {
 
-void BlueprintBank::button_callback(fltk::Widget* widget, void*b)
+struct blueprint_bank::events
 {
- BlueprintBank *bank= static_cast<BlueprintBank *>(b);
- bank->m_blueprint->add_component(bank->m_bank[widget->label()], widget->label());
-}
-
-void BlueprintBank::rearrange()
+ events(gui::wnd<blueprint_bank> w)
+ {
+ for (blueprint_bank::component_buttons_type::iterator it
+ = w->m_component_buttons.begin(); it!= w->m_component_buttons.end(); it++)
+ (*it)->click_signal().connect(boost::bind(w->use_event(&events::click), "argh"));
+ }
+
+ void click(gui::wnd<blueprint_bank> bank, const std::string &text)
+ {
+ bank->m_blueprint->add_component(bank->m_bank[text], text);
+ }
+};
+
+
+void blueprint_bank::rearrange()
 {
- clear();
+ gui::wnd<blueprint_bank> this_ = wnd_from_this();
+ namespace controls = gui::controls;
+
+// clear();
     int y = 0;
- for(blueprint::component_bank::iterator it= m_bank.begin(); it!=m_bank.end(); it++)
+
+ for(blueprint::component_bank::iterator it=m_bank.begin(); it!=m_bank.end(); it++)
     {
- fltk::Button *button = new fltk::Button(0, y, 100, 100, it->c_str());
- y += 100;
- button->callback((fltk::Callback *)&button_callback, this);
- add(button);
+ m_component_buttons.push_back(
+ gui::create<controls::button>
+ ( gui::_text = it->c_str()
+ , gui::_parent = this_
+ , gui::_size = std::make_pair(100, 100)
+ , gui::_pos = std::make_pair(0, y) ) );
+ y += 100;
     }
+
+ std::auto_ptr<events> pe(new events(this_));
+ add_event_class<events>(pe);
+}
+
+void blueprint_bank::create_wnd(create_params& params)
+{
+ gui::params(params, gui::_size = std::make_pair(100, 600));
 }
 
 } } }

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.hpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.hpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintBank.hpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_bank.hpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -9,35 +9,38 @@
 
 #include <boost/dataflow/blueprint/component_bank.hpp>
 
-#include <fltk/window.h>
+#include <gui/controls/button.hpp>
+#include <gui/frame_window.hpp>
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+namespace boost { namespace dataflow { namespace cppgui {
 
-class BlueprintWindow;
+class blueprint_window;
 
-class BlueprintBank : public fltk::Window
+class blueprint_bank : public gui::subclass<blueprint_bank, gui::frame_window>
 {
 public:
- BlueprintBank(int w, int h, const char *label = 0)
- : fltk::Window(w, h, label)
- {}
- BlueprintBank(int x, int y, int w, int h, const char *label = 0, bool begin=false)
- : fltk::Window(x, y, w, h, label, begin)
- {}
+ blueprint_bank() {};
+
+ static void create_wnd(create_params&);
+
     void set_bank(const blueprint::component_bank &bank)
     {
         m_bank = bank;
         rearrange();
     }
- void set_blueprint(BlueprintWindow &blueprint)
+ void set_blueprint(blueprint_window &blueprint)
     {
         m_blueprint = &blueprint;
     }
- static void button_callback(fltk::Widget* widget, void*b);
+
+ typedef std::vector<child_wnd<gui::controls::button> > component_buttons_type;
 private:
     void rearrange();
- BlueprintWindow * m_blueprint;
+ blueprint_window * m_blueprint;
     blueprint::component_bank m_bank;
+ component_buttons_type m_component_buttons;
+
+ struct events;
 };
 
 } } }

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.cpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.cpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.cpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -3,38 +3,41 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include "BlueprintComponent.hpp"
-#include <fltk/events.h>
+#include <gui/gui.hpp>
+#include "blueprint_component.hpp"
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+#include <gui/controls/button.hpp>
 
-class BlueprintComponentCore : public fltk::Button
+namespace boost { namespace dataflow { namespace cppgui {
+
+class blueprint_component_core
+ : public gui::subclass<blueprint_component_core, gui::controls::button>
 {
 public:
- BlueprintComponentCore(int x, int y, int w, int h, bool invocable)
- : fltk::Button(x, y, w, h, invocable ? "invoke" : 0)
- , m_dragged(false)
- , m_invocable(invocable)
+ blueprint_component_core()
+// : fltk::Button(x, y, w, h, invocable ? "invoke" : 0)
+// , m_dragged(false)
+// , m_invocable(invocable)
     {
- callback((fltk::Callback *)on_push, this);
+// callback((fltk::Callback *)on_push, this);
     }
     int handle(int event);
 private:
- static void on_push(fltk::Widget *widget, BlueprintComponentCore *core)
+/* static void on_push(fltk::Widget *widget, BlueprintComponentCore *core)
     {
- if (!core->m_dragged && core->m_invocable)
- core->component().invoke();
- }
- BlueprintComponent &component()
- { return *static_cast<BlueprintComponent *>(parent()); }
+// if (!core->m_dragged && core->m_invocable)
+// core->component().invoke();
+ }*/
+ blueprint_component &component()
+ { return *static_cast<blueprint_component *>(NULL/*parent()*/); }
     int push_x, push_y;
     bool m_dragged;
     bool m_invocable;
 };
 
-int BlueprintComponentCore::handle(int event)
+int blueprint_component_core::handle(int event)
 {
- switch (event)
+/* switch (event)
     {
     case fltk::DRAG:
         parent()->position(parent()->x() + fltk::event_x_root() - push_x, parent()->y() + fltk::event_y_root() - push_y);
@@ -44,12 +47,13 @@
         m_dragged = event==fltk::DRAG;
         return fltk::Button::handle(event);
     }
- return fltk::Button::handle(event);
+ return fltk::Button::handle(event);*/
+ return 0;
 }
 
-int BlueprintComponentPort::handle(int event)
+int blueprint_component_port::handle(int event)
 {
- switch(event)
+/* switch(event)
     {
         case fltk::DND_RELEASE:
             return blueprint().register_drop(this);;
@@ -64,46 +68,45 @@
             blueprint().register_drag(this);
             fltk::dnd();
     }
- return fltk::Button::handle(event);
-}
-
-BlueprintComponent::BlueprintComponent(int x, int y, int w, int h, const char *label, blueprint::component &c, id_type id)
- : fltk::Group(x, y, w, h)
-{
- BlueprintComponent_(label);
- set_component(c, id);
+ return fltk::Button::handle(event);*/
+ return 0;
 }
 
-BlueprintComponent::BlueprintComponent(int x, int y, int w, int h, const char *label)
- : fltk::Group(x, y, w, h)
+blueprint_component::blueprint_component()
 {
- BlueprintComponent_(label);
+// BlueprintComponent_(label);
+// set_component(c, id);
 }
 
-void BlueprintComponent::BlueprintComponent_(const char *label)
+/*void BlueprintComponent::BlueprintComponent_(const char *label)
 {
- copy_label(label);
- add(m_gui_group = new fltk::Group(0,80,100,60));
- resize(100, 160);
-}
+// copy_label(label);
+// add(m_gui_group = new fltk::Group(0,80,100,60));
+// resize(100, 160);
+}*/
 
-void BlueprintComponent::gui_begin()
+void blueprint_component::gui_begin()
 {
- m_gui_group->begin();
+// m_gui_group->begin();
 }
 
-void BlueprintComponent::gui_end()
+void blueprint_component::gui_end()
 {
- m_gui_group->end();
+// m_gui_group->end();
 }
 
-void BlueprintComponent::set_component(blueprint::component &c, id_type id)
+void blueprint_component::set_component(blueprint::component &c, id_type id)
 {
     m_component=&c;
     m_id = id;
- add(new BlueprintComponentCore(20, 20, 60, 60, c.is_invocable()));
     
- int y_left = 20;
+ gui::wnd<blueprint_component> this_ = wnd_from_this();
+ gui::create<blueprint_component_core>
+ ( gui::_pos = std::make_pair(20, 20)
+ , gui::_size = std::make_pair(60, 60)
+ , gui::_parent = this_);//, c.is_invocable()));
+
+/* int y_left = 20;
     int y_right = 20;
     
     for (size_t i=0; i<c.num_ports(); i++)
@@ -116,7 +119,7 @@
         {
             add(new BlueprintComponentPort(0, y_left, 20, 20, "@>", i));
             y_left+=20;
- }
+ }*/
 }
 
 

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.hpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.hpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintComponent.hpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_component.hpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -6,47 +6,43 @@
 #ifndef BLUEPRINT_COMPONENT_HPP
 #define BLUEPRINT_COMPONENT_HPP
 
-#include <fltk/Button.h>
-#include "BlueprintWindow.hpp"
+#include "blueprint_window.hpp"
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+namespace boost { namespace dataflow { namespace cppgui {
 
-class BlueprintComponent : public fltk::Group
+class blueprint_component : public gui::subclass<blueprint_component, gui::window>
 {
     typedef blueprint::network::component_type id_type;
 public:
- BlueprintComponent(int x, int y, int w, int h, const char *label, blueprint::component &c, id_type id);
- BlueprintComponent(int x, int y, int w, int h, const char *label);
+ blueprint_component();
     void set_component(blueprint::component &c, id_type id);
     void gui_begin();
     void gui_end();
     void invoke() {m_component->invoke();}
     id_type id() {return m_id;}
 private:
- void BlueprintComponent_(const char *label);
     blueprint::component *m_component;
     std::string m_name;
     id_type m_id;
- fltk::Group *m_gui_group;
+// fltk::Group *m_gui_group;
 };
 
-class BlueprintComponentPort : public fltk::Button
+class blueprint_component_port// : public fltk::Button
 {
 public:
- BlueprintComponentPort(int x, int y, int w, int h, const char *label, size_t id)
- : fltk::Button(x, y, w, h, label), m_id(id)
+ blueprint_component_port()
     {}
     int handle(int event);
- BlueprintComponent &component()
- { return *static_cast<BlueprintComponent *>(parent()); }
+ blueprint_component &component()
+ { return *static_cast<blueprint_component *>(0/*parent()*/); }
     int center_x_root()
- { return parent()->x() + center_x(); }
+ { /*return parent()->x() + center_x(); */ return 0;}
     int center_y_root()
- { return parent()->y() + center_y(); }
+ { /*return parent()->y() + center_y(); */ return 0;}
     size_t id() {return m_id;}
 private:
- BlueprintWindow &blueprint()
- { return *static_cast<BlueprintWindow *>(parent()->parent()); }
+ blueprint_window &blueprint()
+ { return *static_cast<blueprint_window *>(0/*parent()->parent()*/); }
     size_t m_id;
 };
 

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.cpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.cpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.cpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -3,60 +3,49 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include "BlueprintWindow.hpp"
-#include "BlueprintComponent.hpp"
-//#include <fltk/MenuBar.hpp>
-#include <fltk/draw.h>
-#include <fltk/events.h>
+#include <gui/gui.hpp>
+#include "blueprint_window.hpp"
+#include "blueprint_component.hpp"
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+namespace boost { namespace dataflow { namespace cppgui {
 
-BlueprintWindow::BlueprintWindow(int width, int height, const char *label)
- : fltk::Window(width, height)
+blueprint_window::blueprint_window()
 {
- copy_label(label);
     m_next_created_x = 100;
     m_next_created_y = 50;
- /*fltk::Group *box= new fltk::Group(width, height, 0, 0);
- add(box);
- box->hide();
- resizable(box);*/
-
-
-// begin();
-/* fltk::MenuBar menubar(0,0,width,25);
- menubar.callback(callback);
- menubar.begin();
- fltk::ItemGroup file("&Blueprint");
- file.begin();
- Item* o = new Item("Instantiate connections");
- file.end();
- end();*/
 }
 
-void BlueprintWindow::add_component(std::auto_ptr<blueprint::component> c, const std::string &name)
+void blueprint_window::add_component(std::auto_ptr<blueprint::component> c, const std::string &name)
 {
- BlueprintComponent *bc = new BlueprintComponent(m_next_created_x, m_next_created_y, 100, 100, name.c_str(), *c, m_network.add_component(c));
- add_component_helper(bc);
+ //BlueprintComponent *bc = new BlueprintComponent(m_next_created_x, m_next_created_y, 100, 100, name.c_str(), *c, m_network.add_component(c));
+ //add_component_helper(bc);
 }
 
-void BlueprintWindow::add_component(boost::function<blueprint::component *()> f, const std::string &name)
+void blueprint_window::add_component(boost::function<blueprint::component *()> f, const std::string &name)
 {
- BlueprintComponent *bc = new BlueprintComponent(m_next_created_x, m_next_created_y, 100, 100, name.c_str());
- bc->gui_begin();
- std::auto_ptr<blueprint::component> c(f());
- blueprint::network::component_type id = m_network.add_component(c);
- bc->set_component(m_network[id], id);
- bc->gui_end();
- add_component_helper(bc);
+ gui::wnd<blueprint_window> this_ = wnd_from_this();
+
+/* gui::wnd<blueprint_component> bc = gui::create<blueprint_component>
+ ( gui::_pos = std::make_pair(m_next_created_x, m_next_created_y)
+ , gui::_size = std::make_pair(100, 100)
+ , gui::_text = name
+ , gui::_parent = this_);*/
+
+// bc->gui_begin();
+// std::auto_ptr<blueprint::component> c(f());
+// blueprint::network::component_type id = m_network.add_component(c);
+// bc->set_component(m_network[id], id);
+// bc->gui_end();
+
+// add_component_helper(*bc);
 }
 
-void BlueprintWindow::add_component_helper(BlueprintComponent *bc)
+void blueprint_window::add_component_helper(blueprint_component &bc)
 {
- add(bc);
- redraw();
+/* add(bc);
+ redraw();*/
     m_next_created_x += 150;
- if (m_next_created_x + 100 > w())
+ if (m_next_created_x + 100 > bc.size().first)
     {
         m_next_created_x = 100;
         m_next_created_y += 150;
@@ -64,21 +53,21 @@
 }
     
 
-bool BlueprintWindow::register_drop(BlueprintComponentPort *port)
+bool blueprint_window::register_drop(blueprint_component_port *port)
 {
- return m_network.are_connectable(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id());
+// return m_network.are_connectable(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id());
 }
 
-void BlueprintWindow::connect_dragged_with(BlueprintComponentPort *port)
+void blueprint_window::connect_dragged_with(blueprint_component_port *port)
 {
- m_network.add_connection(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id(), true);
+/* m_network.add_connection(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id(), true);
     m_connections.push_back(Connection(m_dragged, port));
- redraw();
+ redraw();*/
 }
 
-void BlueprintWindow::draw()
+void blueprint_window::draw()
 {
- fltk::Window::draw();
+/* fltk::Window::draw();
     for (std::vector<Connection>::iterator it=m_connections.begin(); it!=m_connections.end(); it++)
     {
         fltk::setcolor(it == m_selected ? fltk::RED : fltk::GREEN);
@@ -87,7 +76,7 @@
             it->first->center_y_root(),
             it->second->center_x_root(),
             it->second->center_y_root());
- }
+ }*/
 }
 
 namespace detail
@@ -116,9 +105,9 @@
     }
 }
 
-int BlueprintWindow::handle(int event)
+int blueprint_window::handle(int event)
 {
- if (fltk::Window::handle(event))
+/* if (fltk::Window::handle(event))
         return 1;
     bool found=false;
     if(event == fltk::PUSH)
@@ -136,7 +125,7 @@
             }
     if (!found)
         m_selected = std::vector<Connection>::iterator();
- redraw();
+ redraw();*/
     return 0;
 }
 

Copied: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.hpp (from r42302, /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.hpp)
==============================================================================
--- /sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/BlueprintWindow.hpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/blueprint_window.hpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -6,46 +6,46 @@
 #ifndef BLUEPRINT_WINDOW_HPP
 #define BLUEPRINT_WINDOW_HPP
 
-#include <fltk/Window.h>
+#include <gui/frame_window.hpp>
 
 #include <boost/dataflow/blueprint/network.hpp>
 #include <boost/dataflow/signals/runtime_support.hpp>
 
-namespace boost { namespace dataflow { namespace fltk_gui {
+namespace boost { namespace dataflow { namespace cppgui {
 
-class BlueprintComponent;
-class BlueprintComponentPort;
+class blueprint_component;
+class blueprint_component_port;
 
-class Connection
- : public std::pair<BlueprintComponentPort *, BlueprintComponentPort *>
+class connection
+ : public std::pair<blueprint_component_port *, blueprint_component_port *>
 {
 public:
- Connection(BlueprintComponentPort *p1, BlueprintComponentPort *p2)
- : std::pair<BlueprintComponentPort *, BlueprintComponentPort *>(p1, p2)
+ connection(blueprint_component_port *p1, blueprint_component_port *p2)
+ : std::pair<blueprint_component_port *, blueprint_component_port *>(p1, p2)
     {}
 };
 
-class BlueprintWindow : public fltk::Window
+class blueprint_window : public gui::subclass<blueprint_window, gui::frame_window>
 {
 public:
- BlueprintWindow(int width, int height, const char *label = 0);
+ blueprint_window();
     void add_component(std::auto_ptr<blueprint::component> c, const std::string &name);
     void add_component(boost::function<blueprint::component *()> f, const std::string &name);
- void register_drag(BlueprintComponentPort *port)
+ void register_drag(blueprint_component_port *port)
     {
         m_dragged = port;
     }
- bool register_drop(BlueprintComponentPort *port);
- void connect_dragged_with(BlueprintComponentPort *port);
+ bool register_drop(blueprint_component_port *port);
+ void connect_dragged_with(blueprint_component_port *port);
 private:
- void add_component_helper(BlueprintComponent *bc);
+ void add_component_helper(blueprint_component &bc);
     virtual void draw();
     virtual int handle(int event);
     blueprint::network m_network;
- std::vector<BlueprintComponent *> m_components;
- BlueprintComponentPort *m_dragged;
- std::vector<Connection> m_connections;
- std::vector<Connection>::iterator m_selected;
+ std::vector<blueprint_component *> m_components;
+ blueprint_component_port *m_dragged;
+ std::vector<connection> m_connections;
+ std::vector<connection>::iterator m_selected;
     int m_next_created_x;
     int m_next_created_y;
 };

Added: sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/cppgui_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/cppgui_gui/cppgui_example.cpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -0,0 +1,95 @@
+//[ cppgui_example
+
+// Copyright 2007 Stjepan Rajko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#include <gui/gui.hpp>
+#include <gui/frame_window.hpp>
+
+#include "blueprint_bank.hpp"
+#include "blueprint_window.hpp"
+
+#include <boost/dataflow/signals/component/function.hpp>
+#include <boost/dataflow/signals/component/storage.hpp>
+#include <boost/dataflow/signals/runtime_support.hpp>
+#include <boost/dataflow/blueprint/component_bank.hpp>
+
+namespace blueprint=boost::dataflow::blueprint;
+namespace signals=boost::signals;
+namespace df=boost::dataflow;
+
+// A regular Dataflow.Signals component, sends and receives void(int)
+class output_valuator : public signals::filter<output_valuator, void(int), boost::mpl::vector<void(int)> >
+{
+public:
+ output_valuator()
+ { valuator_(); }
+ void operator()(int x)
+ {
+// m_output->value(x);
+ out(x);
+ }
+public:
+ void valuator_()
+ {
+ // This component has a GUI element
+// m_output = new fltk::ValueOutput(20, 0, 60, 40);
+ }
+// std::auto_ptr<fltk::Window> m_window;
+// fltk::ValueOutput *m_output;
+};
+
+// A regular Dataflow.Signals component, receives void(int)
+class input_valuator : public boost::signals::filter<input_valuator, void(int)>
+{
+public:
+ input_valuator()
+ {
+ }
+public:
+/* static void callback(fltk::Widget *widget, input_valuator*iv)
+ {
+// iv->out(iv->m_input->value());
+ }*/
+// std::auto_ptr<fltk::Window> m_window;
+// fltk::ValueInput *m_input;
+};
+
+// A component_bank with some components
+class example_bank : public blueprint::tag_component_bank<df::signals::tag>
+{
+public:
+ example_bank()
+ {
+ // A storage initialized with a value of 100
+ add_component<signals::storage<void(int)> >("storage", 100);
+ // Output and input components
+ add_component<output_valuator>("output");
+ add_component<input_valuator>("input");
+ // A filter that doubles
+ add_component<signals::function<void (int), int(int)> >
+ ("doubler", boost::function<int(int)>(boost::bind(std::multiplies<int>(), _1, 2)));
+ }
+};
+
+int main()
+{
+
+ using namespace gui;
+
+ // create the blueprint and component windows
+ wnd<df::cppgui::blueprint_bank> bank = create<df::cppgui::blueprint_bank>(_title = "Component bank");
+ wnd<df::cppgui::blueprint_window> window = create<df::cppgui::blueprint_window>(_title = "Blueprint");
+
+ // initialize the bank
+ bank->set_bank(example_bank());
+ bank->set_blueprint(*window);
+
+ gui::wait();
+}
+
+//]
+

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/fltk_gui_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/fltk_gui_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/fltk_gui_example.cpp 2008-02-05 00:44:11 EST (Tue, 05 Feb 2008)
@@ -29,22 +29,14 @@
 class output_valuator : public signals::filter<output_valuator, void(int), boost::mpl::vector<void(int)> >
 {
 public:
- output_valuator(const output_valuator &)
- { valuator_(); }
     output_valuator()
- { valuator_(); }
+ { m_output = new fltk::ValueOutput(20, 0, 60, 40); }
     void operator()(int x)
     {
         m_output->value(x);
         out(x);
     }
 public:
- void valuator_()
- {
- // This component has a GUI element
- m_output = new fltk::ValueOutput(20, 0, 60, 40);
- }
- std::auto_ptr<fltk::Window> m_window;
     fltk::ValueOutput *m_output;
 };
 
@@ -52,12 +44,7 @@
 class input_valuator : public boost::signals::filter<input_valuator, void(int)>
 {
 public:
- input_valuator(const input_valuator &)
- { input_valuator_(); }
     input_valuator()
- { input_valuator_(); }
-public:
- void input_valuator_()
     {
         // This component has a GUI element
         m_input = new fltk::ValueInput(20, 0, 60, 40);
@@ -66,11 +53,11 @@
         m_input->minimum(-std::numeric_limits<float>::max());
         m_input->maximum(std::numeric_limits<float>::max());
     }
+public:
     static void callback(fltk::Widget *widget, input_valuator*iv)
     {
         iv->out(iv->m_input->value());
     }
- std::auto_ptr<fltk::Window> m_window;
     fltk::ValueInput *m_input;
 };
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk