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

surfacedriver.h

Go to the documentation of this file.
00001 //--- < SURFACEDRIVER.H > -------| ViewGraph - A Flexible Graph view Framework |
00002 //
00003 // Abstraction of a drawable surface which can 
00004 // use various lower-level libraries
00005 // 
00006 // You will also find a base cursor class that
00007 // can be used together with the surface library
00008 //
00009 // $Author: botik32 $
00010 // $Revision: 1.7 $
00011 // $Date: 2004/05/25 13:14:16 $
00012 //-----------------------------------------------------------------------------/
00013 
00014 
00015 #ifndef SURFACEDRIVER_H
00016 #define SURFACEDRIVER_H
00017 
00018 #include <cZUI/drivers/surfacecursor.h>
00019 #include <cZUI/drivers/mouse.h>
00020 #include <cZUI/drivers/image.h>
00021 
00022 class Event;
00023 
00024 typedef enum{ JUST_RIGHT, JUST_CENTER, JUST_LEFT } textjustify;
00025 
00026 class SurfaceDriver{
00027 protected:
00028         int wx, wy;
00029         unsigned char r, g, b;
00030         int thickness;
00031 public:
00032         void pen( unsigned char r, unsigned char g, unsigned char b, int thickness );
00033         void get_pen( unsigned char& r, unsigned char& g, unsigned char& b, int& thickness );
00034         virtual void penstyle( const char * )=0;
00035         virtual void line(      double x1, double y1, double x2, double y2 )=0;
00036         virtual void dot( double x1, double y1 )=0;
00037         virtual void rectangle( double x1, double y1, double x2, double y2 )=0;
00038         virtual void circle( double x1, double y1, int radius )=0;
00039         // Start angle is less than end angle; both are in radians
00040         virtual void arc( double xc, double yc, int radius, 
00041                 double an1, double an2 )=0;
00042         virtual void bezier( double x1, double y1, double x2, double y2, 
00043                                  double x3, double y3 )=0;
00044         virtual void fill_h_triangle( double x1, double y1, 
00045                                  double x2, double y2, double x3 )=0;
00046         virtual void fill_v_triangle( double x1, double y1, 
00047                                  double x2, double y2, double y3 )=0;
00048         virtual void fillrect( double x1, double y1, double x2, double y2,
00049                 unsigned char fr, unsigned char fg, unsigned char fb )=0;
00050         
00051 
00052         virtual void repaint( void )=0;
00053         virtual void clear( unsigned char, unsigned char, unsigned char )=0;
00054         virtual void clear_rect( int, int, int, int,
00055                 unsigned char, unsigned char, unsigned char)=0;
00056         virtual void repaint_rect( int, int, int, int )=0;
00057 
00058         virtual void textout( double x1, double y1, const char *text )=0;
00059         virtual void textrect( double x1, double y1, 
00060                         double x2, double y2, const char *text )=0;
00061         virtual void setfont( const char * )=0;
00062         virtual void setfontsize( int )=0;
00063         virtual void setjustification( textjustify )=0;
00064 
00065         /// This function returns true if the passed rectangle
00066         /// fits the surface. The default does a straight 
00067         /// rectangle fit check. Depending on implementation 
00068         /// details of your surface driver, you might want to
00069         /// change this function to return true if any overlap
00070         /// exists, or, like the Xp driver, use a safe bound area
00071         /// of x percent of the canvas.
00072         virtual bool rectfits( double, double, double, double );
00073 
00074         int get_w( void );
00075         int get_h( void );
00076 
00077         // Cursor functions
00078         virtual void setcursor( SurfaceCursor * )=0;
00079         virtual SurfaceCursor* getcursor( void )=0;
00080         virtual void showcursor( bool )=0;
00081 
00082         // this function returns the screen position
00083         // and cannot be used in embedded scenes.
00084         virtual void get_mousepos( int&, int& )=0;
00085         virtual msbutton get_mousestate( void )=0;
00086 
00087         // this function is probably obsolete
00088         virtual void enqueue_event( Event * )=0;
00089 
00090         virtual Image* load_image( const char* )=0;
00091         virtual void put_image( Image*, int destx, int desty, 
00092                 int imgx=0, int imgy=0, int wx=0, int wy=0 )=0;
00093         //virtual Image* create_image_from_pixels( void *pixels,
00094                 //int width, int height, int pitch )=0;
00095         virtual Image* create_scaled_image( Image*, double mgf )=0;
00096                                 
00097         // Views may take only part of the surface and will
00098         // request clipping
00099         virtual void set_cliprect( int, int, int w, int h )=0;
00100         virtual void clear_cliprect( void )=0;
00101         SurfaceDriver( int, int );
00102 };
00103 
00104 #endif
00105 
00106 /// $Log: surfacedriver.h,v $
00107 /// Revision 1.7  2004/05/25 13:14:16  botik32
00108 /// Many bugfixes, including fix for no draw at load.
00109 /// Many fixes for ANSI compatibility (e.g. windows)
00110 ///
00111 /// Revision 1.6  2004/05/03 21:02:01  botik32
00112 /// Significant changes and many bugfixes.
00113 /// ScrollableView now has a background color used to
00114 /// tell SurfaceDriver to clear with.
00115 /// SurfaceDriver's clear() requires a color now
00116 /// Added SceneEvents for all node additions/removals
00117 /// in GroupNode and Camera.
00118 /// Added paint_selected and paint_selected_invalid
00119 /// to ActiveLeaf
00120 /// Modified ActiveLeaf's mouse_down and mouse_up
00121 /// handler signatures to accept an Event* instead of
00122 /// Camera*
00123 /// - Many more bugfixes
00124 ///
00125 /// Revision 1.5  2004/04/29 09:50:48  botik32
00126 /// Fixed the zoomablesurfaceview's put_image to work
00127 /// correctly with zooms.
00128 /// Moved convert_image_to16() from SurfaceDriver to Image. It
00129 /// is now called convert_to_565()
00130 /// Fixed bug in rgb24.cpp including rgb24.h in the wrong location
00131 /// Finished code zoom in ZoomableSurfaceView, not tested
00132 ///
00133 /// Revision 1.4  2004/04/28 09:21:25  botik32
00134 /// Major interface change in drivers:
00135 ///   - Added convert_image_to16() to SurfaceDriver
00136 ///   - Added get_bpp to Image
00137 ///
00138 /// Revision 1.3  2004/04/15 10:31:29  botik32
00139 /// Interface change: added arc() function to surfacedriver.
00140 ///
00141 /// Revision 1.2  2004/04/09 17:15:08  botik32
00142 /// Changes in interface: added get_pen to scrollableview and
00143 /// surfacedriver
00144 ///
00145 /// Revision 1.1.1.1  2004/03/26 10:50:27  botik32
00146 /// Initial release
00147 ///
00148 /// Revision 1.1.1.1  2004/03/26 08:53:33  botik
00149 /// initial import
00150 ///
00151 ///
00152 /// Revision 1.18  2004/03/17 09:56:38  botik
00153 /// Demo now shows camera in the small window
00154 /// ScrollableView: added clear_surface() and update_surface()
00155 ///   functions
00156 /// GraphWindow: calls clear_surface() and update_surface() on update.
00157 ///
00158 /// Revision 1.17  2004/01/03 19:59:41  botik
00159 /// added text support via aedGUI
00160 ///
00161 /// Revision 1.16  2003/12/12 11:32:33  botik
00162 /// Added drivers/mouse.h
00163 /// Moved msbutton definition to drivers/mouse.h
00164 /// Added get_mousestate to SurfaceDriver
00165 /// Added get_mousestate to ScrollableView
00166 /// Changed the zoom decorator to only receive events if
00167 /// the left mouse is pressed
00168 /// Moved scroll layer beneath the zoom decorator layer
00169 /// This hopefully fixes a segfault when zoomdecorator gets
00170 /// invalid position after scroll
00171 ///
00172 /// Revision 1.15  2003/12/04 01:02:14  botik
00173 /// Added Image class to framework
00174 /// Added SDLImage class to drivers/sdxpsdl
00175 /// Added load_image to surfacedriver class
00176 /// Added put_image to surfacedriver class
00177 /// Added load_image and put_image to scrollableview class
00178 ///
00179 /// Revision 1.14  2003/11/18 17:47:20  botik
00180 /// Added triangle fill function to surface driver
00181 /// and views
00182 ///
00183 /// Revision 1.13  2003/11/18 13:54:06  botik
00184 /// Got the borderlayer to scroll well.
00185 ///
00186 /// Revision 1.12  2003/11/17 18:39:37  botik
00187 /// Added rectangle to surface driver.
00188 /// Sdxpsdl line and rectangle bugfixes
00189 ///
00190 /// Revision 1.11  2003/11/13 18:50:18  botik
00191 /// Fixed (almost) clear and update rect behaviour.
00192 /// Added update_rect to framework and sdl wrapper.
00193 /// Added mouse_in/mouse_out handling
00194 /// Fixed message handling
00195 /// Many small bugfixes
00196 ///
00197 /// Revision 1.10  2003/11/13 12:50:51  botik
00198 /// Refined the event handling architecture
00199 /// Got the event handling to recognize and treat mouse
00200 /// events accordingly
00201 /// Important fixes to ./Makefile
00202 ///
00203 /// Revision 1.9  2003/11/12 12:04:27  botik
00204 /// Further refinements of contrib/borderlayer,
00205 /// added inner event generation to view and surface
00206 /// classes,
00207 /// a few minor bugfixes
00208 ///
00209 /// Revision 1.8  2003/11/12 00:47:31  botik
00210 /// Further work on getting repaints to work, tested with
00211 /// scrolling
00212 ///
00213 /// Revision 1.7  2003/11/11 23:18:31  botik
00214 /// Got sdlxp driver to work, fixed a few architecture
00215 /// errors and some bugs
00216 ///
00217 /// Revision 1.6  2003/11/09 15:23:01  botik
00218 /// Got GraphDisplay to compile and run.
00219 ///
00220 /// Revision 1.5  2003/11/08 23:45:54  botik
00221 /// Got the framework to compile, in order to do that
00222 /// filled in some functions and added some empty
00223 /// ones as well.
00224 ///
00225 /// Revision 1.4  2003/11/07 17:51:32  botik
00226 /// Added cursor support to surfacedriver.
00227 /// SetCursor does not work yet but should be
00228 /// piece of cake
00229 ///
00230 /// Revision 1.3  2003/10/15 11:56:19  botik
00231 /// Added a new function called rectfits() that will
00232 /// check if a given rectangle fits the canvas. This
00233 /// function should be used to decide whether to draw
00234 /// an object or not.
00235 ///
00236 /// Revision 1.2  2003/10/13 16:49:42  botik
00237 /// Minor CVS-related changes such as adding the Log keyword
00238 ///
00239 /// Revision 1.1  2003/10/13 16:36:04  botik
00240 /// Recovered from changes onto an exported version. Added display_framework
00241 /// directory and changed some files in graph_display (namely those related
00242 /// to the canvas)
00243 ///
00244 
00245 

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