PLplot  5.11.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
wxwidgets.h
Go to the documentation of this file.
1 // Copyright (C) 2008 Werner Smekal
2 //
3 // This file is part of PLplot.
4 //
5 // PLplot is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // PLplot is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public License
16 // along with PLplot; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 
20 #ifndef __WXWIDGETS_H__
21 #define __WXWIDGETS_H__
22 
23 #include <vector>
24 #include <memory>
25 
26 // plplot headers
27 #include "plplotP.h"
28 #include "wxwidgets_comms.h"
29 
30 // some special wxWidgets headers
31 #include <wx/wx.h>
32 #include <wx/spinctrl.h>
33 #ifdef wxUSE_GRAPHICS_CONTEXT
34 #include <wx/dcgraph.h>
35 #endif
36 
37 class wxPLplotFrame;
38 
39 // base device class
41 {
42 public:
43  wxPLDevice( PLStream *pls, char * mfo, PLINT text, PLINT hrshsym );
44  virtual ~wxPLDevice( void );
45 
46  void DrawLine( short x1a, short y1a, short x2a, short y2a );
47  void DrawPolyline( short *xa, short *ya, PLINT npts );
48  void ClearBackground( PLStream* pls, PLINT x1 = -1, PLINT y1 = -1, PLINT x2 = -1, PLINT y2 = -1 );
49  void FillPolygon( PLStream *pls );
50  void SetWidth( PLStream *pls );
51  void SetColor( PLStream *pls );
52  void SetDC( PLStream *pls, wxDC* dc );
53  void EndPage( PLStream* pls );
54  void BeginPage( PLStream* pls );
55  void SetSize( PLStream* pls, int width, int height );
56  void ProcessString( PLStream* pls, EscText* args );
57  void FixAspectRatio( bool fix );
58  void Locate( PLStream* pls, PLGraphicsIn *graphicsIn );
59  void Flush( PLStream* pls );
60 
61 private:
62  void DrawTextLine( PLUNICODE* ucs4, int ucs4Len, PLFLT baseFontSize, bool drawText, PLINT &superscriptLevel );
63  void DrawTextSection( char* utf8_string, PLFLT baseFontSize, PLFLT yOffset, bool drawText );
64  void TransmitBuffer( PLStream* pls, unsigned char transmissionType );
65  void SetupMemoryMap();
66  wxFont GetFont( PLUNICODE fci, PLFLT scaledFontSize );
67 
68  //The DC we will draw on if given by the user
69  wxDC *m_dc;
71  //for the gcdc case we may need to store the graphics context for use
72  // with text transformations
73  wxGraphicsContext *m_gc;
74  wxPen m_pen;
75  wxBrush m_brush;
76 
77  //Size and Scale
78  //As far as plplot is concerned the size of the window is SHRT_MAX by
79  //SHRT_MAX which gives us the best resolution.
81  PLFLT m_width; //native width
82  PLFLT m_height; //native height
83  PLFLT m_xScale; //conversion from native width to plplotEdgeLength
84  PLFLT m_yScale; //conversion from native height to plplotEdgeLength
85  PLFLT m_xAspect; //values which when multiplied by m_plplotEdgeLength give an aspect
86  PLFLT m_yAspect; //ratio equal to the native aspect ratio, the biggest of which is 1.0
87  PLFLT m_scale; //MAX(m_scalex, m_scaley)
89 
90  // font variables
91  static const int m_max_string_length = 500;
92  wxFont m_font;
94  //PLFLT m_fontSize;
95  //PLFLT m_fontScale;
98 
99  //Text positioning related variables
100  wxCoord m_superscriptHeight; //distance between superscript top and baseline
101  wxCoord m_subscriptDepth; //distance between subscript base and baseline
103  //PLFLT m_yOffset;
107 
108  //variables for dealing with sending/receiving commands
109  //via a memory map
114 };
115 
116 
117 struct dev_entry
118 {
119  wxString dev_name;
120  wxString dev_menu_short;
121  wxString dev_menu_long;
122  wxString dev_file_app;
124 };
125 
126 //--------------------------------------------------------------------------
127 // Declarations for the device.
128 //--------------------------------------------------------------------------
129 
130 void plD_init_wxwidgets( PLStream * );
131 void plD_init_wxpng( PLStream * );
132 void plD_line_wxwidgets( PLStream *, short, short, short, short );
133 void plD_polyline_wxwidgets( PLStream *, short *, short *, PLINT );
134 void plD_eop_wxwidgets( PLStream * );
135 void plD_bop_wxwidgets( PLStream * );
136 void plD_tidy_wxwidgets( PLStream * );
138 void plD_esc_wxwidgets( PLStream *, PLINT, void * );
139 
140 void wx_set_dc( PLStream* pls, wxDC* dc );
141 void wx_set_buffer( PLStream* pls, wxImage* buffer );
142 
143 //--------------------------------------------------------------------------
144 // Debug functions
145 //--------------------------------------------------------------------------
146 
147 // define if you want debug output
148 // #define _DEBUG //
149 // #define _DEBUG_VERBOSE //
150 void Log_Verbose( const char *fmt, ... );
151 void Log_Debug( const char *fmt, ... );
152 
153 
154 //--------------------------------------------------------------------------
155 // Font style and weight lookup tables
156 //--------------------------------------------------------------------------
157 const wxFontFamily fontFamilyLookup[5] = {
158  wxFONTFAMILY_SWISS, // sans-serif
159  wxFONTFAMILY_ROMAN, // serif
160  wxFONTFAMILY_TELETYPE, // monospace
161  wxFONTFAMILY_SCRIPT, // script
162  wxFONTFAMILY_SWISS // symbol
163 };
164 
165 const int fontStyleLookup[3] = {
166  wxFONTSTYLE_NORMAL, // upright
167  wxFONTSTYLE_ITALIC, // italic
168  wxFONTSTYLE_SLANT // oblique
169 };
170 
171 const int fontWeightLookup[2] = {
172  wxFONTWEIGHT_NORMAL, // medium
173  wxFONTWEIGHT_BOLD // bold
174 };
175 
176 #endif // __WXWIDGETS_H__