]> git.saurik.com Git - wxWidgets.git/commitdiff
Whole lotta stuff for wxPlotWindow,
authorRobert Roebling <robert@roebling.de>
Thu, 10 Feb 2000 18:43:33 +0000 (18:43 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 10 Feb 2000 18:43:33 +0000 (18:43 +0000)
  repaired image sample.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5956 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

16 files changed:
Makefile.in
docs/gtk/changes.txt
include/wx/event.h
include/wx/generic/plot.h
include/wx/generic/plot_dwn.xpm [new file with mode: 0644]
include/wx/generic/plot_enl.xpm [new file with mode: 0644]
include/wx/generic/plot_shr.xpm [new file with mode: 0644]
include/wx/generic/plot_up.xpm [new file with mode: 0644]
include/wx/generic/plot_zin.xpm [new file with mode: 0644]
include/wx/generic/plot_zot.xpm [new file with mode: 0644]
samples/configure
samples/configure.in
samples/image/image.cpp
samples/plot/Makefile.in
samples/plot/plot.cpp
src/generic/plot.cpp

index 21db9f2ddb0ccba5034cac21ce6799929bc1e700..668b22698bb9fef9f3fba33cf0ac33fa769f8038 100644 (file)
@@ -895,6 +895,11 @@ SAMPLES_DIST: ALL_GUI_DIST
        cp $(SAMPDIR)/richedit/README $(DISTDIR)/samples/richedit
        cp $(SAMPDIR)/richedit/TODO $(DISTDIR)/samples/richedit
     
        cp $(SAMPDIR)/richedit/README $(DISTDIR)/samples/richedit
        cp $(SAMPDIR)/richedit/TODO $(DISTDIR)/samples/richedit
     
+       mkdir $(DISTDIR)/samples/plot
+       cp $(SAMPDIR)/plot/Makefile.in $(DISTDIR)/samples/plot
+       cp $(SAMPDIR)/plot/makefile.unx $(DISTDIR)/samples/plot
+       cp $(SAMPDIR)/plot/*.cpp $(DISTDIR)/samples/plot
+    
        mkdir $(DISTDIR)/samples/proplist
        cp $(SAMPDIR)/proplist/Makefile.in $(DISTDIR)/samples/proplist
        cp $(SAMPDIR)/proplist/*.cpp $(DISTDIR)/samples/proplist
        mkdir $(DISTDIR)/samples/proplist
        cp $(SAMPDIR)/proplist/Makefile.in $(DISTDIR)/samples/proplist
        cp $(SAMPDIR)/proplist/*.cpp $(DISTDIR)/samples/proplist
index 6b85b38beb18770fc6c571d702b9d5e95cea1c54..8d30067c2b080700ba9fd82aa7f9a082137fd1ec 100644 (file)
@@ -1,6 +1,14 @@
 
 12th January '2000: wxWindows 2.1.14 released
 
 
 12th January '2000: wxWindows 2.1.14 released
 
+Minor changes to socket code.
+
+Added code for rotating images.
+
+Much work on the new grid class has been done.
+
+wxPlotWindow is now useful and works.
+
 Corrected one more bug in the TIFF handler.
 
 It is now possible to run wxGTK apps in the best visual
 Corrected one more bug in the TIFF handler.
 
 It is now possible to run wxGTK apps in the best visual
@@ -10,6 +18,9 @@ instead of only the default on system that support this
 Added default keyboard handling to wxScrolledWindow.
 
 Fixed slightly overoptimized window colour and style handling.
 Added default keyboard handling to wxScrolledWindow.
 
 Fixed slightly overoptimized window colour and style handling.
+This will expose a bug in the GtkPixmap theme, or more exactly
+in ImLib's image cashing so that wxGTK currently doesn't work
+well with pixamp themes.
 
 Fixed bug in drawing code that made GTK pick the wrong pen
 style when using the default.
 
 Fixed bug in drawing code that made GTK pick the wrong pen
 style when using the default.
index 4d959cc105b47d1bcec20eb314fbc5c04ffb6da1..05eef8c4159c391a867fe854fb4791d268735aa9 100644 (file)
@@ -253,6 +253,28 @@ extern const wxEventType wxEVT_CALENDAR_YEAR_CHANGED;
 extern const wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
 extern const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
 
 extern const wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
 extern const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
 
+/* Plot events */
+extern const wxEventType wxEVT_PLOT_SEL_CHANGING;
+extern const wxEventType wxEVT_PLOT_SEL_CHANGED;
+extern const wxEventType wxEVT_PLOT_CLICKED;
+extern const wxEventType wxEVT_PLOT_DOUBLECLICKED;
+extern const wxEventType wxEVT_PLOT_ZOOM_IN;
+extern const wxEventType wxEVT_PLOT_ZOOM_OUT;
+extern const wxEventType wxEVT_PLOT_VALUE_SEL_CREATING;
+extern const wxEventType wxEVT_PLOT_VALUE_SEL_CREATED;
+extern const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGING;
+extern const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGED;
+extern const wxEventType wxEVT_PLOT_AREA_SEL_CREATING;
+extern const wxEventType wxEVT_PLOT_AREA_SEL_CREATED;
+extern const wxEventType wxEVT_PLOT_AREA_SEL_CHANGING;
+extern const wxEventType wxEVT_PLOT_AREA_SEL_CHANGED;
+extern const wxEventType wxEVT_PLOT_BEGIN_X_LABEL_EDIT;
+extern const wxEventType wxEVT_PLOT_END_X_LABEL_EDIT;
+extern const wxEventType wxEVT_PLOT_BEGIN_Y_LABEL_EDIT;
+extern const wxEventType wxEVT_PLOT_END_Y_LABEL_EDIT;
+extern const wxEventType wxEVT_PLOT_BEGIN_TITLE_EDIT;
+extern const wxEventType wxEVT_PLOT_END_TITLE_EDIT;
+
 extern const wxEventType wxEVT_USER_FIRST;
 
 #else // everybody else
 extern const wxEventType wxEVT_USER_FIRST;
 
 #else // everybody else
@@ -474,6 +496,28 @@ const wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953;
 const wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954;
 const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955;
 
 const wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954;
 const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955;
 
+/* Plot events */
+const wxEventType wxEVT_PLOT_SEL_CHANGING = wxEVT_FIRST + 1000;
+const wxEventType wxEVT_PLOT_SEL_CHANGED = wxEVT_FIRST + 1001;
+const wxEventType wxEVT_PLOT_CLICKED = wxEVT_FIRST + 1002;
+const wxEventType wxEVT_PLOT_DOUBLECLICKED = wxEVT_FIRST + 1003;
+const wxEventType wxEVT_PLOT_ZOOM_IN = wxEVT_FIRST + 1004;
+const wxEventType wxEVT_PLOT_ZOOM_OUT = wxEVT_FIRST + 1005;
+const wxEventType wxEVT_PLOT_VALUE_SEL_CREATING = wxEVT_FIRST + 1010;
+const wxEventType wxEVT_PLOT_VALUE_SEL_CREATED = wxEVT_FIRST + 1011;
+const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGING = wxEVT_FIRST + 1012;
+const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGED = wxEVT_FIRST + 1013;
+const wxEventType wxEVT_PLOT_AREA_SEL_CREATING = wxEVT_FIRST + 1014;
+const wxEventType wxEVT_PLOT_AREA_SEL_CREATED = wxEVT_FIRST + 1015;
+const wxEventType wxEVT_PLOT_AREA_SEL_CHANGING = wxEVT_FIRST + 1016;
+const wxEventType wxEVT_PLOT_AREA_SEL_CHANGED = wxEVT_FIRST + 1017;
+const wxEventType wxEVT_PLOT_BEGIN_X_LABEL_EDIT = wxEVT_FIRST + 1020;
+const wxEventType wxEVT_PLOT_END_X_LABEL_EDIT = wxEVT_FIRST + 1021;
+const wxEventType wxEVT_PLOT_BEGIN_Y_LABEL_EDIT = wxEVT_FIRST + 1022;
+const wxEventType wxEVT_PLOT_END_Y_LABEL_EDIT = wxEVT_FIRST + 1023;
+const wxEventType wxEVT_PLOT_BEGIN_TITLE_EDIT = wxEVT_FIRST + 1024;
+const wxEventType wxEVT_PLOT_END_TITLE_EDIT = wxEVT_FIRST + 1025;
+
 const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
 
 #endif // for VisualAge C++ V4.0
 const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
 
 #endif // for VisualAge C++ V4.0
index 386117cfa8c6116d5475e0de8d68a5bde6b2dd12..449d68fed1652fd3ec51ae827b49f2ffb1cb2e76 100644 (file)
 #endif
 
 #include "wx/scrolwin.h"
 #endif
 
 #include "wx/scrolwin.h"
+#include "wx/event.h"
 
 //-----------------------------------------------------------------------------
 // classes
 //-----------------------------------------------------------------------------
 
 
 //-----------------------------------------------------------------------------
 // classes
 //-----------------------------------------------------------------------------
 
-class wxPlotCurve;
-class wxPlotArea;
-class wxPlotWindow;
+class WXDLLEXPORT wxPlotEvent;
+class WXDLLEXPORT wxPlotCurve;
+class WXDLLEXPORT wxPlotArea;
+class WXDLLEXPORT wxPlotXAxisArea;
+class WXDLLEXPORT wxPlotYAxisArea;
+class WXDLLEXPORT wxPlotWindow;
+
+//-----------------------------------------------------------------------------
+// consts
+//-----------------------------------------------------------------------------
+
+#define wxPLOT_X_AXIS          0x0004
+#define wxPLOT_Y_AXIS          0x0008
+#define wxPLOT_BUTTON_MOVE     0x0010
+#define wxPLOT_BUTTON_ZOOM     0x0020
+#define wxPLOT_BUTTON_ENLARGE  0x0040
+
+#define wxPLOT_BUTTON_ALL  (wxPLOT_BUTTON_MOVE|wxPLOT_BUTTON_ZOOM|wxPLOT_BUTTON_ENLARGE)
+#define wxPLOT_DEFAULT     (wxPLOT_X_AXIS|wxPLOT_Y_AXIS | wxPLOT_BUTTON_ALL)
+
+//-----------------------------------------------------------------------------
+// wxPlotEvent
+//-----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxPlotEvent: public wxNotifyEvent
+{
+public:
+    wxPlotEvent( wxEventType commandType = wxEVT_NULL, int id = 0 );
+      
+    wxPlotCurve *GetCurve()
+        { return m_curve; }
+    void SetCurve( wxPlotCurve *curve )
+        { m_curve = curve; }
+        
+    double GetZoom()
+        { return m_zoom; }
+    void SetZoom( double zoom )
+        { m_zoom = zoom; }
+    
+    wxInt32 GetPosition()
+        { return m_position; }
+    void SetPosition( wxInt32 pos )
+        { m_position = pos; }
+    
+private:
+    wxPlotCurve   *m_curve;
+    double         m_zoom;
+    wxInt32        m_position;
+};
 
 //-----------------------------------------------------------------------------
 // wxPlotCurve
 
 //-----------------------------------------------------------------------------
 // wxPlotCurve
@@ -77,13 +124,56 @@ public:
     void DrawCurve( wxDC *dc, wxPlotCurve *curve, int from = -1, int to = -1 );
     void DeleteCurve( wxPlotCurve *curve, int from = -1, int to = -1 );
     
     void DrawCurve( wxDC *dc, wxPlotCurve *curve, int from = -1, int to = -1 );
     void DeleteCurve( wxPlotCurve *curve, int from = -1, int to = -1 );
     
+    virtual void ScrollWindow( int dx, int dy, const wxRect *rect );
+    
 private:
 private:
-    wxPlotWindow   *m_owner;
+    wxPlotWindow     *m_owner;
+    bool              m_zooming;
 
     DECLARE_CLASS(wxPlotArea)
     DECLARE_EVENT_TABLE()
 };
 
 
     DECLARE_CLASS(wxPlotArea)
     DECLARE_EVENT_TABLE()
 };
 
+//-----------------------------------------------------------------------------
+// wxPlotXAxisArea
+//-----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxPlotXAxisArea: public wxWindow
+{
+public:
+    wxPlotXAxisArea() {}
+    wxPlotXAxisArea( wxPlotWindow *parent );
+    
+    void OnPaint( wxPaintEvent &event );
+    void OnMouse( wxMouseEvent &event );
+    
+private:
+    wxPlotWindow   *m_owner;
+
+    DECLARE_CLASS(wxPlotXAxisArea)
+    DECLARE_EVENT_TABLE()
+};
+
+//-----------------------------------------------------------------------------
+// wxPlotYAxisArea
+//-----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxPlotYAxisArea: public wxWindow
+{
+public:
+    wxPlotYAxisArea() {}
+    wxPlotYAxisArea( wxPlotWindow *parent );
+    
+    void OnPaint( wxPaintEvent &event );
+    void OnMouse( wxMouseEvent &event );
+    
+private:
+    wxPlotWindow   *m_owner;
+
+    DECLARE_CLASS(wxPlotYAxisArea)
+    DECLARE_EVENT_TABLE()
+};
+
 //-----------------------------------------------------------------------------
 // wxPlotWindow
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // wxPlotWindow
 //-----------------------------------------------------------------------------
@@ -92,9 +182,12 @@ class WXDLLEXPORT wxPlotWindow: public wxScrolledWindow
 {
 public:
     wxPlotWindow() {}
 {
 public:
     wxPlotWindow() {}
-    wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flags );
+    wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flags = wxPLOT_DEFAULT );
     ~wxPlotWindow();
     
     ~wxPlotWindow();
     
+    // curve accessors
+    // ---------------
+    
     void Add( wxPlotCurve *curve );
     size_t GetCount();
     wxPlotCurve *GetAt( size_t n );
     void Add( wxPlotCurve *curve );
     size_t GetCount();
     wxPlotCurve *GetAt( size_t n );
@@ -102,31 +195,88 @@ public:
     void SetCurrent( wxPlotCurve* current );
     wxPlotCurve *GetCurrent();
     
     void SetCurrent( wxPlotCurve* current );
     wxPlotCurve *GetCurrent();
     
+    // vertical representation
+    // -----------------------
+    
     void Move( wxPlotCurve* curve, int pixels_up );
     void Enlarge( wxPlotCurve *curve, double factor );
 
     void Move( wxPlotCurve* curve, int pixels_up );
     void Enlarge( wxPlotCurve *curve, double factor );
 
+    // horizontal representation
+    // -------------------------
+    
+    void SetUnitsPerValue( double upv );
+    double GetUnitsPerValue()
+        { return m_xUnitsPerValue; }
+        
+    void SetZoom( double zoom );
+    double GetZoom()
+        { return m_xZoom; }
+    
+    // events (may be overridden)
+    // --------------------------
+
     void OnMoveUp( wxCommandEvent& event );
     void OnMoveDown( wxCommandEvent& event );
     
     void OnMoveUp( wxCommandEvent& event );
     void OnMoveDown( wxCommandEvent& event );
     
-    void OnEnlarge100( wxCommandEvent& event );
-    void OnEnlarge50( wxCommandEvent& event );
-    void OnShrink50( wxCommandEvent& event );
-    void OnShrink33( wxCommandEvent& event );
+    void OnEnlarge( wxCommandEvent& event );
+    void OnShrink( wxCommandEvent& event );
+    void OnZoomIn( wxCommandEvent& event );
+    void OnZoomOut( wxCommandEvent& event );
     
     
-    void OnPaint( wxPaintEvent &event );
-
+    void OnScroll2( wxScrollWinEvent& event );
+    
+    // utilities
+    // ---------
+    
+    void RedrawEverything();
+    void RedrawXAxis();
     void RedrawYAxis();
     
     void RedrawYAxis();
     
+    void ResetScrollbar();
+    
 private:
     friend wxPlotArea;
 private:
     friend wxPlotArea;
+    friend wxPlotXAxisArea;
+    friend wxPlotYAxisArea;
     
     
-    wxList         m_curves;
-    wxPlotArea    *m_area;
-    wxPlotCurve   *m_current;
+    double             m_xUnitsPerValue;
+    double             m_xZoom;
+    
+    wxList             m_curves;
+    wxPlotArea        *m_area;
+    wxPlotXAxisArea   *m_xaxis;
+    wxPlotYAxisArea   *m_yaxis;
+    wxPlotCurve       *m_current;
 
     DECLARE_CLASS(wxPlotWindow)
     DECLARE_EVENT_TABLE()
 };
 
 
     DECLARE_CLASS(wxPlotWindow)
     DECLARE_EVENT_TABLE()
 };
 
+// ----------------------------------------------------------------------------
+// calendar events macros
+// ----------------------------------------------------------------------------
+
+#define EVT_PLOT(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_SEL_CHANGING(id, fn) { wxEVT_PLOT_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_SEL_CHANGED(id, fn) { wxEVT_PLOT_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_CLICKED(id, fn) { wxEVT_PLOT_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_DOUBLECLICKED(id, fn) { wxEVT_PLOT_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_ZOOM_IN(id, fn) { wxEVT_PLOT_ZOOM_IN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_ZOOM_OUT(id, fn) { wxEVT_PLOT_ZOOM_OUT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_VALUE_SEL_CREATING(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_VALUE_SEL_CREATED(id, fn) { wxEVT_PLOT_VALUE_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_VALUE_SEL_CHANGING(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_VALUE_SEL_CHANGED(id, fn) { wxEVT_PLOT_VALUE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_AREA_SEL_CREATING(id, fn) { wxEVT_PLOT_AREA_SEL_CREATING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_AREA_SEL_CREATED(id, fn) { wxEVT_PLOT_AREA_SEL_CREATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_AREA_SEL_CHANGING(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_AREA_SEL_CHANGED(id, fn) { wxEVT_PLOT_AREA_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_BEGIN_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_END_X_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_X_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_BEGIN_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_BEGIN_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_END_Y_LABEL_EDIT(id, fn) { wxEVT_PLOT_END_Y_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_BEGIN_TITLE_EDIT(id, fn) { wxEVT_PLOT_BEGIN_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_PLOT_END_TITLE_EDIT(id, fn) { wxEVT_PLOT_END_TITLE_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+
 #endif
    // _WX_PLOT_H_
 #endif
    // _WX_PLOT_H_
diff --git a/include/wx/generic/plot_dwn.xpm b/include/wx/generic/plot_dwn.xpm
new file mode 100644 (file)
index 0000000..51a59d3
--- /dev/null
@@ -0,0 +1,32 @@
+/* XPM */
+static char *plot_dwn_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 18 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@@@@@@@@@@",
+".@.@.@@@@@@@@@@@@@@@",
+"@@.@@@@@@@@  @@@@@@@",
+"@@.@@@@++++o +++@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@@@+ +@@@@@@@",
+"@@.@@@@@@@@+@@@@@@@@",
+"@@.@@....@@@@@@@@@@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@@O...O@@@",
+"@@.@@@@@@@@@@@@@@@@@",
+"@@@@@@@@@@@@@@@@@@@@",
+};
diff --git a/include/wx/generic/plot_enl.xpm b/include/wx/generic/plot_enl.xpm
new file mode 100644 (file)
index 0000000..7e48e2c
--- /dev/null
@@ -0,0 +1,34 @@
+/* XPM */
+static char *plot_enl_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 20 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@+@@@@@@@@",
+".@.@.@@@@@+ +@@@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@++++o +++@@@@",
+"@@.@@....@@  @@@@@@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@@O...O@@@",
+"@@.@@@@@@@@  @@@@@@@",
+"@@.@@@@++++o +++@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@@@+ +@@@@@@@",
+"@@@@@@@@@@@+@@@@@@@@",
+};
diff --git a/include/wx/generic/plot_shr.xpm b/include/wx/generic/plot_shr.xpm
new file mode 100644 (file)
index 0000000..0918938
--- /dev/null
@@ -0,0 +1,34 @@
+/* XPM */
+static char *plot_shr_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 20 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@  @@@@@@@",
+".@.@.@@++++o +++@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@@@+ +@@@@@@@",
+"@@.@@....@@+@@@@@@@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@+O...O@@@",
+"@@.@@@@@@@+ +@@@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@++++o +++@@@@",
+"@@.@@@@@@@@  @@@@@@@",
+"@@@@@@@@@@@@@@@@@@@@",
+};
diff --git a/include/wx/generic/plot_up.xpm b/include/wx/generic/plot_up.xpm
new file mode 100644 (file)
index 0000000..cafdb0b
--- /dev/null
@@ -0,0 +1,32 @@
+/* XPM */
+static char *plot_up_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 18 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@@@@@@@@@@",
+".@.@.@@@@@@@@@@@@@@@",
+"@@.@@@@@@@@+@@@@@@@@",
+"@@.@@@@@@@+ +@@@@@@@",
+"@@.@@@@@@+ o +@@@@@@",
+"@@.@@@@@+ ooo +@@@@@",
+"@@.@@@@@   o   @@@@@",
+"@@.@@@@++++o +++@@@@",
+"@@.@@@@@@@@  @@@@@@@",
+"@@.@@....@@@@@@@@@@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@@O...O@@@",
+"@@.@@@@@@@@@@@@@@@@@",
+"@@@@@@@@@@@@@@@@@@@@",
+};
diff --git a/include/wx/generic/plot_zin.xpm b/include/wx/generic/plot_zin.xpm
new file mode 100644 (file)
index 0000000..27aabe8
--- /dev/null
@@ -0,0 +1,32 @@
+/* XPM */
+static char *plot_zin_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 18 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@@@@@@@@@@",
+".@.@.@@@@+@@@@+@@@@@",
+"@@.@@@@+ +@@@@+ +@@@",
+"@@.@@@+  +@@@@+  +@@",
+"@@.@@+ o +@@@@+ o +@",
+"@@.@+ oooo @@ oooo +",
+"@@.@@+ o   @@   o +@",
+"@@.@@@+  +@@@@+  +@@",
+"@@.@@@@+ +@@@@+ +@@@",
+"@@.@@....+@@@@+@@@@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@@O...O@@@",
+"@@.@@@@@@@@@@@@@@@@@",
+"@@@@@@@@@@@@@@@@@@@@",
+};
diff --git a/include/wx/generic/plot_zot.xpm b/include/wx/generic/plot_zot.xpm
new file mode 100644 (file)
index 0000000..d3a34d1
--- /dev/null
@@ -0,0 +1,32 @@
+/* XPM */
+static char *plot_zot_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"20 18 8 1",
+"  c Gray0",
+". c #000084",
+"X c Blue",
+"o c Green",
+"O c #848484",
+"+ c #c6c6c6",
+"@ c None",
+"# c Gray100",
+/* pixels */
+"@@.@@@@@@@@@@@@@@@@@",
+"@...@@@@@@@@@@@@@@@@",
+".@.@.@+@@@@@@@@@@+@@",
+"@@.@@@+ +@@@@@@+ +@@",
+"@@.@@@+  +@@@@+  +@@",
+"@@.@@@+ o +@@+ o +@@",
+"@@.@@ oooo ++ oooo @",
+"@@.@@   o +@@+ o   @",
+"@@.@@@+  +@@@@+  +@@",
+"@@.@@@+ +@@@@@@+ +@@",
+"@@.@@....@@@@@@@@+@@",
+"@@.@.O@@@.O@@@@@@@@@",
+"@@.O.@@@@@.@@@@@@@.@",
+"@@..@@@@@@@.@@@@@.O@",
+"@@.@@@@@@@@O.@@@.O@@",
+"@@.@@@@@@@@@O...O@@@",
+"@@.@@@@@@@@@@@@@@@@@",
+"@@@@@@@@@@@@@@@@@@@@",
+};
index 0a88efd4cb6a6dbd7c98f3dedebf450ab05f196e..59f6f4652d76f4fa763e3d75174ca6444a0e0e41 100755 (executable)
@@ -2,7 +2,7 @@
 
 # From configure.in Id: configure.in
 # Guess values for system-dependent variables and create Makefiles.
 
 # From configure.in Id: configure.in
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13 
+# Generated automatically using autoconf version 2.14 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -334,7 +334,7 @@ EOF
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.13"
+    echo "configure generated by autoconf version 2.14"
     exit 0 ;;
 
   -with-* | --with-*)
     exit 0 ;;
 
   -with-* | --with-*)
@@ -628,7 +628,7 @@ do
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.13"
+    echo "$CONFIG_STATUS generated by autoconf version 2.14"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -648,6 +648,7 @@ trap 'rm -fr `echo "
             console/Makefile
             db/Makefile
             dialogs/Makefile
             console/Makefile
             db/Makefile
             dialogs/Makefile
+            dialup/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
@@ -664,9 +665,9 @@ trap 'rm -fr `echo "
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
-            dialup/Makefile
             newgrid/Makefile
             notebook/Makefile
             newgrid/Makefile
             notebook/Makefile
+            plot/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
@@ -779,6 +780,7 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
             console/Makefile
             db/Makefile
             dialogs/Makefile
             console/Makefile
             db/Makefile
             dialogs/Makefile
+            dialup/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
@@ -795,9 +797,9 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
-            dialup/Makefile
             newgrid/Makefile
             notebook/Makefile
             newgrid/Makefile
             notebook/Makefile
+            plot/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
index 633b12e9e00704d28106543085622eeab63abeb3..feb575b07125cc16519a533bfadf8e0d2dbe768b 100644 (file)
@@ -16,6 +16,7 @@ AC_OUTPUT([
             console/Makefile
             db/Makefile
             dialogs/Makefile
             console/Makefile
             db/Makefile
             dialogs/Makefile
+            dialup/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
             docview/Makefile
             docvwmdi/Makefile
             dnd/Makefile
@@ -32,9 +33,9 @@ AC_OUTPUT([
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
             mdi/Makefile
             minifram/Makefile
             minimal/Makefile
-            dialup/Makefile
             newgrid/Makefile
             notebook/Makefile
             newgrid/Makefile
             notebook/Makefile
+            plot/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
             png/Makefile
             printing/Makefile
             proplist/Makefile
index 63cc8f3b17019ec17fd92373b0fa0399eeb98efe..bcc4ed44085ad2675d1a1737026a6df95437bec7 100644 (file)
@@ -142,8 +142,13 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
     wxImage image( bitmap );
 
 #if wxUSE_LIBPNG
     wxImage image( bitmap );
 
 #if wxUSE_LIBPNG
+    image.LoadFile( dir + wxString("test.png") );
+    my_square = new wxBitmap( image.ConvertToBitmap() );
+    
     if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) )
         wxLogError("Can't save file");
     if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) )
         wxLogError("Can't save file");
+        
+    image = wxImage( 100, 100 );
 
     if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) )
         wxLogError("Can't load PNG image");
 
     if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) )
         wxLogError("Can't load PNG image");
@@ -152,6 +157,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
 #endif // wxUSE_LIBPNG
 
 #if wxUSE_LIBJPEG
 #endif // wxUSE_LIBPNG
 
 #if wxUSE_LIBJPEG
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.jpg") ) )
         wxLogError("Can't load JPG image");
     else
     if ( !image.LoadFile( dir + wxString("horse.jpg") ) )
         wxLogError("Can't load JPG image");
     else
@@ -159,6 +166,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
 #endif // wxUSE_LIBJPEG
 
 #if wxUSE_GIF
 #endif // wxUSE_LIBJPEG
 
 #if wxUSE_GIF
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.gif") ) )
         wxLogError("Can't load GIF image");
     else
     if ( !image.LoadFile( dir + wxString("horse.gif") ) )
         wxLogError("Can't load GIF image");
     else
@@ -166,21 +175,24 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
 #endif
 
 #if wxUSE_PCX
 #endif
 
 #if wxUSE_PCX
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.pcx"), wxBITMAP_TYPE_PCX ) )
         wxLogError("Can't load PCX image");
     else
         my_horse_pcx = new wxBitmap( image.ConvertToBitmap() );
     if ( !image.LoadFile( dir + wxString("horse.pcx"), wxBITMAP_TYPE_PCX ) )
         wxLogError("Can't load PCX image");
     else
         my_horse_pcx = new wxBitmap( image.ConvertToBitmap() );
-
-    image.LoadFile( dir + wxString("test.pcx") );
-    my_square = new wxBitmap( image.ConvertToBitmap() );
 #endif
 
 #endif
 
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.bmp"), wxBITMAP_TYPE_BMP ) )
         wxLogError("Can't load BMP image");
     else
         my_horse_bmp = new wxBitmap( image.ConvertToBitmap() );
 
 #if wxUSE_PNM
     if ( !image.LoadFile( dir + wxString("horse.bmp"), wxBITMAP_TYPE_BMP ) )
         wxLogError("Can't load BMP image");
     else
         my_horse_bmp = new wxBitmap( image.ConvertToBitmap() );
 
 #if wxUSE_PNM
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.pnm"), wxBITMAP_TYPE_PNM ) )
         wxLogError("Can't load PNM image");
     else
     if ( !image.LoadFile( dir + wxString("horse.pnm"), wxBITMAP_TYPE_PNM ) )
         wxLogError("Can't load PNM image");
     else
@@ -188,6 +200,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
 #endif
 
 #if wxUSE_LIBTIFF
 #endif
 
 #if wxUSE_LIBTIFF
+    image = wxImage( 100, 100 );
+
     if ( !image.LoadFile( dir + wxString("horse.tif"), wxBITMAP_TYPE_TIF ) )
         wxLogError("Can't load TIFF image");
     else
     if ( !image.LoadFile( dir + wxString("horse.tif"), wxBITMAP_TYPE_TIF ) )
         wxLogError("Can't load TIFF image");
     else
@@ -199,11 +213,13 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
     my_smile_xbm = new wxBitmap( (const char*)smile_bits, smile_width,
                                  smile_height, 1 );
 
     my_smile_xbm = new wxBitmap( (const char*)smile_bits, smile_width,
                                  smile_height, 1 );
 
+#ifndef __WXGTK__
 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
     // demonstrates XPM automatically using the mask when saving
     if ( m_bmpSmileXpm.Ok() )
         m_bmpSmileXpm.SaveFile("saved.xpm", wxBITMAP_TYPE_XPM);
 #endif
 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
     // demonstrates XPM automatically using the mask when saving
     if ( m_bmpSmileXpm.Ok() )
         m_bmpSmileXpm.SaveFile("saved.xpm", wxBITMAP_TYPE_XPM);
 #endif
+#endif
 }
 
 MyCanvas::~MyCanvas()
 }
 
 MyCanvas::~MyCanvas()
index 322ee115100c3d90c1736101f4f271bdbf7c2384..ee038834cb8cfabee3ba2157d28b92a7cb1625fd 100644 (file)
@@ -9,7 +9,7 @@
 #
 # Makefile for plot example (UNIX).
 
 #
 # Makefile for plot example (UNIX).
 
-top_srcdir = @top_srcdir@
+top_srcdir = @top_srcdir@/..
 top_builddir = ../..
 program_dir = samples/plot
 
 top_builddir = ../..
 program_dir = samples/plot
 
index 50a1932c3935864220869cf932019b6501d2d03a..46e9c363ac144bd90af4d76d099f3e6e92a567b0 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual wxInt32 GetStartX()
         { return 0; }
     virtual wxInt32 GetEndX()
     virtual wxInt32 GetStartX()
         { return 0; }
     virtual wxInt32 GetEndX()
-        { return 10000; }
+        { return 7000; }
     
     virtual double GetY( wxInt32 x )
         { 
     
     virtual double GetY( wxInt32 x )
         { 
@@ -64,6 +64,9 @@ public:
 
     void OnAbout( wxCommandEvent &event );
     void OnQuit( wxCommandEvent &event );
 
     void OnAbout( wxCommandEvent &event );
     void OnQuit( wxCommandEvent &event );
+    
+    void OnPlotClick( wxPlotEvent &event );
+    void OnPlotDClick( wxPlotEvent &event );
 
     wxPlotWindow   *m_plot;
     wxTextCtrl     *m_log;
 
     wxPlotWindow   *m_plot;
     wxTextCtrl     *m_log;
@@ -93,8 +96,10 @@ const int ID_ABOUT = 109;
 IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
 
 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
 IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
 
 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
-  EVT_MENU    (ID_ABOUT, MyFrame::OnAbout)
-  EVT_MENU    (ID_QUIT,  MyFrame::OnQuit)
+  EVT_MENU             (ID_ABOUT, MyFrame::OnAbout)
+  EVT_MENU             (ID_QUIT,  MyFrame::OnQuit)
+  EVT_PLOT_CLICKED         ( -1,  MyFrame::OnPlotClick)
+  EVT_PLOT_DOUBLECLICKED   ( -1,  MyFrame::OnPlotDClick)
 END_EVENT_TABLE()
 
 MyFrame::MyFrame()
 END_EVENT_TABLE()
 
 MyFrame::MyFrame()
@@ -114,8 +119,8 @@ MyFrame::MyFrame()
     int widths[] = { -1, 100 };
     SetStatusWidths( 2, widths );
 
     int widths[] = { -1, 100 };
     SetStatusWidths( 2, widths );
 
-    m_plot = new wxPlotWindow( this, -1, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER );
-    m_plot->SetScrollbars( 10, 10, 500, 0 );
+    m_plot = new wxPlotWindow( this, -1, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER | wxPLOT_DEFAULT );
+    m_plot->SetUnitsPerValue( 0.01 );
 
     m_plot->Add( new MyPlotCurve( 0,  -1.5, 1.5 ) );
     m_plot->Add( new MyPlotCurve( 50, -1.5, 1.5 ) );
 
     m_plot->Add( new MyPlotCurve( 0,  -1.5, 1.5 ) );
     m_plot->Add( new MyPlotCurve( 50, -1.5, 1.5 ) );
@@ -145,6 +150,20 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
                       "About wxPlotWindow Demo", wxICON_INFORMATION | wxOK );
 }
 
                       "About wxPlotWindow Demo", wxICON_INFORMATION | wxOK );
 }
 
+void MyFrame::OnPlotClick( wxPlotEvent &event )
+{
+    double x = event.GetPosition() * m_plot->GetUnitsPerValue();
+    double y = event.GetCurve()->GetY( event.GetPosition() );
+    wxLogMessage( "Clicked on curve at x coordinate: %f, value: %f", x, y );
+}
+
+void MyFrame::OnPlotDClick( wxPlotEvent &event )
+{
+    double x = event.GetPosition() * m_plot->GetUnitsPerValue();
+    double y = event.GetCurve()->GetY( event.GetPosition() );
+    wxLogMessage( "Double clicked on curve at x coordinate: %f, value: %f", x, y );
+}
+
 //-----------------------------------------------------------------------------
 // MyApp
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // MyApp
 //-----------------------------------------------------------------------------
index 57c197c8753be0e0c1809e9f0d11582d756e5742..0da3f4ec7950fac6a37592246b2586f8e6498d49 100644 (file)
 #endif
 
 #include "wx/generic/plot.h"
 #endif
 
 #include "wx/generic/plot.h"
+#include "wx/bmpbuttn.h"
 
 #include <math.h>
 
 
 #include <math.h>
 
+// ----------------------------------------------------------------------------
+// XPMs
+// ----------------------------------------------------------------------------
+
+#if !defined(__WXMSW__) && !defined(__WXPM__)
+    #include "wx/generic/plot_enl.xpm"
+    #include "wx/generic/plot_shr.xpm"
+    #include "wx/generic/plot_zin.xpm"
+    #include "wx/generic/plot_zot.xpm"
+    #include "wx/generic/plot_up.xpm"
+    #include "wx/generic/plot_dwn.xpm"
+#endif
+
+// ----------------------------------------------------------------------------
+// accessor functions for the bitmaps (may return NULL, check for it!)
+// ----------------------------------------------------------------------------
+
+static wxBitmap *GetEnlargeBitmap();
+static wxBitmap *GetShrinkBitmap();
+static wxBitmap *GetZoomInBitmap();
+static wxBitmap *GetZoomOutBitmap();
+static wxBitmap *GetUpBitmap();
+static wxBitmap *GetDownBitmap();
+
+//-----------------------------------------------------------------------------
+// wxPlotEvent
+//-----------------------------------------------------------------------------
+
+wxPlotEvent::wxPlotEvent( wxEventType commandType, int id )
+    : wxNotifyEvent( commandType, id )
+{ 
+    m_curve = (wxPlotCurve*) NULL;
+    m_zoom = 1.0;
+    m_position = 0;
+}
+      
 //-----------------------------------------------------------------------------
 // wxPlotCurve
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // wxPlotCurve
 //-----------------------------------------------------------------------------
@@ -57,12 +94,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxPlotArea, wxWindow)
 BEGIN_EVENT_TABLE(wxPlotArea, wxWindow)
   EVT_PAINT(        wxPlotArea::OnPaint)
   EVT_LEFT_DOWN(    wxPlotArea::OnMouse)
 BEGIN_EVENT_TABLE(wxPlotArea, wxWindow)
   EVT_PAINT(        wxPlotArea::OnPaint)
   EVT_LEFT_DOWN(    wxPlotArea::OnMouse)
+  EVT_LEFT_DCLICK(  wxPlotArea::OnMouse)
 END_EVENT_TABLE()
 
 wxPlotArea::wxPlotArea( wxPlotWindow *parent )
         : wxWindow( parent, -1, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, "plotarea" )
 {
     m_owner = parent;
 END_EVENT_TABLE()
 
 wxPlotArea::wxPlotArea( wxPlotWindow *parent )
         : wxWindow( parent, -1, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, "plotarea" )
 {
     m_owner = parent;
+    
+    m_zooming = FALSE;
 
     SetBackgroundColour( *wxWHITE );
 }
 
     SetBackgroundColour( *wxWHITE );
 }
@@ -77,32 +117,48 @@ void wxPlotArea::OnMouse( wxMouseEvent &event )
     m_owner->GetViewStart( &view_x, &view_y );
     view_x *= 10;
     view_y *= 10;
     m_owner->GetViewStart( &view_x, &view_y );
     view_x *= 10;
     view_y *= 10;
-
-    wxPoint pos = event.GetPosition();
-    int x = pos.x;
-    int y = pos.y;
+    
+    int x = event.GetX();
+    int y = event.GetY();
     x += view_x;
     y += view_y;
     x += view_x;
     y += view_y;
-
+    
     wxNode *node = m_owner->m_curves.First();
     while (node)
     {
         wxPlotCurve *curve = (wxPlotCurve*)node->Data();
     wxNode *node = m_owner->m_curves.First();
     while (node)
     {
         wxPlotCurve *curve = (wxPlotCurve*)node->Data();
-
+            
         double double_client_height = (double)client_height;
         double range = curve->GetEndY() - curve->GetStartY();
         double end = curve->GetEndY();
         wxCoord offset_y = curve->GetOffsetY();
         double double_client_height = (double)client_height;
         double range = curve->GetEndY() - curve->GetStartY();
         double end = curve->GetEndY();
         wxCoord offset_y = curve->GetOffsetY();
-
-        double dy = (end - curve->GetY( x )) / range;
+            
+        double dy = (end - curve->GetY( x/m_owner->GetZoom() )) / range;
         wxCoord curve_y = (wxCoord)(dy * double_client_height) - offset_y - 1;
         wxCoord curve_y = (wxCoord)(dy * double_client_height) - offset_y - 1;
-
+                
         if ((y-curve_y < 4) && (y-curve_y > -4))
         {
         if ((y-curve_y < 4) && (y-curve_y > -4))
         {
-            m_owner->SetCurrent( curve );
+            wxPlotEvent event1( event.ButtonDClick() ? wxEVT_PLOT_DOUBLECLICKED : wxEVT_PLOT_CLICKED, m_owner->GetId() );
+            event1.SetEventObject( m_owner );
+            event1.SetZoom( m_owner->GetZoom() );
+            event1.SetCurve( curve );
+            event1.SetPosition( (int)floor(x/m_owner->GetZoom()) );
+            m_owner->GetEventHandler()->ProcessEvent( event1 );
+            
+            if (curve != m_owner->GetCurrent());
+            {
+                wxPlotEvent event2( wxEVT_PLOT_SEL_CHANGING, m_owner->GetId() );
+                event2.SetEventObject( m_owner );
+                event2.SetZoom( m_owner->GetZoom() );
+                event2.SetCurve( curve );
+                if (!m_owner->GetEventHandler()->ProcessEvent( event2 ) || event2.IsAllowed())
+                {
+                    m_owner->SetCurrent( curve );
+                }
+            }
             return;
         }
             return;
         }
-
+            
         node = node->Next();
     }
 }
         node = node->Next();
     }
 }
@@ -121,37 +177,39 @@ void wxPlotArea::DrawCurve( wxDC *dc, wxPlotCurve *curve, int from, int to )
     int view_y;
     m_owner->GetViewStart( &view_x, &view_y );
     view_x *= 10;
     int view_y;
     m_owner->GetViewStart( &view_x, &view_y );
     view_x *= 10;
-
+    
     if (from == -1)
         from = view_x;
 
     int client_width;
     int client_height;
     GetClientSize( &client_width, &client_height);
     if (from == -1)
         from = view_x;
 
     int client_width;
     int client_height;
     GetClientSize( &client_width, &client_height);
-
+    
     if (to == -1)
         to = view_x + client_width;
 
     if (to == -1)
         to = view_x + client_width;
 
-    int start_x = wxMax( from, curve->GetStartX() );
-    int end_x = wxMin( to, curve->GetEndX() );
+    double zoom = m_owner->GetZoom();
+
+    int start_x = wxMax( from, (int)floor(curve->GetStartX()*zoom) );
+    int end_x = wxMin( to, (int)floor(curve->GetEndX()*zoom) );
 
     start_x = wxMax( view_x, start_x );
     end_x = wxMin( view_x + client_width, end_x );
 
     start_x = wxMax( view_x, start_x );
     end_x = wxMin( view_x + client_width, end_x );
-
+    
     double double_client_height = (double)client_height;
     double range = curve->GetEndY() - curve->GetStartY();
     double end = curve->GetEndY();
     wxCoord offset_y = curve->GetOffsetY();
     double double_client_height = (double)client_height;
     double range = curve->GetEndY() - curve->GetStartY();
     double end = curve->GetEndY();
     wxCoord offset_y = curve->GetOffsetY();
-
+            
     wxCoord y=0,last_y=0;
     for (int x = start_x; x < end_x; x++)
     {
     wxCoord y=0,last_y=0;
     for (int x = start_x; x < end_x; x++)
     {
-        double dy = (end - curve->GetY( x )) / range;
+        double dy = (end - curve->GetY( x/zoom )) / range;
         y = (wxCoord)(dy * double_client_height) - offset_y - 1;
         y = (wxCoord)(dy * double_client_height) - offset_y - 1;
-
+            
         if (x != start_x)
            dc->DrawLine( x-1, last_y, x, y );
         if (x != start_x)
            dc->DrawLine( x-1, last_y, x, y );
-
+            
         last_y = y;
     }
 }
         last_y = y;
     }
 }
@@ -168,16 +226,16 @@ void wxPlotArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
     m_owner->PrepareDC( dc );
 
     wxRegionIterator upd( GetUpdateRegion() );
     m_owner->PrepareDC( dc );
 
     wxRegionIterator upd( GetUpdateRegion() );
-
+    
     while (upd)
     {
         int update_x = upd.GetX();
         int update_y = upd.GetY();
         int update_width = upd.GetWidth();
     while (upd)
     {
         int update_x = upd.GetX();
         int update_y = upd.GetY();
         int update_width = upd.GetWidth();
-
+        
         update_x += view_x;
         update_y += view_y;
         update_x += view_x;
         update_y += view_y;
-
+        
 /*
         if (m_owner->m_current)
         {
 /*
         if (m_owner->m_current)
         {
@@ -186,17 +244,17 @@ void wxPlotArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
             dc.DrawLine( update_x-1, base_line-1, update_x+update_width+2, base_line-1 );
         }
 */
             dc.DrawLine( update_x-1, base_line-1, update_x+update_width+2, base_line-1 );
         }
 */
-
+        
         wxNode *node = m_owner->m_curves.First();
         while (node)
         {
             wxPlotCurve *curve = (wxPlotCurve*)node->Data();
         wxNode *node = m_owner->m_curves.First();
         while (node)
         {
             wxPlotCurve *curve = (wxPlotCurve*)node->Data();
-
+            
             if (curve == m_owner->GetCurrent())
                 dc.SetPen( *wxBLACK_PEN );
             else
             if (curve == m_owner->GetCurrent())
                 dc.SetPen( *wxBLACK_PEN );
             else
-                dc.SetPen( *wxLIGHT_GREY_PEN );
-
+                dc.SetPen( *wxGREY_PEN );
+                
             DrawCurve( &dc, curve, update_x-1, update_x+update_width+2 );
 
             node = node->Next();
             DrawCurve( &dc, curve, update_x-1, update_x+update_width+2 );
 
             node = node->Next();
@@ -205,60 +263,330 @@ void wxPlotArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
     }
 }
 
     }
 }
 
+void wxPlotArea::ScrollWindow( int dx, int dy, const wxRect *rect )
+{
+    wxWindow::ScrollWindow( dx, dy, rect );
+//    m_owner->m_xaxis->ScrollWindow( dx, 0 );
+}
+
+//-----------------------------------------------------------------------------
+// wxPlotXAxisArea
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPlotXAxisArea, wxWindow)
+
+BEGIN_EVENT_TABLE(wxPlotXAxisArea, wxWindow)
+  EVT_PAINT(        wxPlotXAxisArea::OnPaint)
+  EVT_LEFT_DOWN(    wxPlotXAxisArea::OnMouse)
+END_EVENT_TABLE()
+
+wxPlotXAxisArea::wxPlotXAxisArea( wxPlotWindow *parent )
+        : wxWindow( parent, -1, wxDefaultPosition, wxSize(-1,40), 0, "plotxaxisarea" )
+{
+    m_owner = parent;
+    
+    SetBackgroundColour( *wxWHITE );
+}
+
+void wxPlotXAxisArea::OnMouse( wxMouseEvent &event )
+{
+    int client_width;
+    int client_height;
+    GetClientSize( &client_width, &client_height);
+    int view_x;
+    int view_y;
+    m_owner->GetViewStart( &view_x, &view_y );
+    view_x *= 10;
+    view_y *= 10;
+    
+    int x = event.GetX();
+    int y = event.GetY();
+    x += view_x;
+    y += view_y;
+    
+    /* do something here */
+}
+
+void wxPlotXAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+    int view_x;
+    int view_y;
+    m_owner->GetViewStart( &view_x, &view_y );
+    view_x *= 10;
+    view_y *= 10;
+
+    wxPaintDC dc( this );
+    
+    int client_width;
+    int client_height;
+    GetClientSize( &client_width, &client_height);
+    
+    double zoom = m_owner->GetZoom();
+    
+    double ups = m_owner->GetUnitsPerValue() / zoom;
+    
+    double start = view_x * ups;
+    double end = (view_x + client_width) * ups;
+    double range = end - start;
+    
+    int int_log_range = (int)floor( log10( range ) );
+    double step = 1.0;
+    if (int_log_range > 0)
+    {
+        for (int i = 0; i < int_log_range; i++)
+           step *= 10; 
+    }
+    if (int_log_range < 0)
+    {
+        for (int i = 0; i < -int_log_range; i++)
+           step /= 10; 
+    }
+    double lower = ceil(start / step) * step;
+    double upper = floor(end / step) * step;
+    
+    // if too few values, shrink size
+    if ((range/step) < 4)
+    {
+        step /= 2;
+        if (lower-step > start) lower -= step;
+        if (upper+step < end) upper += step;
+    }
+    
+    // if still too few, again
+    if ((range/step) < 4)
+    {
+        step /= 2;
+        if (lower-step > start) lower -= step;
+        if (upper+step < end) upper += step;
+    }
+    
+    dc.SetBrush( *wxWHITE_BRUSH );
+    dc.SetPen( *wxTRANSPARENT_PEN );
+    dc.DrawRectangle( 4, 5, client_width-14, 10 );
+    dc.DrawRectangle( 0, 20, client_width, 20 );
+    dc.SetPen( *wxBLACK_PEN );
+    
+    double current = lower;
+    while (current < upper+(step/2))
+    {
+        int x = (int)ceil((current-start) / range * (double)client_width) - 1;
+        if ((x > 4) && (x < client_width-25))
+        {
+            dc.DrawLine( x, 5, x, 15 );
+            wxString label;
+            if (range < 10)
+                label.Printf( wxT("%.1f"), current );
+            else
+                label.Printf( wxT("%d"), (int)floor(current) );
+            dc.DrawText( label, x-4, 20 );
+        }
+
+        current += step;
+    }
+    
+    dc.DrawLine( 0, 15, client_width-8, 15 );
+    dc.DrawLine( client_width-4, 15, client_width-10, 10 );
+    dc.DrawLine( client_width-4, 15, client_width-10, 20 );
+}
+
+//-----------------------------------------------------------------------------
+// wxPlotYAxisArea
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPlotYAxisArea, wxWindow)
+
+BEGIN_EVENT_TABLE(wxPlotYAxisArea, wxWindow)
+  EVT_PAINT(        wxPlotYAxisArea::OnPaint)
+  EVT_LEFT_DOWN(    wxPlotYAxisArea::OnMouse)
+END_EVENT_TABLE()
+
+wxPlotYAxisArea::wxPlotYAxisArea( wxPlotWindow *parent )
+        : wxWindow( parent, -1, wxDefaultPosition, wxSize(60,-1), 0, "plotyaxisarea" )
+{
+    m_owner = parent;
+    
+    SetBackgroundColour( *wxWHITE );
+}
+
+void wxPlotYAxisArea::OnMouse( wxMouseEvent &WXUNUSED(event) )
+{
+    /* do something here */
+}
+
+void wxPlotYAxisArea::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+    wxPaintDC dc( this );
+    
+    wxPlotCurve *curve = m_owner->GetCurrent();
+    
+    if (!curve) return;
+    
+    int client_width;
+    int client_height;
+    GetClientSize( &client_width, &client_height);
+
+    
+    double range = curve->GetEndY() - curve->GetStartY();
+    double offset = ((double) curve->GetOffsetY() / (double)client_height ) * range;
+    double start = curve->GetStartY() - offset;
+    double end = curve->GetEndY() - offset;
+    
+    int int_log_range = (int)floor( log10( range ) );
+    double step = 1.0;
+    if (int_log_range > 0)
+    {
+        for (int i = 0; i < int_log_range; i++)
+           step *= 10; 
+    }
+    if (int_log_range < 0)
+    {
+        for (int i = 0; i < -int_log_range; i++)
+           step /= 10; 
+    }
+    double lower = ceil(start / step) * step;
+    double upper = floor(end / step) * step;
+    
+    // if too few values, shrink size
+    if ((range/step) < 4)
+    {
+        step /= 2;
+        if (lower-step > start) lower -= step;
+        if (upper+step < end) upper += step;
+    }
+    
+    // if still too few, again
+    if ((range/step) < 4)
+    {
+        step /= 2;
+        if (lower-step > start) lower -= step;
+        if (upper+step < end) upper += step;
+    }
+
+    dc.SetPen( *wxBLACK_PEN );
+    
+    double current = lower;
+    while (current < upper+(step/2))
+    {
+        int y = (int)((curve->GetEndY()-current) / range * (double)client_height) - 1;
+        y -= curve->GetOffsetY();
+        if ((y > 10) && (y < client_height-7))
+        {
+            dc.DrawLine( client_width-15, y, client_width-7, y );
+            wxString label;
+            label.Printf( wxT("%.1f"), current );
+            dc.DrawText( label, 5, y-7 );
+        }
+
+        current += step;
+    }
+    
+    dc.DrawLine( client_width-15, 6, client_width-15, client_height );
+    dc.DrawLine( client_width-15, 2, client_width-20, 8 );
+    dc.DrawLine( client_width-15, 2, client_width-10, 8 );
+}
+
 //-----------------------------------------------------------------------------
 // wxPlotWindow
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
 // wxPlotWindow
 //-----------------------------------------------------------------------------
 
-#define  ID_ENLARGE_100   1000
-#define  ID_ENLARGE_50    1001
-#define  ID_SHRINK_33     1002
-#define  ID_SHRINK_50     1003
+#define  ID_ENLARGE       1000
+#define  ID_SHRINK        1002
 
 #define  ID_MOVE_UP       1006
 #define  ID_MOVE_DOWN     1007
 
 
 #define  ID_MOVE_UP       1006
 #define  ID_MOVE_DOWN     1007
 
+#define  ID_ZOOM_IN       1010
+#define  ID_ZOOM_OUT      1011
+
 
 IMPLEMENT_DYNAMIC_CLASS(wxPlotWindow, wxScrolledWindow)
 
 BEGIN_EVENT_TABLE(wxPlotWindow, wxScrolledWindow)
 
 IMPLEMENT_DYNAMIC_CLASS(wxPlotWindow, wxScrolledWindow)
 
 BEGIN_EVENT_TABLE(wxPlotWindow, wxScrolledWindow)
-  EVT_PAINT(                   wxPlotWindow::OnPaint)
   EVT_BUTTON(  ID_MOVE_UP,     wxPlotWindow::OnMoveUp)
   EVT_BUTTON(  ID_MOVE_DOWN,   wxPlotWindow::OnMoveDown)
   EVT_BUTTON(  ID_MOVE_UP,     wxPlotWindow::OnMoveUp)
   EVT_BUTTON(  ID_MOVE_DOWN,   wxPlotWindow::OnMoveDown)
-
-  EVT_BUTTON(  ID_ENLARGE_100, wxPlotWindow::OnEnlarge100)
-  EVT_BUTTON(  ID_ENLARGE_50,  wxPlotWindow::OnEnlarge50)
-  EVT_BUTTON(  ID_SHRINK_50,   wxPlotWindow::OnShrink50)
-  EVT_BUTTON(  ID_SHRINK_33,   wxPlotWindow::OnShrink33)
+  
+  EVT_BUTTON(  ID_ENLARGE,  wxPlotWindow::OnEnlarge)
+  EVT_BUTTON(  ID_SHRINK,   wxPlotWindow::OnShrink)
+  
+  EVT_BUTTON(  ID_ZOOM_IN,     wxPlotWindow::OnZoomIn)
+  EVT_BUTTON(  ID_ZOOM_OUT,    wxPlotWindow::OnZoomOut)
+  
+  EVT_SCROLLWIN( wxPlotWindow::OnScroll2)
 END_EVENT_TABLE()
 
 wxPlotWindow::wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag )
         : wxScrolledWindow( parent, id, pos, size, flag, "plotcanvas" )
 {
 END_EVENT_TABLE()
 
 wxPlotWindow::wxPlotWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag )
         : wxScrolledWindow( parent, id, pos, size, flag, "plotcanvas" )
 {
-    m_area = new wxPlotArea( this );
+    m_xUnitsPerValue = 1.0;
+    m_xZoom = 1.0;
 
 
+    m_area = new wxPlotArea( this );
     wxBoxSizer *mainsizer = new wxBoxSizer( wxHORIZONTAL );
     wxBoxSizer *mainsizer = new wxBoxSizer( wxHORIZONTAL );
+    
+    if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ALL) != 0)
+    {
+        wxBoxSizer *buttonlist = new wxBoxSizer( wxVERTICAL );
+        if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ENLARGE) != 0)
+        {
+            buttonlist->Add( new wxBitmapButton( this, ID_ENLARGE, *GetEnlargeBitmap() ), 0, wxEXPAND|wxALL, 2 );
+            buttonlist->Add( new wxBitmapButton( this, ID_SHRINK, *GetShrinkBitmap() ), 0, wxEXPAND|wxALL, 2 );
+            buttonlist->Add( 20,10, 0 );
+        }
+        if ((GetWindowStyleFlag() & wxPLOT_BUTTON_MOVE) != 0)
+        {
+            buttonlist->Add( new wxBitmapButton( this, ID_MOVE_UP, *GetUpBitmap() ), 0, wxEXPAND|wxALL, 2 );
+            buttonlist->Add( new wxBitmapButton( this, ID_MOVE_DOWN, *GetDownBitmap() ), 0, wxEXPAND|wxALL, 2 );
+            buttonlist->Add( 20,10, 0 );
+        }
+        if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ZOOM) != 0)
+        {
+            buttonlist->Add( new wxBitmapButton( this, ID_ZOOM_IN, *GetZoomInBitmap() ), 0, wxEXPAND|wxALL, 2 );
+            buttonlist->Add( new wxBitmapButton( this, ID_ZOOM_OUT, *GetZoomOutBitmap() ), 0, wxEXPAND|wxALL, 2 );
+        }
+        mainsizer->Add( buttonlist, 0, wxEXPAND|wxALL, 4 );
+    }
+    
+    wxBoxSizer *plotsizer = new wxBoxSizer( wxHORIZONTAL );
+    
+    if ((GetWindowStyleFlag() & wxPLOT_Y_AXIS) != 0)
+    {
+        m_yaxis = new wxPlotYAxisArea( this );
+    
+        wxBoxSizer *vert1 = new wxBoxSizer( wxVERTICAL );
+        plotsizer->Add( vert1, 0, wxEXPAND );
+        vert1->Add( m_yaxis, 1 );
+        if ((GetWindowStyleFlag() & wxPLOT_X_AXIS) != 0)
+            vert1->Add( 60, 40 );
+    }
+    else
+    {
+        m_yaxis = (wxPlotYAxisArea*) NULL;
+    }
+    
+    if ((GetWindowStyleFlag() & wxPLOT_X_AXIS) != 0)
+    {
+        m_xaxis = new wxPlotXAxisArea( this );
+    
+        wxBoxSizer *vert2 = new wxBoxSizer( wxVERTICAL );
+        plotsizer->Add( vert2, 1, wxEXPAND );
+        vert2->Add( m_area, 1, wxEXPAND );
+        vert2->Add( m_xaxis, 0, wxEXPAND );
+    }
+    else
+    {
+        plotsizer->Add( m_area, 1, wxEXPAND );
+        m_xaxis = (wxPlotXAxisArea*) NULL;
+    }
 
 
-    wxBoxSizer *buttonlist = new wxBoxSizer( wxVERTICAL );
-    buttonlist->Add( new wxButton( this, ID_ENLARGE_100, _("+ 100%") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( new wxButton( this, ID_ENLARGE_50, _("+ 50%") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( new wxButton( this, ID_SHRINK_33, _("- 33%") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( new wxButton( this, ID_SHRINK_50, _("- 50%") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( 20,20, 0 );
-    buttonlist->Add( new wxButton( this, ID_MOVE_UP, _("Up") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( new wxButton( this, ID_MOVE_DOWN, _("Down") ), 0, wxEXPAND|wxALL, 5 );
-    buttonlist->Add( 20,20, 1 );
-
-    mainsizer->Add( buttonlist, 0, wxEXPAND );
-
-    mainsizer->Add( m_area, 1, wxEXPAND|wxLEFT, 50 );
-
+    mainsizer->Add( plotsizer, 1, wxEXPAND );    
+    
     SetAutoLayout( TRUE );
     SetSizer( mainsizer );
 
     SetTargetWindow( m_area );
 
     SetBackgroundColour( *wxWHITE );
     SetAutoLayout( TRUE );
     SetSizer( mainsizer );
 
     SetTargetWindow( m_area );
 
     SetBackgroundColour( *wxWHITE );
-
+    
     m_current = (wxPlotCurve*) NULL;
 }
 
     m_current = (wxPlotCurve*) NULL;
 }
 
@@ -270,6 +598,8 @@ void wxPlotWindow::Add( wxPlotCurve *curve )
 {
     m_curves.Append( curve );
     if (!m_current) m_current = curve;
 {
     m_curves.Append( curve );
     if (!m_current) m_current = curve;
+    
+    ResetScrollbar();
 }
 
 size_t wxPlotWindow::GetCount()
 }
 
 size_t wxPlotWindow::GetCount()
@@ -282,7 +612,7 @@ wxPlotCurve *wxPlotWindow::GetAt( size_t n )
     wxNode *node = m_curves.Nth( n );
     if (!node)
         return (wxPlotCurve*) NULL;
     wxNode *node = m_curves.Nth( n );
     if (!node)
         return (wxPlotCurve*) NULL;
-
+        
     return (wxPlotCurve*) node->Data();
 }
 
     return (wxPlotCurve*) node->Data();
 }
 
@@ -290,8 +620,14 @@ void wxPlotWindow::SetCurrent( wxPlotCurve* current )
 {
     m_current = current;
     m_area->Refresh( FALSE );
 {
     m_current = current;
     m_area->Refresh( FALSE );
-
+    
     RedrawYAxis();
     RedrawYAxis();
+    
+    wxPlotEvent event( wxEVT_PLOT_SEL_CHANGED, GetId() );
+    event.SetEventObject( this );
+    event.SetZoom( GetZoom() );
+    event.SetCurve( m_current );
+    GetEventHandler()->ProcessEvent( event );
 }
 
 wxPlotCurve *wxPlotWindow::GetCurrent()
 }
 
 wxPlotCurve *wxPlotWindow::GetCurrent()
@@ -302,153 +638,255 @@ wxPlotCurve *wxPlotWindow::GetCurrent()
 void wxPlotWindow::Move( wxPlotCurve* curve, int pixels_up )
 {
     m_area->DeleteCurve( curve );
 void wxPlotWindow::Move( wxPlotCurve* curve, int pixels_up )
 {
     m_area->DeleteCurve( curve );
-
+    
     curve->SetOffsetY( curve->GetOffsetY() + pixels_up );
     curve->SetOffsetY( curve->GetOffsetY() + pixels_up );
-
+    
     m_area->Refresh( FALSE );
     m_area->Refresh( FALSE );
-
+    
     RedrawYAxis();
 }
 
 void wxPlotWindow::OnMoveUp( wxCommandEvent& WXUNUSED(event) )
 {
     if (!m_current) return;
     RedrawYAxis();
 }
 
 void wxPlotWindow::OnMoveUp( wxCommandEvent& WXUNUSED(event) )
 {
     if (!m_current) return;
-
+    
     Move( m_current, 25 );
 }
 
 void wxPlotWindow::OnMoveDown( wxCommandEvent& WXUNUSED(event) )
 {
     if (!m_current) return;
     Move( m_current, 25 );
 }
 
 void wxPlotWindow::OnMoveDown( wxCommandEvent& WXUNUSED(event) )
 {
     if (!m_current) return;
-
+    
     Move( m_current, -25 );
 }
 
 void wxPlotWindow::Enlarge( wxPlotCurve *curve, double factor )
 {
     m_area->DeleteCurve( curve );
     Move( m_current, -25 );
 }
 
 void wxPlotWindow::Enlarge( wxPlotCurve *curve, double factor )
 {
     m_area->DeleteCurve( curve );
-
+    
     double range = curve->GetEndY() - curve->GetStartY();
     double range = curve->GetEndY() - curve->GetStartY();
-    double new_range = range * factor;
+    double new_range = range / factor;
     double middle = curve->GetEndY() - range/2;
     curve->SetStartY( middle - new_range / 2 );
     curve->SetEndY( middle + new_range / 2 );
     double middle = curve->GetEndY() - range/2;
     curve->SetStartY( middle - new_range / 2 );
     curve->SetEndY( middle + new_range / 2 );
-
+    
     m_area->Refresh( FALSE );
     m_area->Refresh( FALSE );
-
     RedrawYAxis();
 }
 
     RedrawYAxis();
 }
 
-void wxPlotWindow::OnEnlarge100( wxCommandEvent& WXUNUSED(event) )
+void wxPlotWindow::SetUnitsPerValue( double upv )
 {
 {
-    if (!m_current) return;
-
-    Enlarge( m_current, 2.0 );
+    m_xUnitsPerValue = upv;
+    
+    RedrawXAxis();
 }
 
 }
 
-void wxPlotWindow::OnEnlarge50( wxCommandEvent& WXUNUSED(event) )
+void wxPlotWindow::SetZoom( double zoom )
 {
 {
-    if (!m_current) return;
+    double old_zoom = m_xZoom;
+    m_xZoom = zoom;
+    
+    int view_x = 0;
+    int view_y = 0;
+    GetViewStart( &view_x, &view_y );
+    
+    wxInt32 max = 0;
+    wxNode *node = m_curves.First();
+    while (node)
+    {
+        wxPlotCurve *curve = (wxPlotCurve*) node->Data();
+        if (curve->GetEndX() > max)
+            max = curve->GetEndX();
+        node = node->Next();
+    }
+    SetScrollbars( 10, 10, (int)((max*m_xZoom)/10)+1, 0, (int)view_x*zoom/old_zoom, 0 );
 
 
-    Enlarge( m_current, 1.5 );
+    RedrawXAxis();
+    m_area->Refresh( TRUE );
 }
 
 }
 
-void wxPlotWindow::OnShrink50( wxCommandEvent& WXUNUSED(event) )
+void wxPlotWindow::ResetScrollbar()
 {
 {
-    if (!m_current) return;
-
-    Enlarge( m_current, 0.5 );
+    wxInt32 max = 0;
+    wxNode *node = m_curves.First();
+    while (node)
+    {
+        wxPlotCurve *curve = (wxPlotCurve*) node->Data();
+        if (curve->GetEndX() > max)
+            max = curve->GetEndX();
+        node = node->Next();
+    }
+    
+    SetScrollbars( 10, 10, ((max*m_xZoom)/10)+1, 0 );
 }
 
 }
 
-void wxPlotWindow::OnShrink33( wxCommandEvent& WXUNUSED(event) )
+void wxPlotWindow::RedrawXAxis()
 {
 {
-    if (!m_current) return;
-
-    Enlarge( m_current, 0.6666666 );
+    if (m_xaxis)
+        m_xaxis->Refresh( FALSE );
 }
 
 void wxPlotWindow::RedrawYAxis()
 {
 }
 
 void wxPlotWindow::RedrawYAxis()
 {
-    int client_width;
-    int client_height;
-    GetClientSize( &client_width, &client_height);
+    if (m_yaxis)
+       m_yaxis->Refresh( TRUE );
+}
 
 
-    wxPoint pos( m_area->GetPosition() );
+void wxPlotWindow::RedrawEverything()
+{
+    if (m_xaxis)
+        m_xaxis->Refresh( TRUE );
+    if (m_yaxis)
+        m_yaxis->Refresh( TRUE );
+    m_area->Refresh( TRUE );
+}
 
 
-    wxRect rect(pos.x-45,0,45,client_height);
-    Refresh(TRUE,&rect);
+void wxPlotWindow::OnZoomIn( wxCommandEvent& WXUNUSED(event) )
+{
+    SetZoom( m_xZoom * 1.5 );
 }
 
 }
 
-void wxPlotWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
+void wxPlotWindow::OnZoomOut( wxCommandEvent& WXUNUSED(event) )
 {
 {
-    wxPaintDC dc( this );
+    SetZoom( m_xZoom * 0.6666 );
+}
 
 
+void wxPlotWindow::OnEnlarge( wxCommandEvent& WXUNUSED(event) )
+{
     if (!m_current) return;
     if (!m_current) return;
+    
+    Enlarge( m_current, 1.5 );
+}
 
 
-    int client_width;
-    int client_height;
-    GetClientSize( &client_width, &client_height);
+void wxPlotWindow::OnShrink( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_current) return;
+    
+    Enlarge( m_current, 0.6666666 );
+}
 
 
-    dc.SetPen( *wxBLACK_PEN );
+void wxPlotWindow::OnScroll2( wxScrollWinEvent& event )
+{
+    wxScrolledWindow::OnScroll( event );
+    
+    RedrawXAxis();
+}
 
 
-    wxPoint pos( m_area->GetPosition() );
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
 
 
-    double range = m_current->GetEndY() - m_current->GetStartY();
-    double offset = ((double) m_current->GetOffsetY() / (double)client_height ) * range;
-    double start = m_current->GetStartY() - offset;
-    double end = m_current->GetEndY() - offset;
-    int int_log_range = (int)floor( log10( range ) );
-    double step = 1.0;
-    if (int_log_range > 0)
+// FIXME MT-UNSAFE
+static wxBitmap *GetEnlargeBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
     {
     {
-        for (int i = 0; i < int_log_range; i++)
-           step *= 10;
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
+
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_enl.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_enl_xpm );
+        #endif
     }
     }
-    if (int_log_range < 0)
+
+    return s_bitmap;
+}
+
+static wxBitmap *GetShrinkBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
     {
     {
-        for (int i = 0; i < -int_log_range; i++)
-           step /= 10;
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
+
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_shr.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_shr_xpm );
+        #endif
     }
     }
-    double lower = ceil(start / step) * step;
-    double upper = floor(end / step) * step;
 
 
-    // if too few values, shrink size
-    int steps = (int)ceil((upper-lower)/step);
-    if (steps < 4)
+    return s_bitmap;
+}
+
+static wxBitmap *GetZoomInBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
     {
     {
-        step /= 2;
-        if (lower-step > start) lower -= step;
-        if (upper+step < end) upper += step;
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
+
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_zin.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_zin_xpm );
+        #endif
     }
 
     }
 
-    // if still too few, again
-    steps = (int)ceil((upper-lower)/step);
-    if (steps < 4)
+    return s_bitmap;
+}
+
+static wxBitmap *GetZoomOutBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
     {
     {
-        step /= 2;
-        if (lower-step > start) lower -= step;
-        if (upper+step < end) upper += step;
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
+
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_zot.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_zot_xpm );
+        #endif
     }
 
     }
 
-    double current = lower;
-    while (current < upper+(step/2))
+    return s_bitmap;
+}
+
+static wxBitmap *GetUpBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
     {
     {
-        int y = (int)((m_current->GetEndY()-current) / range * (double)client_height) - 1;
-        y -= m_current->GetOffsetY();
-        if ((y > 10) && (y < client_height-7))
-        {
-            dc.DrawLine( pos.x-15, y, pos.x-7, y );
-            wxString label;
-            label.Printf( wxT("%.1f"), current );
-            dc.DrawText( label, pos.x-45, y-7 );
-        }
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
 
 
-        current += step;
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_up.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_up_xpm );
+        #endif
     }
 
     }
 
-    dc.DrawLine( pos.x-15, 6, pos.x-15, client_height-5 );
-    dc.DrawLine( pos.x-19, 8, pos.x-15, 2 );
-    dc.DrawLine( pos.x-10, 9, pos.x-15, 2 );
-
+    return s_bitmap;
 }
 
 }
 
+static wxBitmap *GetDownBitmap()
+{
+    static wxBitmap* s_bitmap = (wxBitmap *) NULL;
+    static bool s_loaded = FALSE;
+
+    if ( !s_loaded )
+    {
+        s_loaded = TRUE; // set it to TRUE anyhow, we won't try again
+
+        #if defined(__WXMSW__) || defined(__WXPM__)
+            s_bitmap = new wxBitmap("plot_dwn.bmp", wxBITMAP_TYPE_RESOURCE);
+        #else
+            s_bitmap = new wxBitmap( plot_dwn_xpm );
+        #endif
+    }
+
+    return s_bitmap;
+}