FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
PluginWindowMac.h
1 /**********************************************************\
2 Original Author: Eric Herrmann
3 
4 Created: Feb 8, 2011
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2011 Eric Herrmann, Firebreath development team
13 \**********************************************************/
14 
15 #ifndef H_PLUGINWINDOWMAC
16 #define H_PLUGINWINDOWMAC
17 
18 #include <boost/type_traits.hpp>
19 #include "NpapiBrowserHost.h"
20 #include "NpapiTypes.h"
21 #include "FBPointers.h"
22 
23 #include "PluginWindow.h"
24 
25 namespace FB {
26 
27  FB_FORWARD_PTR(PluginEventMac);
28  FB_FORWARD_PTR(PluginWindowMac);
29 
30  class PluginWindowMac : public PluginWindow
31  {
32  public:
33  enum DrawingModel
34  {
35  DrawingModelQuickDraw,
36  DrawingModelCoreGraphics,
37  DrawingModelCoreAnimation,
38  DrawingModelInvalidatingCoreAnimation
39  };
40 
41  static NPDrawingModel initPluginWindowMac(const FB::Npapi::NpapiBrowserHostPtr &host);
42  static NPDrawingModel initPluginWindowMac(const FB::Npapi::NpapiBrowserHostPtr &host, const std::string& drawingModel);
43  static FB::PluginWindowMac* createPluginWindowMac(NPDrawingModel drawingModel);
44 
45  PluginWindowMac();
46  virtual ~PluginWindowMac();
47 
48  virtual void StartAutoInvalidate(double rate);
49  virtual void StopAutoInvalidate();
50  virtual void InvalidateWindow() const;
51 
52  virtual NPError SetWindow(NPWindow* window);
53  virtual int16_t GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
54 
55  virtual DrawingModel getDrawingModel() const = 0;
56  virtual void* getDrawingPrimitive() const = 0;
57  virtual WindowRef getWindowRef() const = 0;
58 
59  bool getShowDrawingModel() const { return m_drawLabel; }
60  void setShowDrawingModel(bool value) { m_drawLabel = value; }
61 
62  void setNpHost(FB::Npapi::NpapiBrowserHostPtr host) { m_npHost = host; }
63  void setPluginEvent(PluginEventMacPtr event) { m_PluginEvent = event; }
64  PluginEventMacPtr getPluginEvent() { return m_PluginEvent.lock(); }
65 
66  FB::Rect getWindowPosition() const;
67  uint32_t getWindowWidth() const;
68  uint32_t getWindowHeight() const;
69  FB::Rect getWindowClipping() const;
70 
79  virtual int scheduleTimer(int interval, bool repeat);
80 
88  virtual void unscheduleTimer(int timerId);
89  // Handles a timer event
90  virtual void handleTimerEvent();
91 
92  protected:
93  Npapi::NpapiBrowserHostPtr m_npHost;
94  PluginEventMacWeakPtr m_PluginEvent;
95 
96  int32_t m_x;
97  int32_t m_y;
98  uint32_t m_width;
99  uint32_t m_height;
100 
101  int32_t m_clipTop;
102  int32_t m_clipLeft;
103  int32_t m_clipBottom;
104  int32_t m_clipRight;
105 
106  void* m_timer;
107  void* m_helper;
108  bool m_drawLabel;
109  };
110 };
111 
112 #endif // H_PLUGINWINDOWMAC