[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

3352.0. "Getting WB Screen info" by SMAUG::SPODARYK (Binary Throttle) Wed Jan 17 1990 10:50

    I've been working on an Amiga project for some time, and need
    a little help.  This might seem real easy, but I haven't found
    the proper information on how to do this.
    
    What's the best/easiest way to determine the Workbench Screen
    characteristics - width, height, bitplanes?  I thought I could open 
    a window on the workbench, and use it's screen pointer to get this.  
    Ie. something like
    
    struct Window *myWindow;
    code to open window 
    width = myWindow -> Screen -> Width;
    
    However, what I really get is width and height == -1.  
    I believe Intuition uses this to mean 'as large as possible'.
    
    I really need a way to do this, before opening the window.
    
    There was something else that I needed, but it escapes me at
    the moment.
    
    Thanks,
    
    -Steve
    
T.RTitleUserPersonal
Name
DateLines
3352.1WJG::GUINEAUEvery player gets a prize...Wed Jan 17 1990 11:049
I believe you start at the IntuitionBase pointer (from OpenLibrary() of
intuition.library) and follow the screen list to the one with the
"I'm the Workbench" bit set...

Does this help? I don't remember the specifics but it's in the Intuition
ROM Kernel manual.


John
3352.2Sounds rightSMAUG::SPODARYKBinary ThrottleWed Jan 17 1990 13:197
    Yes, this makes sense.  I'll have to do some more digging
    in my ancient ROM Kernel Manual (V1.0 + 1.1 additions, ouch!).
    
    Will there actually be a V1.4 full doc set, or will there
    be additions to V1.3?  I'd like to get a V1.3 set sometime.
    
    -Steve
3352.3late_night_hacking = SUCCESS;SMAUG::SPODARYKBinary ThrottleThu Jan 18 1990 01:1436
/*
 *  S Spodaryk 18-Jan-1989
 *
 *  Return information about the WorkBench screen.
 *
 *  This assumes that IntuitionBase is a valid return from the
 *     OpenLibrary( "intuition.library", REVISION ) call.
 *    
 */

void Get_Display_Statistics( long *width, long *height, long *planes )

{
    extern struct IntuitionBase *IntuitionBase;
    struct Screen *screen_ptr = IntuitionBase -> FirstScreen;

    *width  = 640;		/* establish some defaults */
    *height = 400;
    *planes = 2;

    while ( screen_ptr != NULL ) {   /*  we've got a screen */

	if ( (screen_ptr -> Flags & 0x000F) == WBENCHSCREEN ) {

	    *width  = screen_ptr -> Width;		/* found it */
	    *height = screen_ptr -> Height;
    	    *planes = screen_ptr -> BitMap.Depth;
	    break;
	}
	else {	  /* continue walking down the list of screens */

	    screen_ptr = screen_ptr -> NextScreen; 	
	}
    }
}
    
3352.4FROCKY::BALZERChristian Balzer DTN:785-1029Thu Jan 18 1990 05:078
    Re: .2
    
    If you can afford it, get the 1.3 stuff, it's really nice.
    You can bet that 1.4 will get it's own manual (all in good time).
    
    Regards,
    
    <CB>
3352.5Careful following them pointersTLE::RMEYERSRandy MeyersThu Jan 18 1990 14:1722
Re: .3

I believe that there is a function called GetScreenData() in the
graphics library (it might be in Intuition instead).  I'd recommend
using it instead.

The routine posted in .3 has two problems:

    1.  It will crash the system if another task closes a
	screen while this routine is walking the list of screens!

    2.	It stops when it finds the first WBENCHSCREEN.  There may
	be several if various (maybe even supported) hacks are used.

The first problem can be fixed by either calling Disable()/Enable()
around the loop, or by using the function LockIBase() (or something
like that).  LockIBase has the advantage that it only prevents
Intuition from modifying any data structures, which is all you need
in this case.

I don't know how to fix the second problem.  I hope Commodore got it
right in GetScreenData().
3352.6Thanks, what about this?SMAUG::SPODARYKBinary ThrottleThu Jan 18 1990 16:2636
    re: .4+.5
    
    Randy, thanks for the tips.  That's one reason why I posted the
    code.  If it was 100% correct then maybe it would be useful to
    someone else.  If not, I was hoping someone would point out
    the error of my ways.
    
    That code is only called once, and would probably work for 99.99% 
    of the time, but... I'll check into GetScreenData().
    
    As an aside...  I'm doing one other thing that is probably
    very illegal (but seemingly safe).  When I change a gadgets
    characteristics (for mutual exclusion) rather than just
    RefreshGadgets(), I use something like this ( w/error handling )
    
    void ImprovedRefreshGadgets( struct Gadget *gadget, long number )
    
    {
        struct Gadget *saved_gadget_ptr, *gadget_ptr = gadget;
    
        while ( number-- > 0 )  
            gadget_ptr = gadget_ptr -> NextGadget;
     
        saved_gadget_ptr =  gadget_ptr->NextGadget;  /* save next gadget */
        gadget_ptr->NextGadget = NULL;         /* temporarily trunc list */
        
        RefreshGadgets( gadget, window, etc );
        
        gadget_ptr->NextGadget = saved_gadget_ptr;  /* reset pointer */
    }
    
    This allows me to refresh a sub-portion of a gadget list, without
    having to redraw all 18 gadgets.  I'm not proud of it, but is
    this semi-acceptable?
    
    -Steve                                                          
3352.7Not in my ROM Kernal V2WHAMMY::SPODARYKBinary ThrottleThu Jan 18 1990 23:018
    re: GetScreenData();
    
    Could some kind soul post the info on this routine?  My doc set
    doesn't mention it.  
    
    Thanks again,
    
    Steve
3352.8RefreshGList()TLE::RMEYERSRandy MeyersFri Jan 19 1990 13:0513
Re: .6

Yep, as you suggested, playing with the gadget list yourself is
very naughty.   The manuals warn you never to alter any field
in a gadget directly.

It turns out there is a routine to do what you want.  RefreshGList()
is like RefreshGadgets except it takes a count of the number of
gadgets to refresh.

There were several "GList" routines added back in 1.1 or 1.2 to
replace the "Gadget" routines because of the problem of not being
able to specify the number of gadgets to operate upon.
3352.9Intuition RoutinesTLE::RMEYERSRandy MeyersFri Jan 19 1990 18:0997
Re: .7

>    Could some kind soul post the info on this routine?

It turns out that both of the following routines are in Intuition:

        GetScreenData -- Get copy of a screen data structure.

 
  
SYNOPSIS 
   Success = GetScreenData(Buffer, Size, Type, Screen ) 
    D0                      A0      D0    D1    A1
 
    BOOL   Success;
    CPTR   Buffer;
    USHORT Size;
    USHORT Type;
    struct Screen *Screen;
  
FUNCTION 
    This function copies into the caller's buffer data from a Screen structure
    Typically, this call will be used to find the size, title bar height, and
    other values for a standard screen, such as the Workbench screen.
 
    To get the data for the Workbench screen, one would call:
        GetScreenData(buff, sizeof(struct Screen), WBENCHSCREEN, NULL)
 
    NOTE: if the requested standard screen is not open, this function
    will have the effect of opening it.
  
INPUTS 
    Buffer = pointer to a buffer into which data can be copied
    Size   = the size of the buffer provided, in bytes
    Type   = the screen type, as specified in OpenWindow (WBENCHSCREEN,
        CUSTOMSCREEN, ...)
    Screen = ignored, unless type is CUSTOMSCREEN, which results only in
        copying 'size' bytes from 'screen' to 'buffer'
  
RESULT 
    TRUE if successful
    FALSE if standard screen of Type 'type' could not be opened.
  
BUGS 
  
SEE ALSO 
    OpenWindow()


    RefreshGList  --  Refresh (redraw) a chosen number of gadgets.

 
 
SYNOPSIS
    RefreshGList(Gadgets, Window, Requester, NumGad)
                 A0       A1      A2         D0
 
    struct Gadget *Gadget;
    struct Window *Window;
    struct Requester *Requester;
    SHORT  NumGad;
 
FUNCTION
    Refreshes (redraws) Gadgets in the Gadget List starting
    from the specified Gadget.  At most NumGad gadgets are redrawn.
    If NumGad is -1, all gadgets until a terminating NULL value
    in the NextGadget field is found will be refreshed, making this
    routine a superset of RefreshGadgets().
 
    The Requester variable can point to a Requester structure.  If 
    the first Gadget in the list has the REQGADGET flag set, the 
    Gadget list refers to Gadgets in a Requester and the Pointer 
    must necessarily point to a Window.  If these are not the Gadgets 
    of a Requester, the Requester argument may be NULL.  
 
    Be sure to see the RefreshGadgets() function description, as this
    function is simple an extension of that.
    
INPUTS
    Gadgets = pointer to the first in the list of Gadgets wanting refreshment
    Window = pointer to the Window containing the Gadget or its Requester
    Requester = pointer to a Requester (ignored if Gadget is not attached to
        a Requester).
    NumGad  = maximum number of gadgets to be refreshed.  A value of -1
      will cause all gadgets to be refreshed from Gadget to the
      end of the list.  A value of -2 will also do this, but if Gadget
      is a Requester Gadget (REQGADGET) ALL gadgets in the requester
      will be refreshed (this is a mode compatible with v1.1 
      RefreshGadgets().
 
RESULT
    None
 
BUGS
 
SEE ALSO
    RefreshGadgets()
3352.10thanks againSMAUG::SPODARYKBinary ThrottleSat Jan 20 1990 01:426
    Randy,
    
         Thanks very much for the info.  Are you going to go to the
    "Amigoid Luncheon" so I can buy you a beer?
    
    Steve
3352.11I like diet cokeTLE::RMEYERSRandy MeyersMon Jan 22 1990 03:415
Re: .10

I'd love to go, but unfortunately I have a 1pm meeting every Thursday
(and Marlboro is about an hour from Nashua).  Besides, you really
wouldn't make me drink a beer, would you?