GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
display.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 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 Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_display_h)
24 #define octave_display_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 class Matrix;
31 
32 namespace octave
33 {
34  class
35  OCTINTERP_API
37  {
38  protected:
39 
40  display_info (void)
41  : m_ht (1), m_wd (1), m_dp (0),
42  m_rx (72), m_ry (72), m_dpy_avail (false), m_err_msg ()
43  {
44  init ();
45  }
46 
47  explicit display_info (const std::string& dpy_name)
48  : m_ht (1), m_wd (1), m_dp (0),
49  m_rx (72), m_ry (72), m_dpy_avail (false), m_err_msg ()
50  {
51  init (dpy_name);
52  }
53 
54  explicit display_info (bool query)
55  : m_ht (1), m_wd (1), m_dp (0),
56  m_rx (72), m_ry (72), m_dpy_avail (false), m_err_msg ()
57  {
58  init ("", query);
59  }
60 
61  explicit display_info (const std::string& dpy_name, bool query)
62  : m_ht (1), m_wd (1), m_dp (0),
63  m_rx (72), m_ry (72), m_dpy_avail (false), m_err_msg ()
64  {
65  init (dpy_name, query);
66  }
67 
68  public:
69 
70  static int height (void)
71  {
72  return instance_ok () ? instance->do_height () : 0;
73  }
74 
75  static int width (void)
76  {
77  return instance_ok () ? instance->do_width () : 0;
78  }
79 
80  static int depth (void)
81  {
82  return instance_ok () ? instance->do_depth () : 0;
83  }
84 
85  static double x_dpi (void)
86  {
87  return instance_ok () ? instance->do_x_dpi () : 0;
88  }
89 
90  static double y_dpi (void)
91  {
92  return instance_ok () ? instance->do_y_dpi () : 0;
93  }
94 
95  static bool display_available (void)
96  {
97  std::string msg;
98  return instance_ok () ? instance->do_display_available (msg) : false;
99  }
100 
101  static bool display_available (std::string& msg)
102  {
103  return instance_ok () ? instance->do_display_available (msg) : false;
104  }
105 
106  // To disable querying the window system for defaults, this function
107  // must be called before any other display_info function.
108  static void no_window_system (void)
109  {
110  instance_ok (false);
111  }
112 
113  private:
114 
116 
117  static void cleanup_instance (void) { delete instance; instance = nullptr; }
118 
119  // Height, width, and depth of the display.
120  int m_ht;
121  int m_wd;
122  int m_dp;
123 
124  // X- and Y- Resolution of the display in dots (pixels) per inch.
125  double m_rx;
126  double m_ry;
127 
129 
131 
132  int do_height (void) const { return m_ht; }
133  int do_width (void) const { return m_wd; }
134  int do_depth (void) const { return m_dp; }
135 
136  double do_x_dpi (void) const { return m_rx; }
137  double do_y_dpi (void) const { return m_ry; }
138 
140  {
141  msg = m_err_msg;
142 
143  return m_dpy_avail;
144  }
145 
146  void init (const std::string& dpy_name = "", bool query = true);
147 
148  static bool instance_ok (bool query = true);
149  };
150 }
151 
152 #endif
display_info(const std::string &dpy_name)
Definition: display.h:47
bool do_display_available(std::string &msg) const
Definition: display.h:139
static display_info * instance
Definition: display.h:115
static bool display_available(void)
Definition: display.h:95
int do_height(void) const
Definition: display.h:132
static double y_dpi(void)
Definition: display.h:90
double do_x_dpi(void) const
Definition: display.h:136
static void no_window_system(void)
Definition: display.h:108
static int height(void)
Definition: display.h:70
static double x_dpi(void)
Definition: display.h:85
is false
Definition: cellfun.cc:400
Definition: dMatrix.h:36
std::string m_err_msg
Definition: display.h:130
static int width(void)
Definition: display.h:75
static void cleanup_instance(void)
Definition: display.h:117
double do_y_dpi(void) const
Definition: display.h:137
display_info(const std::string &dpy_name, bool query)
Definition: display.h:61
int do_width(void) const
Definition: display.h:133
static int depth(void)
Definition: display.h:80
static bool display_available(std::string &msg)
Definition: display.h:101
int do_depth(void) const
Definition: display.h:134
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
display_info(bool query)
Definition: display.h:54