VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gvviewerwindow_x.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gvviewerwindow_x.h
19 ///
20 
21 #ifndef GV_VIEWERWINDOW_X__H
22 #define GV_VIEWERWINDOW_X__H
23 
24 #include "gdef.h"
25 #include "gvviewerwindow.h"
26 #include "gvmask.h"
27 #include "gxeventloop.h"
28 #include "geventhandler.h"
29 #include "gxdisplay.h"
30 #include "gxwindow.h"
31 #include "gxcanvas.h"
32 
33 namespace Gv
34 {
35  class ViewerWindowX ;
36  class ViewerWindowXBase ;
37 }
38 
39 /// \class Gv::ViewerWindowXBase
40 /// A private base class for ViewerWindowX that initialises the display before
41 /// the window is created by the GX::Window base class.
42 ///
44 {
45 public:
47  GX::Display m_base_display ;
48  GX::EventLoop m_base_xloop ;
49 } ;
50 
51 /// \class Gv::ViewerWindowX
52 /// A pimple-pattern implementation class for ViewerWindow that uses X11.
53 ///
55 {
56 public:
58  ///< Constructor.
59 
60  virtual ~ViewerWindowX() ;
61  ///< Destructor.
62 
63  virtual void init() override ;
64  ///< Override from ViewerWindow.
65 
66  virtual void display( int , int , int , const char * , size_t ) override ;
67  ///< Override from ViewerWindow.
68 
69  virtual int dx() const override ;
70  ///< Override from ViewerWindow.
71 
72  virtual int dy() const override ;
73  ///< Override from ViewerWindow.
74 
75 private:
76  virtual void onChar( char ) override ; // GX::Window
77  virtual void onLeftMouseButtonDown( int x , int y , bool shift , bool control ) override ; // GX::Window
78  virtual void onLeftMouseButtonUp( int x , int y , bool shift , bool control ) override ; // GX::Window
79  virtual void onMouseMove( int x , int y ) override ; // GX::Window
80  virtual void onExpose( XExposeEvent & ) override ; // GX::Window
81  virtual void readEvent() override ; // GNet::EventHandler
82  virtual void onException( std::exception & ) override ; // GNet::EventHandler
83  void update( int , int , int , int , const unsigned char * , size_t ) ;
84  void update( int , int , int , int , int , const unsigned char * , size_t ) ;
85 
86 private:
87  GX::EventLoop & m_xloop ;
88  ViewerWindowHandler & m_window_handler ;
89  GX::Canvas m_canvas ;
90  ViewerWindowConfig m_config ;
91  int m_dx ;
92  int m_dy ;
93  Gv::Mask m_mask ;
94 } ;
95 
96 
97 inline
98 Gv::ViewerWindowXBase::ViewerWindowXBase() :
99  m_base_xloop(m_base_display)
100 {
101 }
102 
103 #endif
A window class that is-a GX::Drawable and a GX::EventHandler.
Definition: gxwindow.h:47
ViewerWindowX(ViewerWindowHandler &, ViewerWindowConfig, int dx, int dy)
Constructor.
Implements a binary mask over an image that can be edited by mouse actions, and that can be stored on...
Definition: gvmask.h:41
An event-loop class that delivers Xlib 'Display' events to GX::Window objects via their GX::EventHand...
Definition: gxeventloop.h:90
An Xlib Display wrapper.
Definition: gxdisplay.h:38
An abstract base class for a viewer window.
A private base class for ViewerWindowX that initialises the display before the window is created by t...
::Window x()
Returns the X object.
Definition: gxwindow.cpp:149
A configuration structure for Gv::ViewerWindow.
A base class for classes that handle asynchronous events from the event loop.
Definition: geventhandler.h:78
virtual int dy() const override
Override from ViewerWindow.
A pimple-pattern implementation class for ViewerWindow that uses X11.
virtual void init() override
Override from ViewerWindow.
A drawing surface that is embedded in a window.
Definition: gxcanvas.h:61
virtual ~ViewerWindowX()
Destructor.
virtual void display(int, int, int, const char *, size_t) override
Override from ViewerWindow.
A callback interface for Gv::ViewerWindow.
virtual int dx() const override
Override from ViewerWindow.