Main Page | Namespace List | Class Hierarchy | Data Structures | File List | Data Fields | Globals

scrollableview.h

Go to the documentation of this file.
00001 //--- < SCROLLABLEVIEW.H > ------| ViewGraph - A Flexible Graph view Framework |
00002 //
00003 // Abstraction of a viewport, handles 
00004 // scrolling. Redirects drawing calls to
00005 // SurfaceDriver, shifting the parameters.
00006 //
00007 // Use this class when you do not need
00008 // zooming.
00009 //
00010 // $Author: botik32 $
00011 // $Revision: 1.6 $
00012 // $Date: 2004/05/19 16:40:36 $
00013 //-----------------------------------------------------------------------------/
00014 
00015 #ifndef SCROLLABLEVIEW_H
00016 #define SCROLLABLEVIEW_H
00017 
00018 #include <cZUI/drivers/surfacedriver.h>
00019 
00020 class Event;
00021 class Image;
00022 
00023 class ScrollableView{
00024 protected:      
00025         SurfaceDriver *sdriver;
00026         /// View's absolute position on the virtual canvas.
00027         double posx, posy;
00028         /// View's position on the surface
00029         int screenx, screeny;
00030         /// View's size on the surface
00031         int width, height;
00032         /// View's background color
00033         unsigned char bkgr,bkgg,bkgb;
00034         bool brepaint_due;
00035 public:
00036         virtual void pen( unsigned char r, unsigned char g, 
00037                 unsigned char b, int thickness );
00038         virtual void get_pen( unsigned char& r, unsigned char& g, 
00039                 unsigned char& b, int& thickness );
00040         void penstyle( const char *style );
00041         virtual void line(      double x1, double y1, double x2, double y2 );
00042         virtual void rectangle( double x1, double y1, double x2, double y2 );
00043         virtual void dot( double x1, double y1 );
00044         virtual void circle( double x1, double y1, double radius );
00045         virtual void arc( double x1, double y1, double radius,
00046                 double an1, double an2 );
00047         virtual void bezier( double x1, double y1, double x2, double y2, 
00048                                  double x3, double y3 );
00049         virtual void fill_h_triangle( double x1, double y1, 
00050                                  double x2, double y2, double x3 );
00051         virtual void fill_v_triangle( double x1, double y1, 
00052                                  double x2, double y2, double y3 );
00053         virtual void fillrect( double x1, double y1, double x2, double y2,
00054                 unsigned char fr, unsigned char fg, unsigned char fb );
00055         
00056         virtual void repaint( void );
00057         virtual void clear( void );
00058         virtual void repaint_surface( void );
00059         virtual void clear_surface( void );
00060         virtual void clear_rect( double, double, double, double );
00061         virtual void repaint_rect( double, double, double, double );
00062 
00063         // Direct repaints, no scroll/zoom transforms
00064         void clear_rect_x( double, double, double, double );
00065         void repaint_rect_x( double, double, double, double );
00066 
00067         virtual void textout( double x1, double y1, const char *text );
00068         virtual void textrect( double x1, double y1,
00069                     double x2, double y2, const char *text );
00070         virtual void setfontsize( double );
00071         void setjustification( textjustify );
00072         void setfont( const char * );
00073 
00074         void scroll_to( double x, double y );
00075         virtual void scroll( double xinc, double yinc );
00076         virtual void center( double xpos, double ypos );
00077 
00078         double get_x( void );
00079         double get_y( void );
00080         virtual void get_rect( double&, double&, double&, double& );
00081 
00082         // this returns the view rect
00083         void get_screenrect( double&, double&, double&,
00084                                                                  double& );
00085         // this returns the surface rect (0,0,srf->w,srf->h)
00086         void get_surfacerect( double&, double&, double&,
00087                                                                  double& );
00088         int get_width( void );
00089         int get_height( void );
00090 
00091         virtual bool rectfits( double, double, double, double );
00092 
00093         int get_screenx( void );
00094         int get_screeny( void );
00095 
00096         // Cursor functions
00097         void setcursor( SurfaceCursor * );
00098         SurfaceCursor* getcursor( void );
00099         void showcursor( bool );
00100 
00101         // The two functions below cannot be used
00102         // in embedded scene objects because they
00103         // are not aware of embedding.
00104         void get_mousepos( int&, int& );
00105         void get_scenemousepos( double&, double& );
00106         msbutton get_mousestate( void );
00107 
00108         void enqueue_event( Event * );
00109 
00110         Image* load_image( const char * );
00111         virtual void put_image( Image *, int destx, int desty,
00112                 double imgz=1.);
00113 
00114         void repaint_due( void )
00115         {
00116                 brepaint_due = true;
00117         };
00118 
00119         ScrollableView( SurfaceDriver *, int, int, int, int,
00120                 unsigned char, unsigned char, unsigned char );
00121 };
00122 
00123 #endif
00124 
00125 /// $Log: scrollableview.h,v $
00126 /// Revision 1.6  2004/05/19 16:40:36  botik32
00127 /// Bugfixes and enhancements:
00128 /// Added repaint_due() and brepaint_due to ScrollableView
00129 /// Fixed repaint decisions in GraphWindow to work for multiple-window
00130 /// scenes
00131 /// Fixed ScrollableView to call surfacedriver->clear() in constructor
00132 /// Changed mapchooser to use a smaller resolution world map
00133 ///
00134 /// Revision 1.5  2004/05/03 21:02:01  botik32
00135 /// Significant changes and many bugfixes.
00136 /// ScrollableView now has a background color used to
00137 /// tell SurfaceDriver to clear with.
00138 /// SurfaceDriver's clear() requires a color now
00139 /// Added SceneEvents for all node additions/removals
00140 /// in GroupNode and Camera.
00141 /// Added paint_selected and paint_selected_invalid
00142 /// to ActiveLeaf
00143 /// Modified ActiveLeaf's mouse_down and mouse_up
00144 /// handler signatures to accept an Event* instead of
00145 /// Camera*
00146 /// - Many more bugfixes
00147 ///
00148 /// Revision 1.4  2004/04/29 09:50:48  botik32
00149 /// Fixed the zoomablesurfaceview's put_image to work
00150 /// correctly with zooms.
00151 /// Moved convert_image_to16() from SurfaceDriver to Image. It
00152 /// is now called convert_to_565()
00153 /// Fixed bug in rgb24.cpp including rgb24.h in the wrong location
00154 /// Finished code zoom in ZoomableSurfaceView, not tested
00155 ///
00156 /// Revision 1.3  2004/04/15 10:31:29  botik32
00157 /// Interface change: added arc() function to surfacedriver.
00158 ///
00159 /// Revision 1.2  2004/04/09 17:15:08  botik32
00160 /// Changes in interface: added get_pen to scrollableview and
00161 /// surfacedriver
00162 ///
00163 /// Revision 1.1.1.1  2004/03/26 10:50:24  botik32
00164 /// Initial release
00165 ///
00166 /// Revision 1.1.1.1  2004/03/26 08:53:33  botik
00167 /// initial import
00168 ///
00169 ///
00170 /// Revision 1.33  2004/03/17 09:56:38  botik
00171 /// Demo now shows camera in the small window
00172 /// ScrollableView: added clear_surface() and update_surface()
00173 ///   functions
00174 /// GraphWindow: calls clear_surface() and update_surface() on update.
00175 ///
00176 /// Revision 1.32  2004/01/03 19:59:41  botik
00177 /// added text support via aedGUI
00178 ///
00179 /// Revision 1.31  2003/12/12 11:32:33  botik
00180 /// Added drivers/mouse.h
00181 /// Moved msbutton definition to drivers/mouse.h
00182 /// Added get_mousestate to SurfaceDriver
00183 /// Added get_mousestate to ScrollableView
00184 /// Changed the zoom decorator to only receive events if
00185 /// the left mouse is pressed
00186 /// Moved scroll layer beneath the zoom decorator layer
00187 /// This hopefully fixes a segfault when zoomdecorator gets
00188 /// invalid position after scroll
00189 ///
00190 /// Revision 1.30  2003/12/04 01:02:14  botik
00191 /// Added Image class to framework
00192 /// Added SDLImage class to drivers/sdxpsdl
00193 /// Added load_image to surfacedriver class
00194 /// Added put_image to surfacedriver class
00195 /// Added load_image and put_image to scrollableview class
00196 ///
00197 /// Revision 1.29  2003/12/02 14:39:37  botik
00198 /// Changed the repaint strategy to always repaint the scene
00199 /// Added Context class to handle context-related data for
00200 /// scene nodes
00201 /// Added get_surfacerect() to ScrollableView
00202 /// Camera, Scene and GraphWindow now inherit from Context
00203 /// Changed activeleaf to use Scene context to store hover
00204 /// status
00205 ///
00206 /// Revision 1.28  2003/11/29 09:41:03  botik
00207 /// Added scroll_to to scrollableview. (not used yet)
00208 /// Changed testeasynode to zoom in and out
00209 /// Fixed a bug in camera that repainted the wrong rect
00210 /// (changed repaint_rect to repaint_screenrect in
00211 /// cameramvevent handling)
00212 /// Fixed a bug in the test module hudcontrols.cpp that
00213 /// painted hud controls with thickness 1 regardless of
00214 /// zoom level.
00215 ///
00216 /// Revision 1.27  2003/11/25 13:01:03  botik
00217 /// Changed the flawed way scene node's requests were
00218 /// handled in ZoomableSurfaceView. This fixes a bad bug
00219 /// with HUD nodes moving all over the place.
00220 /// Added CameraZoomedMessage and CameraScrolledMessage
00221 /// Replaced the TranslateNodeMEssage with
00222 /// CameraScrolledMessage in HUDGroupNode. This fixed
00223 /// a HUD flicker bug.
00224 /// Simplified repaint and clear handling in GraphWindow.
00225 /// This fixed a few bugs in repainting.
00226 /// Added rect bounds checking in ScrollableView's
00227 /// clear_rect and repaint_rect. This fixed cameras to only
00228 /// clear their rectangle even if the view holds a larger
00229 /// area.
00230 /// Changed ActiveLeaf to use default paint function if
00231 /// the payload of CameraRepaintLeafMessage is empty. This
00232 /// will allow repaints of moved nodes.
00233 /// Changed LayerNode to allow CameraMovement events even
00234 /// if the layer is inactive. This will update existing HUD
00235 /// controls' position on inactive layers so they do not move
00236 /// astray during scrolls.
00237 /// This is an intermediate change; mouseover checks do not work.
00238 ///
00239 /// Revision 1.26  2003/11/24 20:45:29  botik
00240 /// Merged four features from surfacecamera into camera.
00241 /// Modified ScrollableView to hold a width/height of
00242 /// the viewport and to report it to whoever asks.
00243 /// Added scenex, sceney fields to Event.
00244 /// Added coordinate transform for all messages, done
00245 /// at camera level. This should speed up drawability
00246 /// and mouseover checks.
00247 ///
00248 /// Repaint and mouse detection work now over arbitrary
00249 /// magnification.
00250 /// Borderlayer is broken and scrolling segfaults in
00251 /// a weird way.
00252 ///
00253 /// Revision 1.25  2003/11/20 18:40:48  botik
00254 /// Got borderlayer to work satisfactory.
00255 /// Changed xpsdl driver to check bounds
00256 /// on rect update and clear
00257 ///
00258 /// Revision 1.24  2003/11/20 00:32:41  botik
00259 /// Changed the way repaint works by using a screen
00260 /// rectangle as intermediate event.
00261 /// Added get_screenrect to Camera
00262 /// Added screen2scenerect to Camera
00263 ///
00264 /// Revision 1.23  2003/11/18 17:47:20  botik
00265 /// Added triangle fill function to surface driver
00266 /// and views
00267 ///
00268 /// Revision 1.22  2003/11/18 13:54:06  botik
00269 /// Got the borderlayer to scroll well.
00270 ///
00271 /// Revision 1.21  2003/11/17 23:38:45  botik
00272 /// Fixed the framework to work with multiple cameras on
00273 /// one window. There is a clear bug that does not clear
00274 /// the upper camera.
00275 /// Changed scrolling to remove flicker when multiple
00276 /// cameras are present on a window.
00277 /// Scrolling is still slow.
00278 ///
00279 /// Revision 1.20  2003/11/17 18:39:37  botik
00280 /// Added rectangle to surface driver.
00281 /// Sdxpsdl line and rectangle bugfixes
00282 ///
00283 /// Revision 1.19  2003/11/17 13:46:34  botik
00284 /// Removed default cursor from scrollableview
00285 /// Changed message handling behaviour for GroupNode
00286 ///     to recognize broadcast messages
00287 /// Changed message handling behaviour for BaseSceneNode
00288 ///     to recognize broadcast messages
00289 /// Added NodeTranslateMessage to message module
00290 /// Added handling of NodeTranslateMessage for LeafNode
00291 ///
00292 /// Revision 1.18  2003/11/15 16:45:18  botik
00293 /// Added ActiveLeaf node allowing for much easier scene
00294 /// node creation.
00295 /// Added default_cursor to scrollableview.
00296 /// Numerous bugfixes.
00297 /// MouseIn/Out now changes cursor.
00298 ///
00299 /// Revision 1.17  2003/11/14 16:14:55  botik
00300 /// Fixed circle magnification bug
00301 ///
00302 /// Revision 1.16  2003/11/13 18:50:18  botik
00303 /// Fixed (almost) clear and update rect behaviour.
00304 /// Added update_rect to framework and sdl wrapper.
00305 /// Added mouse_in/mouse_out handling
00306 /// Fixed message handling
00307 /// Many small bugfixes
00308 ///
00309 /// Revision 1.15  2003/11/13 12:50:51  botik
00310 /// Refined the event handling architecture
00311 /// Got the event handling to recognize and treat mouse
00312 /// events accordingly
00313 /// Important fixes to ./Makefile
00314 ///
00315 /// Revision 1.14  2003/11/12 18:14:25  botik
00316 /// Got the framework to check scene nodes for viewport fit
00317 /// before painting.
00318 ///
00319 /// Revision 1.13  2003/11/12 12:04:27  botik
00320 /// Further refinements of contrib/borderlayer,
00321 /// added inner event generation to view and surface
00322 /// classes,
00323 /// a few minor bugfixes
00324 ///
00325 /// Revision 1.12  2003/11/12 00:47:31  botik
00326 /// Further work on getting repaints to work, tested with
00327 /// scrolling
00328 ///
00329 /// Revision 1.11  2003/11/11 23:18:31  botik
00330 /// Got sdlxp driver to work, fixed a few architecture
00331 /// errors and some bugs
00332 ///
00333 /// Revision 1.10  2003/11/11 15:30:58  botik
00334 /// Added and compiled second framework test,
00335 /// fixed along a few bugs.
00336 ///
00337 /// Revision 1.9  2003/11/09 18:05:37  botik
00338 /// Contrib/borderlayer works! Fixed a lot of small bugs.
00339 ///
00340 /// Revision 1.8  2003/11/09 15:23:01  botik
00341 /// Got GraphDisplay to compile and run.
00342 ///
00343 /// Revision 1.7  2003/11/08 23:45:54  botik
00344 /// Got the framework to compile, in order to do that
00345 /// filled in some functions and added some empty
00346 /// ones as well.
00347 ///
00348 /// Revision 1.6  2003/11/04 14:59:40  botik
00349 /// Further refined the event handling. This is
00350 /// related to the SDL event driver addition
00351 ///
00352 /// Revision 1.5  2003/10/28 15:43:55  botik
00353 /// More work on event framework and camera composition and
00354 /// z-ordering
00355 ///
00356 /// Revision 1.4  2003/10/21 17:39:00  botik
00357 /// Added preliminary scene support
00358 ///
00359 /// Revision 1.3  2003/10/15 11:58:05  botik
00360 /// With the addition of object display, graphdisplay has been
00361 /// modified. ObjectDisplay's interface has been coded. Some
00362 /// changes to scrollable view have been introduced that relate
00363 /// to the changes above.
00364 ///
00365 /// Revision 1.2  2003/10/13 16:46:39  botik
00366 /// Added Log keyword to end.
00367 /// Modified scrollableview.cpp to translate the parameters
00368 /// correctly for most functions.
00369 ///

Generated on Wed Jun 23 18:47:21 2004 for cZUI by doxygen 1.3.5