Lumiera  0.pre.03
»edit your freedom«
video-display-widget.cpp
Go to the documentation of this file.
1 /*
2  VideoDisplayWidget - Implementation of the video viewer widget
3 
4  Copyright (C) Lumiera.org
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
30 #include "stage/gtk-base.hpp"
33 
34 #include "video-display-widget.hpp"
35 
36 namespace stage {
37 namespace widget {
38 
39  VideoDisplayWidget::VideoDisplayWidget()
40  : displayer_(NULL)
41  { }
42 
43 
44  VideoDisplayWidget::~VideoDisplayWidget()
45  {
46  if (displayer_) delete displayer_;
47  }
48 
49 
50  Displayer*
51  VideoDisplayWidget::getDisplayer() const
52  {
53  return displayer_;
54  }
55 
56 
57  void
58  VideoDisplayWidget::on_realize()
59  {
60  // invoke base implementation
61  Gtk::Widget::on_realize ();
62 
63  // Set colours
64  //modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("black"));
65 
66  if (displayer_) delete displayer_;
67  displayer_ = createDisplayer (this, 320, 240);
68 
69  add_events (Gdk::ALL_EVENTS_MASK);
70  }
71 
72 
73  Displayer*
74  VideoDisplayWidget::createDisplayer (Gtk::Widget *drawingArea, int width, int height)
75  {
76  REQUIRE (drawingArea != NULL);
77  REQUIRE (width > 0 && height > 0);
78 
79  Displayer *displayer = NULL;
80 
81  displayer = new XvDisplayer (drawingArea, width, height);
82  if (!displayer->usable())
83  {
84  delete displayer;
85  displayer = NULL;
86  }
87 
88  if (!displayer)
89  {
90  displayer = new GdkDisplayer (drawingArea, width, height);
92  }
93 
94  return displayer;
95  }
96 
97 
98 }}// stage::widget
Display video via GDK.
Widget to create a video display embedded into the UI.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
XvDisplayer is a class which is responsible for rendering a video image via XVideo.
Definition: xvdisplayer.hpp:62
virtual bool usable()
Indicates if this object can be used to render images on the running system.
Definition: displayer.cpp:47
A set of basic GTK includes for the UI.
Implementation of video output via XVideo.
A Displayer is a class which is responsible for rendering an image in some way (ie: Xvideo...
Definition: displayer.hpp:74
GdkDisplayer is a class which is responsible for rendering a video image via GDK. ...