22 #include "wx/editor/candoc.h" 
   44     wxASSERT_MSG( 
m_streami , wxT( 
"m_stream not set" ) );
 
   46     wxImageHandler* handlerfound = NULL;
 
   47     wxList::compatibility_iterator node = wxImage::GetHandlers().GetFirst();
 
   51         wxImageHandler* handler = ( wxImageHandler* )node->GetData();
 
   52 #if wxUSE_STD_IOSTREAM 
   55         const int BUFFSIZE = 3000080;
 
   58         while( len = Read( buf,  BUFFSIZE ) )
 
   59             mem.AppendData( buf, len );
 
   61         wxMemoryInputStream localStream( mem.GetData(), mem.GetDataLen() );
 
   63         if ( handler->CanRead( localStream ) )
 
   68             handlerfound = handler;
 
   71         node = node->GetNext();
 
   75         return ( wxBitmapType ) handlerfound->GetType();
 
   76     return wxBITMAP_TYPE_ANY;
 
   89     wxImageHandler* handlerfound = NULL;
 
   90     if ( 
m_type == wxBITMAP_TYPE_ANY )
 
   94         if ( type == wxBITMAP_TYPE_ANY )
 
  103         if ( !wxImage::FindHandler( 
m_type ) )
 
  118     wxImageHandler* handler = NULL;
 
  119     if ( 
m_type == wxBITMAP_TYPE_ANY )
 
  122         if ( type == wxBITMAP_TYPE_ANY )
 
  124         handler = wxImage::FindHandler( type );
 
  127         handler = wxImage::FindHandler( 
m_type );
 
  138 #if !wxUSE_STD_IOSTREAM 
  139         if ( handler->LoadFile( &image, stream ) )
 
  141             a2dImage* canvas_image = 
new a2dImage( image, 0, 0, image.GetWidth() * m_scale, image.GetHeight() * m_scale ); 
 
  147                 m_showObject->
Append( canvas_image );
 
  154         const int BUFFSIZE = 3000080;
 
  157         while( len = Read( buf,  BUFFSIZE ) )
 
  158             mem.AppendData( buf, len );
 
  160         wxMemoryInputStream localStream( mem.GetData(), mem.GetDataLen() );
 
  161         if ( handler->LoadFile( &image, localStream ) )        
 
  163             a2dImage* canvas_image = 
new a2dImage( image, 0, 0, image.GetWidth() * m_scale, image.GetHeight() * m_scale ); 
 
  169                 m_showObject->
Append( canvas_image );
 
  201         wxASSERT_MSG( 
m_border >= 0 && 
m_border <= 100 , wxT( 
"percentage must be >=0 and <= 100" ) );
 
  214     m_maxWidthHeight = 1000;
 
  238     wxImageHandler* handler = NULL;
 
  239     handler = wxImage::FindHandler( 
m_type );
 
  263 #if wxUSE_STD_IOSTREAM 
  264         wxMemoryOutputStream streamimage;
 
  268         const int BUFFSIZE = 100;
 
  271         streamimage.SeekO(0);
 
  272         wxStreamBuffer* theBuffer = streamimage.GetOutputStreamBuffer();
 
  273         while ( theBuffer->Read( (
void*) buf, BUFFSIZE ) > 0 )
 
  278 #else //wxUSE_STD_IOSTREAM 
  279         res = image.SaveFile( *
m_streamo, m_type );
 
  280 #endif //wxUSE_STD_IOSTREAM 
  325         m_maxWidthHeight = wxGetNumberFromUser( _( 
"Give Maximum pixel size in width and height:" ), _( 
"Pixels:" ), _( 
"Pixel" ), m_maxWidthHeight, 0, 50000 );
 
  329         xpp = w / m_maxWidthHeight;
 
  330         ypp = h / m_maxWidthHeight;
 
  348         border = ( int ) ( wxMin( clientw, clienth ) * 
m_border / 100.0 ) ;
 
  350     if ( clientw - border > 0 )
 
  351         clientw = clientw - border;
 
  353     if ( clienth - border > 0 )
 
  354         clienth = clienth - border;
 
  363     virt_minX = middlexworld - ( clientw + border ) / 2.0 * uppx;
 
  364     virt_minY = middleyworld - ( clienth + border ) / 2.0 * uppx;
 
void SetMappingUpp(double vx1, double vy1, double xpp, double ypp)
Give the virtual size to be displayed, the mapping matrix will be calculated. 
virtual void SetYaxis(bool up)
set if the Yaxis goes up or down 
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown. 
double GetHeight() const 
returns height of the boundingbox 
wxBitmapType m_type
image type 
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types. 
wxSize m_imageSizeCalc
calculate image size as set by user when m_imageSize = (0,0) else eqauls m_imageSize ...
virtual void InitializeLoad()
Inits the handler for reading. 
const a2dAffineMatrix & GetTransformMatrix() const 
get the matrix used to position the object 
virtual void InitializeSave()
Inits the handler for writing. 
virtual void ResetSave()
Reset the object after saving. 
a2dCanvasObject * GetRootObject() const 
get the root object, which holds the objects in the document 
wxBitmapType DetectImageType()
for the stream, detect what image type it contains 
bool CanSave(const wxObject *obj=NULL)
this handler can also save as CVG 
wxSize m_imageSize
image size that will be created. 
void SetMappingDeviceRect(int mapx, int mapy, int mapWidth, int mapHeight, bool remap=false)
to change the default mapping (to the complete buffer). 
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams 
a2dDocumentInputStream * m_streami
file or other string stream containing the format to parse. 
a2dCanvasDocumentIOHandlerImageOut(wxBitmapType type=wxBITMAP_TYPE_ANY)
Constructor. 
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate 
This class implements drawing functions for wxDC based drawing. 
a2dDrawing * GetDrawing() const 
get the root object, which holds the objects in the document. 
void SetBorder(wxUint16 border, bool percentual=true)
leafs a border of this amount of pixels around the drawing 
a2dBoundingBox m_viewBox
viewing area in world coordinates to display on bitmap 
a2dIOHandlerStrIn & SeekI(wxFileOffset pos)
set stream at a position 
a2dDrawer2D * m_drawer2D
the drawing engine to use 
a2dCanvasDocument * m_doc
the document to store/load the data found into 
virtual bool Load(a2dDocumentInputStream &stream, wxObject *doc)
load a complete document which contains an image 
bool GetValid() const 
returns true if boundingbox is calculated properly and therefore its valid flag is set...
double GetMinX() const 
get minimum X of the boundingbox 
a2dCanvasDocument * m_doc
the document to store/load the data found into 
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *obj)
save a2dCanvasDocument as image 
wxBitmapType m_type
image type 
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice. 
Drawing context abstraction. 
a2dImage (will scale/rotate image when needed) 
~a2dCanvasDocumentIOHandlerImageIn()
Destructor. 
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes. 
void SetShowObjectAndRender(a2dCanvasObject *obj)
Used temporarely in rendering bitmas or in printing, to Set the show object and redraw the whole part...
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
test header of the file to see if it can be loaded 
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document 
void SetDrawer2D(a2dDrawer2D *drawer2d)
set the internal m_drawer2D to be used for rendering the document 
A 2x3 affine matrix class for 2D transformations. 
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically. 
wxInputStream a2dDocumentInputStream
input stream based wxStreams 
a2dCanvasDocumentIOHandlerImageIn(wxBitmapType type=wxBITMAP_TYPE_ANY)
Constructor. 
void MapBbox(const a2dAffineMatrix &matrix)
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke. 
virtual wxBitmap GetBuffer() const =0
Return the buffer as a bitmap. 
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
double GetWidth() const 
returns width of the boundingbox 
const a2dStroke * a2dTRANSPARENT_STROKE
global a2dStroke stock object for TRANSPARENT stroking 
wxImage RenderImage(a2dCanvasDocument *document)
render the document into an image. 
const a2dError a2dError_NotSpecified
bool m_borderpercentual
border is not in pixel but a percentage of the smallest height/width 
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject. 
bool Invert(void)
Invert matrix. 
double GetMinY() const 
get minimum Y of the boundingbox 
virtual void SetBufferSize(int w, int h)=0
Change the buffer size. 
void SetDrawer2D(a2dDrawer2D *drawer2d, bool noDelete=false)
set the internal m_drawer2D to be used for rendering the document 
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects 
int m_border
create a border in this ammount of pixels. 
a2dCanvasObject * m_showObject
render the document using this object as ShowObject. 
wxBitmapType m_typeDetectedFromFilename
image type as detected in CanSave(), wil be used in Save() if m_type is wxBITMAP_TYPE_ANY ...
~a2dCanvasDocumentIOHandlerImageOut()
Destructor. 
a2dDocumentOutputStream * m_streamo
file or other string stream containing the format to output to. 
virtual void ResetLoad()
Reset the handler after loading. 
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill. 
bool m_yaxis
axis is up or down 
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling 
void SetViewRectangle(double minx, double miny, double maxx, double maxy)
Give the virtual size to be rendered to an image.