FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
PluginWindowlessWin.h
1 #ifndef H_PLUGINWINDOWLESSWIN
2 #define H_PLUGINWINDOWLESSWIN
3 
4 /**********************************************************\
5 Original Author: Anson MacKeracher (amackera)
6 
7 Created: Aug 5, 2010
8 License: Dual license model; choose one of two:
9  New BSD License
10  http://www.opensource.org/licenses/bsd-license.php
11  - or -
12  GNU Lesser General Public License, version 2.1
13  http://www.gnu.org/licenses/lgpl-2.1.html
14 
15 Copyright 2010 Anson MacKeracher, Firebreath development team
16 \**********************************************************/
17 
18 #include "win_common.h"
19 #include "PluginWindow.h"
20 
21 #include <boost/function.hpp>
22 #include <boost/scoped_ptr.hpp>
23 
24 #include "Win/KeyCodesWin.h"
25 #include "Win/WindowContextWin.h"
26 
27 namespace FB {
40  {
41  public:
42  PluginWindowlessWin(const WindowContextWindowless&);
44 
45  typedef boost::function<void (uint32_t, uint32_t, uint32_t, uint32_t)> InvalidateWindowFunc;
46 
55  HDC getHDC() const { return m_hdc; }
56  void setHDC(HDC hdc) { m_hdc = hdc; }
57  void setHWND(HWND browserHwnd) { m_browserHwnd = browserHwnd; }
58  void setInvalidateWindowFunc(InvalidateWindowFunc func) { m_invalidateWindow = func; }
59  HWND getHWND() const { return m_browserHwnd; }
60 
61  FB::Rect getWindowPosition() const;
62  void setWindowPosition(int32_t x, int32_t y, uint32_t width, uint32_t height);
63 
64  FB::Rect getWindowClipping() const;
65  void setWindowClipping(int32_t top, int32_t left, int32_t bottom, int32_t right);
66  void setWindowClipping(FB::Rect clip);
67 
68  uint32_t getWindowWidth() const { return m_width; }
69  uint32_t getWindowHeight() const { return m_height; }
70 
71  // Converts window-space coordinates into plugin-place coordinates
72  void translateWindowToPlugin(int32_t &x, int32_t &y) const;
73 
74  // Handle event given to us from NPAPI (windowless plugins don't intercept raw Windows events)
75  bool HandleEvent(uint32_t event, uint32_t wParam, uint32_t lParam, LRESULT& lRes);
76 
77  // Handle draw event specially, since it needs draw bounds
78  bool HandleDraw(HDC dc, FB::Rect bounds);
79 
80  // Invalidate the window (Call from any thread)
81  void InvalidateWindow() const;
82 
83  AsyncDrawServicePtr getAsyncDrawService() const;
84 
85  protected:
86  HDC m_hdc;
87  HWND m_browserHwnd;
88  int32_t m_x, m_y;
89  uint32_t m_width, m_height;
90  int32_t m_clipTop, m_clipLeft, m_clipBottom, m_clipRight;
91  InvalidateWindowFunc m_invalidateWindow;
92  AsyncDrawServicePtr m_asyncDraw;
93  };
94 };
95 
96 #endif
97 
Windows specific implementation of PluginWindow.
uint32_t getWindowHeight() const
Gets the height of the window.
void InvalidateWindow() const
Invalidate window. This should tell the OS to send a REFRESH event.
PluginWindow is the base class for all PluginWindow objects.
Definition: PluginWindow.h:33
FB::Rect getWindowPosition() const
Gets the position rect of the window.
FB::Rect getWindowClipping() const
Gets the clipping rect of the window.
HDC getHDC() const
Gets the HDC of the plugin window.
uint32_t getWindowWidth() const
Gets the width of the window.