VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gvviewerwindowfactory.cpp
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 // gvviewerwindowfactory.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gtest.h"
23 #include "gvviewerwindow.h"
24 #include "gvviewerwindow_ansi.h"
25 #include "genvironment.h"
26 
27 #if GCONFIG_HAVE_X11
28 #include "gvviewerwindow_x.h"
29 #endif
30 
31 #if GCONFIG_HAVE_CURSES
32 #include "gvviewerwindow_curses.h"
33 #endif
34 
35 Gv::ViewerWindow * Gv::ViewerWindow::create( ViewerWindowHandler & window_handler , ViewerWindowConfig config , int dx , int dy )
36 {
37  std::string display = G::Environment::get( "DISPLAY" , "" ) ;
38 
39  if( display == "tty" || G::Test::enabled("viewer-window-tty") )
40  return new ViewerWindowAnsi( window_handler , config , dx , dy ) ;
41 
42  #if GCONFIG_HAVE_CURSES
43  if( display == "curses" || G::Test::enabled("viewer-window-curses") )
44  return new ViewerWindowCurses( window_handler , config , dx , dy ) ;
45  #endif
46 
47  #if GCONFIG_HAVE_X11
48  if( !display.empty() )
49  return new ViewerWindowX( window_handler , config , dx , dy ) ;
50  #endif
51 
52  #if GCONFIG_HAVE_CURSES
53  return new ViewerWindowCurses( window_handler , config , dx , dy ) ;
54  #else
55  return new ViewerWindowAnsi( window_handler , config , dx , dy ) ;
56  #endif
57 }
58 
59 /// \file gvviewerwindowfactory.cpp
static std::string get(const std::string &name, const std::string &default_)
Returns the environment variable value or the given default.
virtual void display(int dx, int dy, int channels, const char *, size_t)=0
Displays the given image.
An abstract base class for a viewer window.
static bool enabled()
Returns true if test features are enabled.
Definition: gtest.cpp:49
A configuration structure for Gv::ViewerWindow.
A pimple-pattern implementation class for Gv::ViewerWindow that uses ansi escape sequences.
A pimple-pattern implementation class for ViewerWindow that uses X11.
static ViewerWindow * create(Handler &, ViewerWindow::Config, int image_dx, int image_dy)
A factory function that returns a new'ed ViewerWindow.
A callback interface for Gv::ViewerWindow.
A pimple-pattern implementation class for ViewerWindow that uses curses.