Screen size detection

Screen size detection

Post by James C » Sun, 03 Dec 1995 04:00:00



I am in need of finding the screen dimensions, number of bitplanes etc for the
screen, however, without using the VDI...

This question could probable be read: How does the VDI figure out the screen
size/number of bitplanes etc.. given the fact that there are such things as
17" SVGA monitors, Screenblaster hardware, virtual screens, and
reflex/supernova graphics card (etc, etc, etc..)

Cheers,


 
 
 

Screen size detection

Post by Graham Hint » Sun, 03 Dec 1995 04:00:00




>I am in need of finding the screen dimensions, number of bitplanes etc for the
>screen, however, without using the VDI...

>This question could probable be read: How does the VDI figure out the screen
>size/number of bitplanes etc.. given the fact that there are such things as
>17" SVGA monitors, Screenblaster hardware, virtual screens, and
>reflex/supernova graphics card (etc, etc, etc..)

The following two C functions show you how to find the screen size and open
a window centred in it in GEM taking into account all of the above. Pure C
is recommended.

/*************************************************************************/

void    Size_Screen ( void )
        {
        /* find the usable size of the AES screen */
        /* this may be real or virtual so never make assumptions */

        wind_get ( 0, WF_WORKXYWH,              /* !! not vhandle; work area of Desktop */
                                &desksize.g_x, &desksize.g_y,
                                &desksize.g_w, &desksize.g_h );

        /* got the desktop size , so calculate the maximum window work size */
        /* by requesting the work area from desktop area */
        /* N.B. the desktop is a window with no border, just an information field
                        that is used for the program name and then the optional menu.
                Nobody ever said that it fills the screen even though it normally
does! */

        wind_calc ( WC_WORK, wtype,
                                desksize.g_x, desksize.g_y, desksize.g_w, desksize.g_h,
                                &wmax.g_x, &wmax.g_y, &wmax.g_w, &wmax.g_h );
        }

/**************************************************************************/

BOOLEAN Open_Window ( void )
        {
        long scr;

        if ( whandle != 0 )     return FALSE;           /* already open */

        /* fit window size to resource form */

        wsize.g_x = wsize.g_y = 0;                              /* top left for calculations below */
        wsize.g_w = panel[ BOX ].ob_width;
        wsize.g_h = panel[ BOX ].ob_height;;

        /* request border size from tree size */

        wind_calc( WC_BORDER, wtype,
                                wsize.g_x, wsize.g_y, wsize.g_w, wsize.g_h,
                                &wstart.g_x, &wstart.g_y, &wstart.g_w, &wstart.g_h      );

        if ( work_out[13] > 4 )                                      /* 3D colour resources */
                {
                wstart.g_w -= 10;                                       /* remove 3D borders from box */
                wstart.g_h -= 10;
                }

        /*  default: centre window in desktop work area */

        wstart.g_x = ((desksize.g_w - wstart.g_w)/2) + desksize.g_x; /* offset =
half border */
        wstart.g_y = ((desksize.g_h - wstart.g_h)/2) + desksize.g_y;

        if ( getcookie( VSCR, &scr ) )                      /*      check for Virtual Screen cookie  */
                {
                INFOVSCR *vs;

                vs = (INFOVSCR*)scr;
                if ( (vs->cookie != 0) && (vs->version == 0x0100) )       /* enabled and
correct version */
                        {
                        /* centre window in physical screen area */

                        wstart.g_x = ((vs->w - wstart.g_w)/2) + vs->x;
                        wstart.g_y = ((vs->h - wstart.g_w)/2) + vs->y;
                        }
                }

        whandle = wind_create( wtype, wstart.g_x, wstart.g_y, wstart.g_w,
wstart.g_h );

        if ( whandle < 0 )           /* error? no more windows */
                {
                do_alert( 1, rs_frstr[ WINDOW ] );
                return ( FALSE );
                }

        /* now set its title  */
        /* !! must be done before opening due to (another) GEM bug */

        wind_set( whandle, WF_NAME, windowname, 0, 0 );

        /* now actually show it by opening */

        wind_open( whandle, wstart.g_x, wstart.g_y, wstart.g_w, wstart.g_h );

        /* recalculate & store actual work area */

        wind_get( whandle, WF_WORKXYWH, &wsize.g_x, &wsize.g_y, &wsize.g_w,
&wsize.g_h );
        top_window = whandle;
        return ( TRUE );
        }

/**************************************************************************/