19 #ifndef __A2DCANVAS_H__
20 #define __A2DCANVAS_H__
27 #include "wx/geometry.h"
91 a2dCanvas( wxWindow* parent, wxWindowID
id = -1,
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = wxScrolledWindowStyle,
a2dDrawer2D* drawer2D = 0 );
110 const wxPoint& pos = wxDefaultPosition,
111 const wxSize& size = wxDefaultSize,
112 long style = wxScrolledWindowStyle );
138 void ClearBackground();
144 virtual void Refresh(
bool eraseBackground =
true,
const wxRect* rect = NULL );
147 void SetBackgroundFill(
const a2dFill& backgroundfill );
150 void SetGridAtFront(
bool gridatfront ) { m_drawingPart->SetGridAtFront( gridatfront ); }
159 void SetGridSize( wxUint16 gridsize ) { m_drawingPart->SetGridSize( gridsize ); }
165 double GetGridX() {
return m_drawingPart->GetGridX(); }
168 void SetGridX(
double gridx ) { m_drawingPart->SetGridX( gridx ); }
171 double GetGridY() {
return m_drawingPart->GetGridY(); }
174 void SetGridY(
double gridy ) { m_drawingPart->SetGridY( gridy ); }
177 void SetGrid(
bool grid ) { m_drawingPart->SetGrid( grid ); }
180 bool GetGrid() {
return m_drawingPart->GetGrid(); }
184 void SetGridLines(
bool gridlines ) { m_drawingPart->SetGridLines( gridlines ); }
193 void SetYaxis(
bool up );
196 bool GetYaxis()
const;
219 void AppendEventHandler( wxEvtHandler* handler );
222 wxEvtHandler* RemoveLastEventHandler(
bool deleteHandler );
261 void SetMappingWidthHeight(
double vx1,
double vy1,
double width,
double height,
bool scrollbars );
267 void SetMappingShowAll(
bool centre =
true );
270 void ZoomOut(
double n );
273 void ZoomOutAtXy(
int x,
int y,
double n );
301 void SetMappingUpp(
double vx1,
double vy1,
double xpp,
double ypp );
312 void SetScrollbars(
double pixelsPerUnitX,
double pixelsPerUnitY,
313 double noUnitsX,
double noUnitsY,
314 double xPos = 0,
double yPos = 0 );
317 double GetVisibleMinX()
const;
319 double GetVisibleMinY()
const;
321 double GetVisibleMaxX()
const;
323 double GetVisibleMaxY()
const;
325 double GetVisibleWidth()
const;
327 double GetVisibleHeight()
const;
330 double GetUppX()
const;
333 double GetUppY()
const;
341 bool ScrollWindowConstrained(
double dx,
double dy );
350 bool SetScrollMaximum(
double vx1,
double vy1,
double vx2,
double vy2 );
353 void SetMinX(
double vxmin );
355 void SetMinY(
double vymin );
371 void SetScrollStepX(
double x );
378 void SetScrollStepY(
double y );
384 void SetScrollBarsVisible(
bool onoff );
402 bool CheckInsideScrollMaximum(
double worldminx,
double worldminy );
434 int layer = wxLAYER_ALL,
439 void SetMouseEvents(
bool onoff );
442 bool GetMouseEvents();
445 bool WriteSVG(
const wxString& filename,
double Width,
double Height, wxString unit );
447 bool ProcessEvent( wxEvent& event );
453 bool MakeVirtualMaxFitVisibleArea();
459 void GetSaveClientSize(
int* dvx,
int* dvy )
const;
464 void OnActivate( wxActivateEvent& event );
467 void OnPaint( wxPaintEvent& event );
470 void OnSize( wxSizeEvent& event );
473 void OnWheel( wxMouseEvent& event );
476 void OnEraseBackground( wxEraseEvent& event );
479 void OnScroll( wxScrollWinEvent& event );
482 void OnChar( wxKeyEvent& event );
485 void DeleteAllPendingAreas();
504 bool CheckInsideScrollMaximum(
int dx,
int dy );
506 void Init(
int dvx,
int dvy );
563 int m_oldw, m_oldh, m_prevh, m_prevw, m_prevClientW, m_prevClientH;
595 DECLARE_EVENT_TABLE()
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
double GetScrollMinX() const
get the minimum scroll X in world coordinates that can be scrolled to
void SetShowOrigin(bool show)
Set showorigin on/off.
int m_oldw
to optimize onsize events
int m_normalize
used to normalize scroll thumb and range
Base class for all types of strokes, understood by a2dDrawer2D classes.
void SetGridSize(wxUint16 gridsize)
set size of grid circle
bool m_aboveScrolledFixedAdjustUpp
when because resizing or setting maximum scrollable area, it becomes smaller then the visible area...
bool GetGrid()
Get grid setting on/off.
bool m_ContinuesSizeUpdate
at small resize also update the buffer directly.
bool m_has_x_scroll
flag if there is a horizontal scrollbar
bool GetContinuesSizeUpdate()
get current setting for ContinuesSizeUpdate flag
int m_delta
oversize of buffer compared to screen width and height
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the canvas.
double GetScrollMaxX() const
get the maximum scroll X in world coordinates that can be scrolled to
The base class for all drawable objects in a a2dCanvasDocument.
int m_thumbx
current thumbsize of X scrollbar which gets always adjusted by the m_scrollstepx
a2dCanvasObject is the base class for Canvas Objects.
int m_oversizeX
in future the offset from window to drawer in X
bool m_scrolled
are scroll bars active?
void FixScrollMaximum(bool fixed)
at all times the virtual displayed area will stay within the maximum scrollable area ...
bool m_frozen
prevent updating activity if true
int m_oversizeY
in future the offset from window to drawer in Y
bool m_yscroll_changed
a flag for ignoring size events when scrollbars change
void SetGridY(double gridy)
Set grid distance in Y.
bool m_xscroll_changed
a flag for ignoring size events when scrollbars change
void SetGridFill(const a2dFill &gridfill)
set brush used for grid drawing
bool GetScaleOnResize()
get current setting for ScaleOnResize
void SetGridX(double gridx)
Set grid distance in X.
a2dHitOption
Enum for hit test options.
bounding class for optimizing drawing speed.
Drawing context abstraction.
void SetScrollTrackDraw(bool scrollTrackDraw)
if set, when dragging scrollbar handles, do a redraw, esle only at release.
double GetScrollMaxY() const
get the maximum scroll Y in world coordinates that can be scrolled to
void SetGrid(bool grid)
Set grid on/off.
double GetGridX()
Get grid distance in X.
double m_virtm_minX
virtual coordinates of total scrollable area for the drawing, used to set scrollbars ...
int m_thumby
current thumbsize of Y scrollbar which gets always adjusted by the m_scrollstepy
void SetContinuesSizeUpdate(bool val)
set if the drawing should be rescaled on a window resize
if set, respect layer order, hit testing is done per layer from the top.
bool m_wantScroll
set true by wxWindow style parameter wxVSCROLL | wxHSCROLL
void SetScaleOnResize(bool val)
set if the drawing should be resclaed on a window resize
bool GetScrollTrackDraw() const
if set, when dragging scrollbar handles, do a redraw, esle only at release.
void SetGridAtFront(bool gridatfront)
Set grid setting for drawing grid in front or back.
bool m_scrollTrackDraw
redraw at drag fo scrollbars
double m_scrollstepy
step for Y line up and down in world coordinates
bool m_clipToScrollMax
see ClipToScrollMaximum()
void SetGridStroke(const a2dStroke &gridstroke)
set stroke used for grid drawing
double GetGridY()
Get grid distance in Y.
if set, don't hit test the root object or object for which IsHitWorld is called
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object...
double GetScrollMinY() const
get the minimum scroll Y in world coordinates that can be scrolled to
bool GetGridAtFront()
Get grid setting for drawing grid in front or back.
int m_scrollrangex
Total range of X scroll bar, which gets always adjusted by the m_scrollstepx.
bool IsFrozen()
Returns if canvas is frozen.
bool GetGridLines()
set grid to draw lines instead of points
a2dDrawingPtr m_drawing
set if the canvas own the drawing
void ClipToScrollMaximum(bool clip)
when scrolling outside the maximum scroll region and
bool m_has_y_scroll
flag if there is a vertical scrollbar
bool m_inSetScrollMaximum
prevent SetScrollMaximum beeing called recursively
a2dDrawer2D * GetDrawer2D() const
Get the drawer of the view.
int m_scrollrangey
Total range of Y scroll bar, which gets always adjusted by the m_scrollstepy.
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
bool m_scrollmaxfixed
stay within maximum scrollable area
double m_scrollstepx
step for X line up and down in world coordinates
void SetGridLines(bool gridlines)
Get grid setting for line drawing.
Contain one drawing as hierarchical tree of a2dCanvasObject's.
bool m_scaleonresize
are scroll bars active?