Page 1 of 2

EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 12:25 am
by Giorgio Garabello
When you draw a menu with Easymenu, that design is the minimum size of the menu.
I can not make it smaller by SBASIC, using MDRAW command.
Now, is there any way to read this minimum size of the menu? The manual I could not find anything useful, but my English is bad and probably escaped me.

Thanks in advanced

Giorgio

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 7:30 am
by tofro
Giorgio,

to my knowledge, there is no S*BASIC command to retrieve menu sizes. You should, however, be able to install the menu using MSETUP, get its address using MWDEF and then PEEK_W the sizes directly from the menu definition.

Window size (width and height) and desired origin are the first two words after the header block in the working definition (offset $20 and $22). Note this is the inner size of the window, i.e. without taking account of the border width. Have a look into the QPTR manual to find the structure of a window working definition.

Tobias

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 12:22 pm
by Giorgio Garabello
Maybe I can use the command MSETUP ?
PVAL of the command values ​​are already ' updated or are updated only after the MDRAW command ?
( I do not QPTR )

Giorgio

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 1:41 pm
by tofro
Giorgio,

surely you can (and should) use MSETUP. MDRAW will try to draw the menu. If you, for example, want to find out whether the menu is too large for the current screen resolution, that will already be too late and your program will have stopped with an error message "OUT OF RANGE" already... Note, to my knowledge, neither MDRAW nor MSETUP will fill the pointer array retrieved with PVAL with any useful value. That is not done until MCALL is called.

Something along the lines of the following should work (just checked - seems to work):

Code: Select all

1000 MSETUP #ch,menu_name$
1010 wwdef = MWDEF(#ch)
1020 width = PEEK_W (wwdef + 32)
1030 height = PEEK_W (wwdef + 34)
Note you might want to do this on a dummy channel opened with FOPEN - If you do it with #0, any other attempt to MSETUP or MDRAW a menu to #0 will be rejected with an "Already exists" error message. The dummy channel you simply CLOSE.

Tobias

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 10:27 pm
by Giorgio Garabello
this solution does not work or, rather, does not do what it takes to me.
the two values that returns are the current size to me instead need to know what 's the minimum possible size of a menu.
This information must be somewhere, because when seeking to reduce the size of the finetra never goes below a certain extent.

Giorgio

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 10:55 pm
by tofro
What you get with this method is the preferred size of the window - i.e the one it would open initially. The minimum size of a window as you refer to it is not part of the window working definition - It is determined by the resizing code setting a minimum limit and and cannot be easily PEEKed from somewhere (Simply, because it's in code and not in data).

This is valid for freely scalable windows. "Old-style" window definitions could only define multiple differently sized, preconfigured and non-scalable layouts. The Pointer Environment would choose the one it thinks fits best to your screen resolution. The size of window definitions that contain multiple layouts cannot, to my knowledge, retrieved with EasyPtr from the window definition. EasyPtr gives you access to the window working definition, the multiple layouts form the window definition - EasyPtr doesn't have a function to return the latter one.

So, what I have given you above is probably the best you can get without re-engineering the EasyPtr file format.

Tobias

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 11:09 pm
by Giorgio Garabello
I do not think so.
Each time you resize the window gives me a different pair of values; if they were the preferred size should have the constant values ...

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 11:11 pm
by tofro
Maybe I was not clear enough - It's the size the window was defined with and the size the window will open initially - As soon as it's on screen and you resize the window, it will follow the change.

Tobias

Re: EASYPTR4 - Minimum menu size

Posted: Fri Aug 05, 2016 11:15 pm
by Giorgio Garabello
tofro wrote:Maybe I was not clear enough - It's the size the window was defined with and the size the window will open initially - As soon as it's on screen and you resize the window, it will follow the change.

Tobias
OK.. now is clear...

thanks

Giorgio

Re: EASYPTR4 - Minimum menu size

Posted: Sat Aug 06, 2016 2:40 pm
by pjw
Hi Giorgio,

I sent a reply to ql-users, but it takes forever for my mails to arrive there, so I'll copy it here, in case you need this info now:

Well, then you need to PEEK the window definition [WD] rather than the window working definition [WWD]. EasyPtr prepends its own header to the WD. I think its always 28b long, in which case the standard/minimum size can be found at

WD = APPA(<menu name>)
minx = PEEK_W(WD + 28): miny = PEEK_W(WD + 30)

This is not a universal formula, mind you, as more than one layout may be defined (the menu designer will know). However, I'll leave that as an excercise for now.. Check out the excellent QPTR manual for details, and use EasySource to dissemble your EasyMen menus.

Per