Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

CSurface Class Reference

#include <cvideo.h>

Inheritance diagram for CSurface:

Inheritance graph
[legend]
Collaboration diagram for CSurface:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CSurface (int w, int h)
 CSurface (const char *filename)
 CSurface (CSurface &copy)
 ~CSurface ()
CSurfaceoperator= (CSurface &cs)
void set_transparent_color (CColor color)
void blit (CSurface &source)
void blit (CSurface &source, CPoint &dest_pos)
void blit (CSurface &source, CPoint &dest_pos, CRect &src_rect)
void fill_rect (const CRect &rect, CColor color)
void set_clipping_rect (CRect &rect)
void clear_clipping_rect ()
int get_depth ()
int get_width ()
int get_height ()
CPoint get_size ()

Protected Member Functions

void attach (CSurface &cs)
void detach ()

Protected Attributes

CSurfaceImplimpl

Detailed Description

The CSurface object is an abstraction of a bitmap surface; the interface end of a bridge pattern. Note that its constructors call factory methods on the video system manager to get concrete CSurfaceImpl implementations of the actual surface.

Being the interface end of a bridge pattern, it makes sense that this class should be used as a higher-level abstraction for the implementation; currently, the only thing "higher-level" about this is the garbage collection used by the attach/detach methods, but other higher-level abstractions could be added later.

Note also that since this class has no virtual methods, it literally only contains the pointer of the CSurfaceImpl it points to; as such, it's extremely portable. When assigning to/from a CSurface, use value assignment instead of reference assignment, as this will use the overloaded '=' operator and change the reference counts of the surfaces involved, making sure that the physical surfaces get deleted when they need to. It will also make your code less vulnerable to dangling pointers.

Definition at line 310 of file cvideo.h.


Constructor & Destructor Documentation

CSurface::CSurface int  w,
int  h
[inline]
 

Create a new surface with the given width and height. This method actually just calls the make_csurface_impl() factory method on the CVideoSystem singleton to get its CSurfaceImpl object.

Definition at line 340 of file cvideo.h.

References CSingletonManager< CVideoSystem >::get_instance(), impl, and CVideoSystem::make_csurface_impl().

Here is the call graph for this function:

CSurface::CSurface const char *  filename  )  [inline]
 

Create a new surface from the given graphics filename (usually a Windows BMP file). This method actually just calls the make_csurface_impl() factory method on the CVideoSystem singleton to get its CSurfaceImpl object.

Definition at line 346 of file cvideo.h.

References CSingletonManager< CVideoSystem >::get_instance(), impl, and CVideoSystem::make_csurface_impl().

Here is the call graph for this function:

CSurface::CSurface CSurface copy  )  [inline]
 

The copy constructor. Note that this doesn't actually make a copy of the surface--it just increases the CSurfaceImpl's reference count so it knows there's another CSurface pointing at its physical bitmap.

Definition at line 352 of file cvideo.h.

References attach().

Here is the call graph for this function:

CSurface::~CSurface  )  [inline]
 

The destructor.

Definition at line 355 of file cvideo.h.

References detach().

Here is the call graph for this function:


Member Function Documentation

void CSurface::attach CSurface cs  )  [inline, protected]
 

Attaches this surface to the given surface. Used when a CSurface is assigned to another CSurface, etc...

Definition at line 317 of file cvideo.h.

References impl, and CSurfaceImpl::inc_ref_count().

Here is the call graph for this function:

void CSurface::blit CSurface source,
CPoint dest_pos,
CRect src_rect
[inline]
 

Surface-blitting function. See CSurfaceImpl for documentation.

Definition at line 378 of file cvideo.h.

References CSurfaceImpl::blit(), and impl.

Here is the call graph for this function:

void CSurface::blit CSurface source,
CPoint dest_pos
[inline]
 

Surface-blitting function. See CSurfaceImpl for documentation.

Definition at line 375 of file cvideo.h.

References CSurfaceImpl::blit(), and impl.

Here is the call graph for this function:

void CSurface::blit CSurface source  )  [inline]
 

Surface-blitting function. See CSurfaceImpl for documentation.

Definition at line 372 of file cvideo.h.

References CSurfaceImpl::blit(), and impl.

Here is the call graph for this function:

void CSurface::clear_clipping_rect  )  [inline]
 

Clear the clipping rectangle for the surface.

Definition at line 387 of file cvideo.h.

References CSurfaceImpl::clear_clipping_rect(), and impl.

Here is the call graph for this function:

void CSurface::detach  )  [inline, protected]
 

Detaches this surface from its implementation (the "real" physical surface). Used when a CSurface is destroyed or assigned to a different surface than the one it's already assigned to, etc...

Definition at line 325 of file cvideo.h.

References CSurfaceImpl::dec_ref_count(), impl, and CSurfaceImpl::is_empty().

Here is the call graph for this function:

void CSurface::fill_rect const CRect rect,
CColor  color
[inline]
 

Draw a filled rectangle on the surface.

Definition at line 381 of file cvideo.h.

References CSurfaceImpl::fill_rect(), and impl.

Here is the call graph for this function:

int CSurface::get_depth  )  [inline]
 

See CSurfaceImpl documentation.

Definition at line 390 of file cvideo.h.

References CSurfaceImpl::get_depth(), and impl.

Here is the call graph for this function:

int CSurface::get_height  )  [inline]
 

See CSurfaceImpl documentation.

Definition at line 396 of file cvideo.h.

References CSurfaceImpl::get_height(), and impl.

Here is the call graph for this function:

CPoint CSurface::get_size  )  [inline]
 

Convenience method that returns the size of the surface as a CPoint where the x coordinate is the width and the y coordinate is the height of the surface.

Definition at line 401 of file cvideo.h.

References get_height(), and get_width().

Here is the call graph for this function:

int CSurface::get_width  )  [inline]
 

See CSurfaceImpl documentation.

Definition at line 393 of file cvideo.h.

References CSurfaceImpl::get_width(), and impl.

Here is the call graph for this function:

CSurface& CSurface::operator= CSurface cs  )  [inline]
 

Overloaded '=' operator. Detaches from the current CSurfaceImpl being pointed to, and attaches to the new one, changing reference counts as appropriate.

Definition at line 360 of file cvideo.h.

References attach(), and detach().

Here is the call graph for this function:

void CSurface::set_clipping_rect CRect rect  )  [inline]
 

Set the clipping rectangle for the surface.

Definition at line 384 of file cvideo.h.

References impl, and CSurfaceImpl::set_clipping_rect().

Here is the call graph for this function:

void CSurface::set_transparent_color CColor  color  )  [inline]
 

Set the transparent color of the surface.

Definition at line 369 of file cvideo.h.

References impl, and CSurfaceImpl::set_transparent_color().

Here is the call graph for this function:


Member Data Documentation

CSurfaceImpl* CSurface::impl [protected]
 

Our implementation.

Definition at line 313 of file cvideo.h.


The documentation for this class was generated from the following file:
Generated on Wed Aug 27 11:59:23 2003 for GFW by doxygen 1.3.3