Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

winsys.H

Go to the documentation of this file.
00001 #ifndef WINSYS_INC
00002 #define WINSYS_INC
00003 #include "disp/view.H"
00004 #include "dev/dev.H"
00005 //#include "widgets/file_select.H"
00006 //#include "widgets/alert_box.H"
00007 
00008 // Callback base 
00009 class MAPPED_CB {
00010    public:
00011       virtual ~MAPPED_CB() {}
00012       virtual void mapped() = 0; // Called when window is mapped (appears)
00013       virtual void icon  () = 0; // Called when window is iconified...
00014 };
00015 
00016 // WINSYS base class
00017 //
00018 // All implemented window systems have subclasses of this class implemented,
00019 // instances are created with the WINSYS::create() static method so that all
00020 // window system dependent issues are hidden
00021 //
00022 // This class derives from DEVmod_gen since all WINSYS are supposed to 
00023 // provide the virtual function 'mods()' that determines which modifiers
00024 // are pressed at any given time.
00025 //
00026 class MoveMenu;
00027 class AlertBox;
00028 class FileSelect;
00029 
00030 class WINSYS: public DEVmod_gen {
00031    protected:
00032       MAPPED_CB  *_map_cb;          // What to call back when the view window
00033                                     // is mapped and iconified
00034       VIEWptr     _view;            // View
00035       int         _double_buffered; // Whether we are double buffering or not
00036       int         _stencil_buffer;  // Do we have a stencil buffer?
00037 
00038    public:
00039       WINSYS() : _map_cb(0), _double_buffered(0), _stencil_buffer(0) {}
00040       virtual ~WINSYS() {}
00041 
00042       static  WINSYS *create(int &argc, char **argv);
00043 
00044       virtual CVIEWptr &view()              {return _view;}
00045       virtual void    set_focus() {}    // Make *this* window the active one!
00046       virtual void    set_context()  = 0; // We're drawing in *this* window!
00047       virtual void    swap_buffers() = 0; // Swaps buffers when double buffering
00048       
00049 
00050       virtual void    set_cursor(int i)  = 0; // Switches to cursor number i
00051       virtual int     get_cursor()  = 0; // Set current cursor 
00052 
00053       virtual void    display()      = 0; // Display that window!
00054       virtual void    setup(CVIEWptr &v) { _view = v; } // do initialization
00055       virtual WINSYS *copy()         = 0; // Make a new window
00056       virtual void    size(int &w, int &h) {}
00057       virtual void    position(int &x, int &y) {}
00058       virtual void    size_manually(int w, int h) { }
00059       virtual void    position_manually(int w, int h) { }
00060 
00061       // Bits per pixel in the colorbuffer for r, g, b, a
00062       virtual uint    red_bits()        const = 0;
00063       virtual uint    green_bits()      const = 0;
00064       virtual uint    blue_bits()       const = 0;
00065       virtual uint    alpha_bits()      const = 0;
00066 
00067       // Bits per pixel in the colorbuffer for r, g, b, a
00068       virtual uint    accum_red_bits()        const = 0;
00069       virtual uint    accum_green_bits()      const = 0;
00070       virtual uint    accum_blue_bits()       const = 0;
00071       virtual uint    accum_alpha_bits()      const = 0;
00072 
00073       virtual uint    stencil_bits()      const = 0;
00074       virtual uint    depth_bits()        const = 0;
00075 
00076       virtual void    stereo(VIEWimpl::stereo_mode m) = 0; // Set stereo mode
00077       virtual void    map_cb             (MAPPED_CB *cb)   { _map_cb = cb; }
00078       virtual int     double_buffered    () const { return _double_buffered; }
00079       virtual void    set_double_buffered(int db) { _double_buffered = db; }
00080       virtual int     stencil_buffer     () const { return _stencil_buffer; }
00081 
00082       // Accessors for window specific mouse, menu, cursor push, and file
00083       // selection objects
00084       virtual Mouse*       mouse() = 0;
00085       virtual MoveMenu*    menu(Cstr_ptr &name) = 0;
00086       virtual DEVhandler*  curspush() = 0;
00087       virtual FileSelect*  file_select() = 0;
00088       virtual AlertBox*    alert_box() = 0;
00089 
00090       virtual int id() const { 
00091          cerr << "Warning:  dummy WINSYS::id() called" << endl;
00092          return -1; 
00093       }
00094    
00095       // Connection locking/unlocking for multithreaded apps
00096       virtual void    lock() = 0;
00097       virtual void    unlock() = 0;
00098 
00099       // Optional drawing of window features (E.g., a cutom cursor)
00100       virtual int draw() { return 0; } 
00101 
00102       // Indicates whether or not window needs context to be set.
00103       // (E.g., to ensure that view will call window's set_context()
00104       // before rendering.)
00105       virtual int needs_context() { return 0; }    
00106 
00107       virtual STDdstream & operator<<(STDdstream &ds) 
00108       {
00109          //Base call sends dummy position and size
00110          return ds << 0 << 0 << 640 << 480;
00111       }
00112 
00113       virtual STDdstream & operator>>(STDdstream &ds) 
00114       {
00115          int foo;
00116          return ds >> foo >> foo >> foo >> foo;
00117       }
00118       enum cursor_t {
00119          CURSOR_RIGHT_ARROW = 0,     //Arrow pointing up and to the right. 
00120          CURSOR_LEFT_ARROW,          //Arrow pointing up and to the left. 
00121          CURSOR_INFO,                //Pointing hand. 
00122          CURSOR_DESTROY,             //Skull & cross bones. 
00123          CURSOR_HELP,                //Question mark. 
00124          CURSOR_CYCLE,               //Arrows rotating in a circle. 
00125          CURSOR_SPRAY,               //Spray can. 
00126          CURSOR_WAIT,                //Wrist watch. 
00127          CURSOR_TEXT,                //Insertion point cursor for text. 
00128          CURSOR_CROSSHAIR,           //Simple cross-hair. 
00129          CURSOR_UP_DOWN,             //Bi-directional pointing up & down. 
00130          CURSOR_LEFT_RIGHT,          //Bi-directional pointing left & right. 
00131          CURSOR_TOP_SIDE,            //Arrow pointing to top side. 
00132          CURSOR_BOTTOM_SIDE,         //Arrow pointing to bottom side. 
00133          CURSOR_LEFT_SIDE,           //Arrow pointing to left side. 
00134          CURSOR_RIGHT_SIDE,          //Arrow pointing to right side. 
00135          CURSOR_TOP_LEFT_CORNER,     //Arrow pointing to top-left corner. 
00136          CURSOR_TOP_RIGHT_CORNER,    //Arrow pointing to top-right corner. 
00137          CURSOR_BOTTOM_RIGHT_CORNER, //Arrow pointing to bottom-left corner. 
00138          CURSOR_BOTTOM_LEFT_CORNER,  //Arrow pointing to bottom-right corner. 
00139          CURSOR_FULL_CROSSHAIR,      //Full-screen cross-hair cursor 
00140          CURSOR_NONE,                //Invisible cursor. 
00141          CURSOR_INHERIT              //Use parent's cursor.          
00142       };
00143 };
00144 #endif

Generated on Mon Sep 18 11:39:34 2006 for jot by  doxygen 1.4.4