GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
display.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2015 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_display_h)
24 #define octave_display_h 1
25 
26 #include <string>
27 
28 class Matrix;
29 
30 class
33 {
34 protected:
35 
36  display_info (bool query = true)
37  : ht (1), wd (1), dp (0), rx (72), ry (72), dpy_avail (false),
38  err_msg ()
39  {
40  init (query);
41  }
42 
43 public:
44 
45  static int height (void)
46  {
47  return instance_ok () ? instance->do_height () : 0;
48  }
49 
50  static int width (void)
51  {
52  return instance_ok () ? instance->do_width () : 0;
53  }
54 
55  static int depth (void)
56  {
57  return instance_ok () ? instance->do_depth () : 0;
58  }
59 
60  static double x_dpi (void)
61  {
62  return instance_ok () ? instance->do_x_dpi () : 0;
63  }
64 
65  static double y_dpi (void)
66  {
67  return instance_ok () ? instance->do_y_dpi () : 0;
68  }
69 
70  static bool display_available (void)
71  {
72  std::string msg;
73  return instance_ok () ? instance->do_display_available (msg) : false;
74  }
75 
76  static bool display_available (std::string& msg)
77  {
78  return instance_ok () ? instance->do_display_available (msg) : false;
79  }
80 
81  // To disable querying the window system for defaults, this function
82  // must be called before any other display_info function.
83  static void no_window_system (void)
84  {
85  instance_ok (false);
86  }
87 
88 private:
89 
91 
92  static void cleanup_instance (void) { delete instance; instance = 0; }
93 
94  // Height, width, and depth of the display.
95  int ht;
96  int wd;
97  int dp;
98 
99  // X- and Y- Resolution of the display in dots (pixels) per inch.
100  double rx;
101  double ry;
102 
103  bool dpy_avail;
104 
105  std::string err_msg;
106 
107  int do_height (void) const { return ht; }
108  int do_width (void) const { return wd; }
109  int do_depth (void) const { return dp; }
110 
111  double do_x_dpi (void) const { return rx; }
112  double do_y_dpi (void) const { return ry; }
113 
114  bool do_display_available (std::string& msg) const
115  {
116  msg = err_msg;
117 
118  return dpy_avail;
119  }
120 
121  void init (bool query = true);
122 
123  static bool instance_ok (bool query = true);
124 };
125 
126 #endif
int do_height(void) const
Definition: display.h:107
bool do_display_available(std::string &msg) const
Definition: display.h:114
bool dpy_avail
Definition: display.h:103
static double y_dpi(void)
Definition: display.h:65
static int height(void)
Definition: display.h:45
display_info(bool query=true)
Definition: display.h:36
static int depth(void)
Definition: display.h:55
int do_depth(void) const
Definition: display.h:109
std::string err_msg
Definition: display.h:105
double rx
Definition: display.h:100
#define OCTINTERP_API
Definition: mexproto.h:66
static void cleanup_instance(void)
Definition: display.h:92
double do_x_dpi(void) const
Definition: display.h:111
double do_y_dpi(void) const
Definition: display.h:112
Definition: dMatrix.h:35
static bool display_available(std::string &msg)
Definition: display.h:76
static void no_window_system(void)
Definition: display.h:83
static bool display_available(void)
Definition: display.h:70
double ry
Definition: display.h:101
int do_width(void) const
Definition: display.h:108
static display_info * instance
Definition: display.h:90
static int width(void)
Definition: display.h:50
static double x_dpi(void)
Definition: display.h:60