VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gxpixmap.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 gxpixmap.h
19 ///
20 
21 #ifndef GX_PIXMAP_H
22 #define GX_PIXMAP_H
23 
24 #include "gdef.h"
25 #include "gxdef.h"
26 #include "gxdrawable.h"
27 #include <memory>
28 
29 namespace GX
30 {
31  class Pixmap ;
32  class Display ;
33  class Image ;
34  class Window ;
35 }
36 
37 /// \class GX::Pixmap
38 /// A pixmap class for xserver-side images. Inherits line-drawing
39 /// from its Drawable base class.
40 ///
41 class GX::Pixmap : public GX::Drawable
42 {
43 public:
44  Pixmap( Display & , GX::Window & window , int dx = 0 , int dy = 0 ) ;
45  ///< Constructor. The display reference is kept.
46 
47  ~Pixmap() ;
48  ///< Destructor.
49 
50  ::Pixmap x() ;
51  ///< Returns the X object.
52 
53  virtual ::Drawable xd() ;
54  ///< From Drawable.
55 
56  void blit( GX::Window & , int src_x , int src_y , int dx , int dy , int dst_x , int dst_y ) ;
57  ///< Blits to a window. Uses the display's default
58  ///< graphics context.
59 
60  int dx() const ;
61  ///< Returns the width.
62 
63  int dy() const ;
64  ///< Returns the height.
65 
66  void clear() ;
67  ///< Draws a big rectangle to clear the pixmap.
68 
69  void readImage( unique_ptr<Image> & ) const ;
70  ///< Reads the image from the xserver. (This is not in
71  ///< the base class because reading window images is
72  ///< less reliable wrt. occlusion etc.)
73 
74 private:
75  Pixmap( const Pixmap & ) ;
76  void operator=( const Pixmap & ) ;
77  void blit( GX::Window & , Context & , int src_x , int src_y , int dx , int dy , int dst_x , int dst_y ) ;
78 
79 private:
80  Display & m_display ;
81  ::Pixmap m_pixmap ;
82  int m_dx ;
83  int m_dy ;
84 } ;
85 
86 #endif
A window class that is-a GX::Drawable and a GX::EventHandler.
Definition: gxwindow.h:47
void readImage(unique_ptr< Image > &) const
Reads the image from the xserver.
Definition: gxpixmap.cpp:89
::Pixmap x()
Returns the X object.
Definition: gxpixmap.cpp:55
~Pixmap()
Destructor.
Definition: gxpixmap.cpp:44
Pixmap(Display &, GX::Window &window, int dx=0, int dy=0)
Constructor. The display reference is kept.
Definition: gxpixmap.cpp:32
An Xlib Display wrapper.
Definition: gxdisplay.h:38
void blit(GX::Window &, int src_x, int src_y, int dx, int dy, int dst_x, int dst_y)
Blits to a window.
Definition: gxpixmap.cpp:75
A pixmap class for xserver-side images.
Definition: gxpixmap.h:41
int dx() const
Returns the width.
Definition: gxpixmap.cpp:65
virtual ::Drawable xd()
From Drawable.
Definition: gxpixmap.cpp:60
void clear()
Draws a big rectangle to clear the pixmap.
Definition: gxpixmap.cpp:100
An Xlib GC wrapper.
Definition: gxcontext.h:37
int dy() const
Returns the height.
Definition: gxpixmap.cpp:70
An abstract base class for xserver-side drawables (windows, pixmaps, etc) with methods for drawing po...
Definition: gxdrawable.h:38