128 #ifndef WXCHARTDIR_WXCHARTVIEWER_H
129 #define WXCHARTDIR_WXCHARTVIEWER_H
134 #include "wxchartviewer_defs.h"
135 #include "wxchartviewer_version.h"
137 #include <wx/bitmap.h>
138 #include <wx/event.h>
139 #include <wx/panel.h>
140 #include <wx/timer.h>
141 #include <wx/graphics.h>
142 #include <wx/overlay.h>
143 #include <wx/popupwin.h>
145 #include "chartdir.h"
148 namespace CD_NAMESPACE
157 MouseUsageDefault = 0,
158 MouseUsageScroll = 1,
159 MouseUsageZoomIn = 3,
160 MouseUsageZoomOut = 4
169 class WXDLLIMPEXP_FWD_WXCHARTVIEWER wxEnhancedTooltip;
177 class WXDLLIMPEXP_WXCHARTVIEWER
wxChartViewer :
public wxPanel,
public ViewPortManager
189 wxChartViewer(wxWindow* parent = 0, wxWindowID
id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL,
const wxString& name = wxPanelNameStr);
217 virtual void setDPI(
int dpi);
223 virtual int getDPI();
233 virtual void setChart(BaseChart* chart);
241 virtual BaseChart* getChart();
258 virtual void setImageMap(
const char* imageMap);
264 virtual ImageMapHandler* getImageMapHandler();
270 virtual void setDefaultToolTip(
const wxString& text);
287 virtual void setCDMLToolTipPrefix(
const wxString& prefix);
305 virtual void setSelectionBorderWidth(
int width);
311 virtual int getSelectionBorderWidth();
317 virtual void setSelectionBorderColor(
const wxColour& color);
323 virtual wxColour getSelectionBorderColor();
329 virtual void setSelectionBorderStyle(wxPenStyle style);
335 virtual wxPenStyle getSelectionBorderStyle();
381 virtual void setMouseUsage(
int mouseUsage);
387 virtual int getMouseUsage();
421 virtual void setZoomDirection(
int direction);
429 virtual int getZoomDirection();
437 virtual void setScrollDirection(
int direction);
445 virtual int getScrollDirection();
453 virtual void setZoomInRatio(
double ratio);
461 virtual double getZoomInRatio();
469 virtual void setZoomOutRatio(
double ratio);
477 virtual double getZoomOutRatio();
491 virtual void setMouseWheelZoomRatio(
double ratio);
499 virtual double getMouseWheelZoomRatio();
514 virtual void setMinimumDrag(
int offset);
520 virtual int getMinimumDrag();
539 virtual void setUpdateInterval(
int interval);
546 virtual int getUpdateInterval();
558 virtual bool needUpdateChart();
570 virtual bool needUpdateImageMap();
578 virtual bool isMouseOnPlotArea();
584 virtual bool isInMouseMoveEvent();
615 virtual bool isInViewPortChangedEvent();
624 virtual bool isMouseDragging();
649 virtual void updateViewPort(
bool needUpdateChart,
bool needUpdateImageMap);
660 virtual void updateDisplay();
669 virtual bool onMouseWheelZoom(
int x,
int y,
int zDelta);
689 virtual void removeDynamicLayer(
const wxString& msg);
697 virtual int getChartMouseX();
705 virtual int getChartMouseY();
720 virtual int getPlotAreaMouseX();
735 virtual int getPlotAreaMouseY();
765 static double ConvertDateTimeToChartTime(wxDateTime dt);
777 static wxDateTime ConvertChartTimeToDateTime(
double ct);
779 DECLARE_EVENT_TABLE()
788 void OnMouseMove(wxMouseEvent &evt);
794 void OnPaint(wxPaintEvent & evt);
800 void PaintNow(BaseChart* chart);
807 void Render(wxDC& dc, BaseChart* chart);
812 virtual
void OnDelayedMouseMove();
818 virtual
void OnMouseCaptureLost(wxMouseCaptureLostEvent& evt);
824 virtual
void OnMousePressEvent(wxMouseEvent& evt);
830 virtual
void OnMouseReleaseEvent(wxMouseEvent& evt);
836 virtual
void OnLeaveEvent(wxMouseEvent& evt);
842 virtual
void OnWheelEvent(wxMouseEvent& evt);
848 virtual
void OnHoldTimerEvent (wxTimerEvent& evt);
854 virtual
void OnDelayTimerEvent(wxTimerEvent& evt);
859 virtual
void OnSetCursor();
863 BaseChart* m_currentChart;
864 ImageMapHandler* m_hotSpotTester;
865 BaseChart* m_imageMapChart;
866 wxString m_defaultToolTip;
867 wxColour m_selectBoxLineColor;
868 int m_selectBoxLineWidth;
869 wxPenStyle m_selectBoxLineStyle;
873 int m_scrollDirection;
874 double m_zoomInRatio;
875 double m_zoomOutRatio;
876 double m_mouseWheelZoomRatio;
878 int m_updateInterval;
879 bool m_needUpdateChart;
880 bool m_needUpdateImageMap;
884 int m_currentHotSpot;
887 bool m_isPlotAreaMouseDown;
888 bool m_isDragScrolling;
889 bool m_isMouseTracking;
890 bool m_isInMouseMove;
894 int m_plotAreaMouseDownXPos;
895 int m_plotAreaMouseDownYPos;
898 bool IsDrag(
int direction, wxMouseEvent& event);
901 void GetDragZoomRect(
int px,
int py,
int& x,
int& y,
int& w,
int& h);
904 void OnPlotAreaMouseDrag(wxMouseEvent& point);
909 wxRect m_currentRect;
910 wxRect m_previousRect;
913 void SetSelectionRect(
int x,
int y,
int width,
int height);
916 void SetRectVisible(
bool b);
919 void DrawSelectionRect(wxDC& dc);
923 bool m_holdTimerActive;
925 bool m_isInViewPortChanged;
927 int m_delayUpdateChart;
928 BaseChart* m_delayedChart;
931 void CommitUpdateChart();
933 unsigned int m_lastMouseMove;
934 wxMouseEvent* m_delayedMouseEvent;
935 wxTimer m_delayedMouseEventTimer;
936 void CommitMouseMove(wxMouseEvent& event);
938 bool m_delayImageMapUpdate;
943 int m_isInMouseMovePlotArea;
946 wxString m_autoHideMsg;
949 void ApplyAutoHide(const wxString& msg);
952 wxEnhancedTooltip* m_enhancedToolTip;
953 wxString m_cdmlToolTipPrefix;
954 void ShowToolTip(const wxString& text, const wxPoint& cursorPosition);
955 void ShowEnhancedToolTip(const wxString& text, const wxPoint& cursorPosition = wxPoint(0,0));
956 void MoveEnhancedToolTip(const wxPoint& cursorPosition, const wxRect& rFrom);
960 bool m_reentrantGuard;
962 wxBitmap m_chartBitmap;
965 double ToImageX(
int x);
966 double ToImageY(
int y);
967 int ToDisplayX(
double x);
968 int ToDisplayY(
double y);
970 double m_toImageScaleX;
971 double m_toImageScaleY;
992 wxViewPortControl(wxWindow* parent = 0, wxWindowID
id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL,
const wxString& name = wxPanelNameStr);
1003 virtual void setChart(BaseChart* chart);
1009 virtual BaseChart* getChart();
1031 virtual void updateDisplay();
1033 DECLARE_EVENT_TABLE()
1040 void OnPaint(wxPaintEvent & evt);
1046 void PaintNow(BaseChart* chart);
1053 void Render(wxDC& dc, BaseChart* chart);
1060 virtual void OnMouseMoveEvent(wxMouseEvent& evt);
1066 virtual void OnMousePressEvent(wxMouseEvent& evt);
1072 virtual void OnMouseReleaseEvent(wxMouseEvent& evt);
1078 virtual void OnMouseWheelEvent(wxMouseEvent& evt);
1084 virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& evt);
1088 virtual void OnViewPortChanged();
1091 bool IsDrag(wxMouseEvent& event);
1094 void PaintDisplay();
1100 void UpdateCursor(
int position);
1103 void UpdateChartViewerIfNecessary();
1106 double ToImageX(
int x);
1109 double ToImageY(
int y);
1113 bool m_reentrantGuard;
1117 bool m_isPlotAreaMouseDown;
1121 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_CLICKED, wxCommandEvent);
1123 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_VIEWPORT_CHANGED, wxCommandEvent);
1125 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_MOUSEMOVE_CHART, wxCommandEvent);
1127 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_MOUSELEAVE_CHART, wxCommandEvent);
1129 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA, wxCommandEvent);
1131 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_MOUSELEAVE_PLOTAREA, wxCommandEvent);
1133 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_WXCHARTVIEWER, wxEVT_CHARTVIEWER_MOUSEWHEEL, wxCommandEvent);
1136 #define EVT_CHARTVIEWER_CLICKED(winid, fn) \
1137 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_CLICKED, winid, wxCommandEventHandler(fn))
1139 #define EVT_CHARTVIEWER_VIEWPORT_CHANGED(winid, fn) \
1140 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_VIEWPORT_CHANGED, winid, wxCommandEventHandler(fn))
1142 #define EVT_CHARTVIEWER_MOUSEMOVE_CHART(winid, fn) \
1143 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_MOUSEMOVE_CHART, winid, wxCommandEventHandler(fn))
1145 #define EVT_CHARTVIEWER_MOUSELEAVE_CHART(winid, fn) \
1146 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_MOUSELEAVE_CHART, winid, wxCommandEventHandler(fn))
1148 #define EVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA(winid, fn) \
1149 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_MOUSEMOVE_PLOTAREA, winid, wxCommandEventHandler(fn))
1151 #define EVT_CHARTVIEWER_MOUSELEAVE_PLOTAREA(winid, fn) \
1152 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_MOUSELEAVE_PLOTAREA, winid, wxCommandEventHandler(fn))
1154 #define EVT_CHARTVIEWER_MOUSEWHEEL(winid, fn) \
1155 wx__DECLARE_EVT1(wxEVT_CHARTVIEWER_MOUSEWHEEL, winid, wxCommandEventHandler(fn))
Class representing a ChartDirector chart viewer control.
Definition: wxchartviewer.h:178
virtual double getViewPortBottom()
Gets the position of the bottom side of the viewport.
Definition: wxchartviewer.h:753
virtual double getViewPortRight()
Gets the position of the right side of the viewport.
Definition: wxchartviewer.h:744
Class representing a ChartDirector viewport control.
Definition: wxchartviewer.h:981