00001 /* 00002 00003 Copyright (C) 2009-2012 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_display_h) 00024 #define octave_display_h 1 00025 00026 class Matrix; 00027 00028 class display_info 00029 { 00030 protected: 00031 00032 display_info (bool query = true) 00033 : ht (1), wd (1), dp (0), rx (72), ry (72) 00034 { 00035 init (query); 00036 } 00037 00038 public: 00039 00040 static int height (void) 00041 { 00042 return instance_ok () ? instance->do_height () : 0; 00043 } 00044 00045 static int width (void) 00046 { 00047 return instance_ok () ? instance->do_width () : 0; 00048 } 00049 00050 static int depth (void) 00051 { 00052 return instance_ok () ? instance->do_depth () : 0; 00053 } 00054 00055 static double x_dpi (void) 00056 { 00057 return instance_ok () ? instance->do_x_dpi () : 0; 00058 } 00059 00060 static double y_dpi (void) 00061 { 00062 return instance_ok () ? instance->do_y_dpi () : 0; 00063 } 00064 00065 // To disable querying the window system for defaults, this function 00066 // must be called before any other display_info function. 00067 static void no_window_system (void) 00068 { 00069 instance_ok (false); 00070 } 00071 00072 private: 00073 00074 static display_info *instance; 00075 00076 static void cleanup_instance (void) { delete instance; instance = 0; } 00077 00078 // Height, width, and depth of the display. 00079 int ht; 00080 int wd; 00081 int dp; 00082 00083 // X- and Y- Resolution of the display in dots (pixels) per inch. 00084 double rx; 00085 double ry; 00086 00087 int do_height (void) const { return ht; } 00088 int do_width (void) const { return wd; } 00089 int do_depth (void) const { return dp; } 00090 00091 double do_x_dpi (void) const { return rx; } 00092 double do_y_dpi (void) const { return ry; } 00093 00094 void init (bool query = true); 00095 00096 static bool instance_ok (bool query = true); 00097 }; 00098 00099 #endif