GNU Octave  4.2.1
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-2017 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 "octave-config.h"
27 
28 #include <string>
29 
30 class Matrix;
31 
32 class
35 {
36 protected:
37 
38  display_info (bool query = true)
39  : ht (1), wd (1), dp (0), rx (72), ry (72), dpy_avail (false),
40  err_msg ()
41  {
42  init (query);
43  }
44 
45 public:
46 
47  static int height (void)
48  {
49  return instance_ok () ? instance->do_height () : 0;
50  }
51 
52  static int width (void)
53  {
54  return instance_ok () ? instance->do_width () : 0;
55  }
56 
57  static int depth (void)
58  {
59  return instance_ok () ? instance->do_depth () : 0;
60  }
61 
62  static double x_dpi (void)
63  {
64  return instance_ok () ? instance->do_x_dpi () : 0;
65  }
66 
67  static double y_dpi (void)
68  {
69  return instance_ok () ? instance->do_y_dpi () : 0;
70  }
71 
72  static bool display_available (void)
73  {
74  std::string msg;
75  return instance_ok () ? instance->do_display_available (msg) : false;
76  }
77 
78  static bool display_available (std::string& msg)
79  {
80  return instance_ok () ? instance->do_display_available (msg) : false;
81  }
82 
83  // To disable querying the window system for defaults, this function
84  // must be called before any other display_info function.
85  static void no_window_system (void)
86  {
87  instance_ok (false);
88  }
89 
90 private:
91 
93 
94  static void cleanup_instance (void) { delete instance; instance = 0; }
95 
96  // Height, width, and depth of the display.
97  int ht;
98  int wd;
99  int dp;
100 
101  // X- and Y- Resolution of the display in dots (pixels) per inch.
102  double rx;
103  double ry;
104 
105  bool dpy_avail;
106 
108 
109  int do_height (void) const { return ht; }
110  int do_width (void) const { return wd; }
111  int do_depth (void) const { return dp; }
112 
113  double do_x_dpi (void) const { return rx; }
114  double do_y_dpi (void) const { return ry; }
115 
117  {
118  msg = err_msg;
119 
120  return dpy_avail;
121  }
122 
123  void init (bool query = true);
124 
125  static bool instance_ok (bool query = true);
126 };
127 
128 #endif
int do_height(void) const
Definition: display.h:109
bool do_display_available(std::string &msg) const
Definition: display.h:116
bool dpy_avail
Definition: display.h:105
static double y_dpi(void)
Definition: display.h:67
static int height(void)
Definition: display.h:47
display_info(bool query=true)
Definition: display.h:38
static int depth(void)
Definition: display.h:57
int do_depth(void) const
Definition: display.h:111
std::string err_msg
Definition: display.h:107
double rx
Definition: display.h:102
#define OCTINTERP_API
Definition: mexproto.h:69
static void cleanup_instance(void)
Definition: display.h:94
is false
Definition: cellfun.cc:398
double do_x_dpi(void) const
Definition: display.h:113
double do_y_dpi(void) const
Definition: display.h:114
Definition: dMatrix.h:37
static bool display_available(std::string &msg)
Definition: display.h:78
static void no_window_system(void)
Definition: display.h:85
static bool display_available(void)
Definition: display.h:72
double ry
Definition: display.h:103
int do_width(void) const
Definition: display.h:110
static display_info * instance
Definition: display.h:92
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:854
static int width(void)
Definition: display.h:52
static double x_dpi(void)
Definition: display.h:62