changeset 8572:e17f262a02cd

display.cc: get info for windows and os x systems
author John W. Eaton <jwe@octave.org>
date Thu, 22 Jan 2009 13:10:20 -0500
parents 38ee7ce3bc7d
children da61d0f7ce0b
files src/ChangeLog src/display.cc
diffstat 2 files changed, 52 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Jan 22 12:02:03 2009 -0500
+++ b/src/ChangeLog	Thu Jan 22 13:10:20 2009 -0500
@@ -1,3 +1,8 @@
+2009-01-22  John W. Eaton  <jwe@octave.org>
+
+	* display.cc (display_info::init): Get info for Windows and OS X
+	systems.
+
 2009-01-22  Jaroslav Hajek  <highegg@gmail.com>
 
 	* pt-idx.cc (tree_index_expression::lvalue): Correct tmpi when seeing
--- a/src/display.cc	Thu Jan 22 12:02:03 2009 -0500
+++ b/src/display.cc	Thu Jan 22 13:10:20 2009 -0500
@@ -26,10 +26,17 @@
 
 #include <cstdlib>
 
-#if defined (HAVE_X_WINDOWS)
+#if defined (OCTAVE_USE_WINDOWS_API)
+#include <Windows.h>
+#elif defined (OCTAVE_USE_OS_X_API)
+#include <CGDirectDisplay.h>
+#include <CGDisplayConfiguration.h>
+#elif defined (HAVE_X_WINDOWS)
 #include <X11/Xlib.h>
 #endif
 
+
+
 #include "display.h"
 #include "error.h"
 
@@ -40,11 +47,47 @@
 {
 #if defined (OCTAVE_USE_WINDOWS_API)
 
-  warning ("code to find screen properties is missing");
+  HDC hdc = GetDC (0);
+
+  if (hdc)
+    {
+      dp = GetDeviceCaps (hdc, BITSPIXEL)
+
+      ht = GetDeviceCaps (hdc, VERTRES);
+      wd = GetDeviceCaps (hdc, HORZRES);
+
+      double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
+      double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
+
+      rx = wd * 25.4 / wd_mm;
+      ry = ht * 25.4 / ht_mm;
+    }
+  else
+    warning ("no graphical display found");
+
+#elif defined (OCTAVE_USE_OS_X_API)
 
-#elif defined (OCTAVE_USE_COCOA_API)  // FIXME -- what should this be called?
+  CGDirectDisplayID display = CGMainDisplayID ();
+
+  if (display)
+    {
+      dp = CGDisplayBitsPerPixel (display);
+
+      ht = CGDisplayPixelsHigh (display);
+      wd = CGDisplayPixelsWide (display);
+
+      CGSize sz_mm = CGDisplayScreenSize (display);
 
-  warning ("code to find screen properties is missing");
+      CGFloat ht_mm = sz_mm.height;
+      CGFloat wd_mm = sz_mm.width;
+
+      rx = wd * 25.4 / wd_mm;
+      ry = ht * 25.4 / ht_mm;
+
+      std::cerr << depth << " bit depth" << std::endl;
+    }
+  else
+    warning ("no graphical display found");
 
 #elif defined (HAVE_X_WINDOWS)