libeblearngui
/home/rex/ebltrunk/tools/libeblearngui/include/datasource_gui.h
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Pierre Sermanet   *
00003  *   pierre.sermanet@gmail.com   *
00004  *   All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions are met:
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Redistribution under a license not approved by the Open Source
00014  *       Initiative (http://www.opensource.org) must display the
00015  *       following acknowledgement in all advertising material:
00016  *        This product includes software developed at the Courant
00017  *        Institute of Mathematical Sciences (http://cims.nyu.edu).
00018  *     * The names of the authors may not be used to endorse or promote products
00019  *       derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY
00025  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00028  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  ***************************************************************************/
00032 
00033 #ifndef DATASOURCE_GUI_H_
00034 #define DATASOURCE_GUI_H_
00035 
00036 #include "libidxgui.h"
00037 #include "datasource.h"
00038 
00039 using namespace std;
00040 
00041 namespace ebl {
00042 
00045   template<class Tnet, class Tdata, class Tlabel>
00046     class labeled_datasource_gui : public scroll_box {
00047   protected:
00048     bool                scroll;
00049     bool                scroll_added;
00050     unsigned int        pos;
00051     int                 display_wid;
00052     unsigned int        _nh;
00053     unsigned int        _nw;
00054     double              _zoom;
00055     Tnet                _rmin;
00056     Tnet                _rmax;
00057     bool                _replaced;
00058     
00059   public:
00060     labeled_datasource<Tnet, Tdata, Tlabel>     *_last_ds;
00061     labeled_datasource<Tnet, Tdata, Tlabel>     *_ds;
00062 
00064     labeled_datasource_gui(bool scroll = false);
00065     virtual ~labeled_datasource_gui();
00066 
00071     virtual void display(labeled_datasource<Tnet, Tdata, Tlabel> &ds,
00072                          unsigned int nh, unsigned int nw, 
00073                          unsigned int h0 = 0, unsigned int w0 = 0, 
00074                          double zoom = 1.0, int wid = -1, 
00075                          const char *wname = NULL, bool scrolling = false,
00076                          Tnet rangemin = 0, Tnet rangemax = 0);
00077 
00078     virtual void display_pickings(labeled_datasource<Tnet, Tdata, Tlabel> &ds,
00079                                   unsigned int nh, unsigned int nw, 
00080                                   unsigned int h0 = 0, unsigned int w0 = 0, 
00081                                   double zoom = 1.0, int wid = -1, 
00082                                   const char *wname = NULL,
00083                                   bool scrolling = false,
00084                                   Tnet rangemin = 0, Tnet rangemax = 0);
00085 
00087     // inherited methods to implement for scrolling capabilities
00088     
00090     virtual void display_next ();
00092     virtual void display_previous ();
00094     virtual unsigned int max_pages ();
00095     //    virtual scroll_box0* copy();
00096     virtual labeled_datasource_gui* copy();
00097   };
00098 
00101   template<class Tnet, class Tdata, class Tlabel>
00102     class labeled_pair_datasource_gui
00103     : public labeled_datasource_gui<Tnet, Tdata, Tlabel> {
00104   protected:
00105     labeled_pair_datasource<Tnet, Tdata, Tlabel>        *_last_ds;
00106   public:
00107     labeled_pair_datasource<Tnet, Tdata, Tlabel>        *_ds;
00108     
00110     labeled_pair_datasource_gui(bool scroll = false);
00111     virtual ~labeled_pair_datasource_gui();
00112 
00117     virtual void display(labeled_pair_datasource<Tnet, Tdata, Tlabel> &ds,
00118                          unsigned int nh, unsigned int nw, 
00119                          unsigned int h0 = 0, unsigned int w0 = 0, 
00120                          double zoom = 1.0, int wid = -1, 
00121                          const char *wname = NULL, bool scrolling = false,
00122                          Tnet rangemin = 0, Tnet rangemax = 0);
00123 
00125     // inherited methods to implement for scrolling capabilities
00126     
00128     virtual void display_next ();
00130     virtual void display_previous ();
00132     virtual unsigned int max_pages ();
00134      virtual labeled_pair_datasource_gui* copy(); 
00135    };
00136 
00137 } // end namespace ebl
00138 
00139 #include "datasource_gui.hpp"
00140 
00141 #endif /* DATASOURCE_GUI_H_ */