1 /***************************************************************************
2   gdlwxstream.hpp  - adapted from plplot wxWidgets driver documentation
3                              -------------------
4     begin                : Wed Oct 16 2013
5     copyright            : (C) 2013 by Marc Schellens
6     email                : m_schellens@users.sourceforge.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 //#ifdef FOR_IMPORT
19 
20 #ifndef GDLWXSTREAM_HPP_
21 #define GDLWXSTREAM_HPP_
22 
23 #ifdef HAVE_LIBWXWIDGETS
24 
25 #include "gdlgstream.hpp"
26 #include "gdlwidget.hpp"
27 #include "graphicsdevice.hpp"
28 
29 #include <wx/fontenum.h>
30 #include <wx/fontmap.h>
31 class gdlwxDrawPanel;
32 
33 static std::vector<wxCursor> gdlwxCursors;
34 
35 class GDLWXStream: public GDLGStream
36 {
37 private:
38     wxMemoryDC*  	streamDC;
39     wxBitmap*    	streamBitmap;
40 
41     int m_width;   //!< Width of dc/plot area.
42     int m_height;   //!< Height of dc/plot area.
43     bool isplot; //precise the status of associated widget: plot (true) or widget_draw (false)
44 public:
45     gdlwxGraphicsPanel* container; // for Update()
46 
47     GDLWXStream( int width, int height );
48     ~GDLWXStream();
49 
GetStreamDC() const50     wxMemoryDC* GetStreamDC() const { return streamDC;}
51 
52 //     void set_stream();   //!< Calls some code before every PLplot command.
53     void SetSize( const wxSize s );   //!< Set new size of plot area.
54     void RenewPlot();   //!< Redo plot.
55     void Update();
56     void SetGdlxwGraphicsPanel(gdlwxGraphicsPanel* w, bool isPlot=true);
GetMyContainer()57     gdlwxGraphicsPanel* GetMyContainer(){return container;}
DestroyContainer()58     void DestroyContainer(){delete container; container=NULL;}
59 
IsPlot()60     bool IsPlot() {return isplot;}
61 
62     void Init();
63     void EventHandler();
64 
65     //static int   GetImageErrorHandler(Display *display, XErrorEvent *error); //
66 
67     void GetGeometry( long& xSize, long& ySize);
68     unsigned long GetWindowDepth() ;
69 
70 //    bool UnsetFocus(); UnsetFocus is dangerous: it prevents using wxEvents correctly.
SetBackingStore(int value)71     bool SetBackingStore(int value){return true;}
72     void Clear();
73     void Clear( DLong bColor);
74     void Raise();
75     void Lower();
76     void Iconic();
77     void DeIconic();
78     bool UnsetFocus();
79     bool GetGin(PLGraphicsIn *gin, int mode);
80     //bool GetExtendedGin(PLGraphicsIn *gin, int mode);
81     void WarpPointer(DLong x, DLong y);
Flush()82     void Flush(){ }// plstream::cmd( PLESC_FLUSH, NULL );}
83     //void SetDoubleBuffering();
84     //void UnSetDoubleBuffering();
HasDoubleBuffering()85     bool HasDoubleBuffering(){return true;}
HasSafeDoubleBuffering()86     bool HasSafeDoubleBuffering(){return ( streamDC->GetLogicalFunction() == wxCOPY);};
87     bool PaintImage(unsigned char *idata, PLINT nx, PLINT ny, DLong *pos,
88 		   DLong trueColorOrder, DLong channel);
HasCrossHair()89     virtual bool HasCrossHair() {return true;}
90     bool SetGraphicsFunction( long value);
91     bool GetWindowPosition(long& xpos, long& ypos );
92     bool CursorStandard(int cursorNumber);
93     bool CursorImage(char* v, int x, int y, char* m);
94     DLong GetVisualDepth();
95     BaseGDL* GetFontnames(DString pattern);
96     DLong GetFontnum(DString pattern);
97     void SetCurrentFont(std::string fontname);
98     DString GetVisualName();
99     bool GetScreenResolution(double& resx, double& resy);
100     DByteGDL* GetBitmapData();
GetPlplotFudge()101     float GetPlplotFudge(){return 1.8;}; //correction factor
102     static void DefineSomeWxCursors(); //global initialisation of 77 X11-like cursors.
103 };
104 
105 
106 
107 #endif
108 
109 #endif
110