29 #if defined (OCTAVE_USE_WINDOWS_API)
31 #elif defined (HAVE_FRAMEWORK_CARBON)
32 #include <Carbon/Carbon.h>
33 #elif defined (HAVE_X_WINDOWS)
47 #if defined (OCTAVE_USE_WINDOWS_API)
53 *dp = GetDeviceCaps (hdc, BITSPIXEL);
55 *ht = GetDeviceCaps (hdc, VERTRES);
56 *wd = GetDeviceCaps (hdc, HORZRES);
58 double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
59 double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
61 *rx = *wd * 25.4 / wd_mm;
62 *ry = *ht * 25.4 / ht_mm;
67 msg =
"no graphical display found";
69 #elif defined (HAVE_FRAMEWORK_CARBON)
71 CGDirectDisplayID display = CGMainDisplayID ();
75 #if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
77 *dp = CGDisplayBitsPerPixel (display);
84 CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display);
85 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode);
87 if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0)
89 else if (CFStringCompare (pixelEncoding,
90 CFSTR (IO16BitDirectPixels), 0) == 0)
97 *ht = CGDisplayPixelsHigh (display);
98 *wd = CGDisplayPixelsWide (display);
100 CGSize sz_mm = CGDisplayScreenSize (display);
106 double ht_mm = sz_mm.height;
107 double wd_mm = sz_mm.width;
109 *rx = *wd * 25.4 / wd_mm;
110 *ry = *ht * 25.4 / ht_mm;
115 msg =
"no graphical display found";
117 #elif defined (HAVE_X_WINDOWS)
119 const char *display_name = getenv (
"DISPLAY");
121 if (display_name && *display_name)
123 Display *display = XOpenDisplay (display_name);
127 Screen *screen = DefaultScreenOfDisplay (display);
131 *dp = DefaultDepthOfScreen (screen);
133 *ht = HeightOfScreen (screen);
134 *wd = WidthOfScreen (screen);
136 int screen_number = XScreenNumberOfScreen (screen);
138 double ht_mm = DisplayHeightMM (display, screen_number);
139 double wd_mm = DisplayWidthMM (display, screen_number);
141 *rx = *wd * 25.4 / wd_mm;
142 *ry = *ht * 25.4 / ht_mm;
145 msg =
"X11 display has no default screen";
147 XCloseDisplay (display);
152 msg =
"unable to open X11 DISPLAY";
155 msg =
"X11 DISPLAY environment variable not set";
159 msg =
"no graphical display found";
An image of characters with associated attributes.
const char * octave_get_display_info(int *ht, int *wd, int *dp, double *rx, double *ry, int *dpy_avail)