Boost logo

Boost :

From: David Allan Finch (sarum_at_[hidden])
Date: 2001-04-02 09:07:01


Phlip wrote:

> Does this library use the "slots and signals" system that Qt invented and
> which I suspect Gtk+ emulates?

I don't know about Qt or Gtk+ sorry.

> I posit that a "quasi-standard" library, such as Boost always tries to be,
> should avoid using an implementation of the Observer Design Pattern that
> sucks, such as MFC's terribly heavy Message Maps.

I agree :-)

Here is an very old example. Note this does not show the libraries
off to it full advantage, as it also has 'derived method callbacks'
and 'observer pattern' on each event as well as 'C style'
callbacks (I do have examples of these somewhere).
We where also adding in a View-Controller system just before we
ended the project.

BTW the library was called 'Sticky' :-)

---8<----
//
// Input Test
//
// this is to test the new SSlider class
// DAF - 13 Mar 96

#include <sticky.hpp>

#include <math.h>

SSlider<double>* s1;
SSlider<double>* s2;
SSlider<double>* s3;
SSlider<double>* s4;

// **********************************************************************

void set_sliders()
       {
       double d1;
       double d2;
       double d3;
       double d4;

       d2 << *s2;
       d4 << *s4;

       d1 = sqrt( d2 * d4 );
       d3 = sqrt( (d2 * d2) + ( d4 + d4 ) );

       *s1 << d1;
       *s3 << d3;
       }

// **********************************************************************

bool slider_changed( SSlider<double>* s )
       {
       set_sliders();
       return( true );
       }

// **********************************************************************

int StickyMain( int& argc, char* argv[] )
       {
       // THE SYSTEM SETUP

       SApplication app( argc, argv );

       // THE FIRST WINDOW
       // This have a vertical layout panel

       STopWindow main_window;
       SWorkspace workspace;
       SVPane top_holder;
       SVPane Vholder;
       SHPane Hholder;
       SSlider<double> slider1;
       SSlider<double> slider2;
       SSlider<double> slider3;
       SSlider<double> slider4;

       s1 = &slider1;
       s2 = &slider2;
       s3 = &slider3;
       s4 = &slider4;

       slider1.min_value = 0;
       slider1.max_value = 1000;
       slider1.read_only = true;
       slider1.orientation = Horizontal;

       slider2.min_value = 0;
       slider2.max_value = 1000;
       slider2.read_only = false;
       slider2.orientation = Horizontal;
       slider2.move += (SCallback)slider_changed;

       slider3.min_value = 0;
       slider3.max_value = 1000;
       slider3.read_only = true;
       slider3.orientation = Vertical;

       slider4.min_value = 0;
       slider4.max_value = 1000;
       slider4.read_only = false;
       slider4.orientation = Vertical;
       slider4.move += (SCallback)slider_changed;

       slider2 << (double)110;
       slider4 << (double)110;

       set_sliders();

       app += main_window;
        main_window += workspace;
         workspace += top_holder;
          top_holder += Vholder;
           Vholder += slider1;
           Vholder += slider2;
          top_holder += Hholder;
           Hholder += slider3;
           Hholder += slider4;

       main_window.name = "SSlider Test";

       return( app() );
       }
---8<----


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk