Minsky
renderNativeWindow.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2021
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef RENDER_NATIVE_WINDOW_H
21 #define RENDER_NATIVE_WINDOW_H
22 
23 #include "eventInterface.h"
24 
25 #include <cairoSurfaceImage.h>
26 #include <plot.h>
27 
28 namespace minsky
29 {
30  class WindowInformation;
31  class RenderNativeWindow : public ecolab::CairoSurface, public EventInterface
32  {
33  public:
34  static ecolab::cairo::Colour backgroundColour;
35 
37  {
38  std::string parentWindowId;
39  double offsetLeft;
40  double offsetTop;
41  double childWidth;
42  double childHeight;
43  double scalingFactor=0;
44  };
45 
46 
47  const RenderFrameArgs& frameArgs() const {return m_frameArgs;}
48 
49  ~RenderNativeWindow() override;
51  virtual void init() {};
52  void renderFrame(const RenderFrameArgs& args);
53  void destroyFrame();
54  void draw();
55  void requestRedraw();
56  void macOSXRedraw();
57  // do not clobber winInfoPtr on load of model
58  RenderNativeWindow& operator=(const RenderNativeWindow& x) {ecolab::CairoSurface::operator=(x); return *this;}
59  RenderNativeWindow()=default;
60  RenderNativeWindow(const RenderNativeWindow&)=default;
61  static double scaleFactor();
63  virtual bool hasScrollBars() const {return false;}
64 
65  private:
67  classdesc::Exclude<std::shared_ptr<WindowInformation>> winInfoPtr;
69 
71  struct CopiableMutux: public std::mutex
72  {
73  CopiableMutux()=default;
75  };
76  classdesc::Exclude<CopiableMutux> drawMutex;
77  };
78 } // namespace minsky
79 
80 #include "renderNativeWindow.cd"
81 #endif
const RenderFrameArgs & frameArgs() const
classdesc::Exclude< std::shared_ptr< WindowInformation > > winInfoPtr
classdesc::Exclude< CopiableMutux > drawMutex
virtual bool hasScrollBars() const
return whether this window has scrollbars (needed for MacOSX).
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
void renderFrame(const RenderFrameArgs &args)
CLASSDESC_ACCESS(RenderNativeWindow)
static ecolab::cairo::Colour backgroundColour
a copiable mutex where each copy has a distinct mutex
virtual void init()
perform any initialisation of any subclasses of this
RenderNativeWindow & operator=(const RenderNativeWindow &x)