forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Menu construction

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed Aug 31, 2016 2:22 am    Post subject: Menu construction Reply with quote

When constructing complex menus, the ability to continue a menu in a new winio@ call by following %mn (or %pm) with more than one [ is really helpful. It allows the programme to break the menu construction up into small parts. For example,
Code:
iw=winio@('%mn[Actions,[Continue,Stop]]','CONTINUE','STOP')

can be written as
Code:
iw=winio@('%mn[Actions,[Continue]]&','CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

However, it would be helpful to be able to break this down further to something like:
Code:
iw=winio@('%mn[Actions]&') ! NB callback intentionally left blank
iw=winio@('%mn[[Continue]]&','CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

The intention here is that the first line does not have a callback function because it only acts as a higher level menu item for Continue and Stop.
But such an option is unavailable for two reasons: (1) line 1 is invalid because a callback function is required, and (2) even if something like 'CONTINUE' is supplied, line two creates an error message. As potential (but unsuccessful) solutions, the following creates a second Actions menu item:
Code:
iw=winio@('%mn[Actions]&','CONTINUE')
iw=winio@('%mn[Actions[Continue]]&','CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

while the following creates a formatting error message at line 1:
Code:
iw=winio@('%mn[Actions[]]&','CONTINUE')
iw=winio@('%mn[[Continue]]&','CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

Could %mn take some kind of modifier to indicate that it should not have a callback function to make the following valid?
Code:
iw=winio@('%mn[Actions]&')
iw=winio@('%mn[[Continue]]&','CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

But perhaps there is a way to do this that I am missing?

The reason such an option would be valuable may be illustrated by the following example:
Code:
iw=winio@('%mn[~Actions[Continue]]&',igrey,'CONTINUE')
iw=winio@('%mn[[Stop]]','STOP')

Although this is a simple example, in a complex menu this first call can become fairly complicated. The complexity is not so much with the possibly long formatting code (by which I mean the first argument to winio@), but rather with the possibly intricate ordering of all the additional arguments that may be required before the actual callback function. (Although, with reference to another post I have on array arguments to %ga, if all these additional arguments could be supplied as an array rather than as individual scalars the complexity would be reduced somewhat.) In effect, I am looking for a way of constructing a complex menu without having to make the first line of code point all the way to the first callback.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Wed Aug 31, 2016 4:54 am    Post subject: Reply with quote

I may have missed your points, but I think some of what you want is already available. The following are examples of menu options I have for building a large multi-level menu. These are taken from separate subroutines that build the menu components. I think they are split as you suggest. I try to have a single menu item per call.
Code:
!
    i = winio@  ('%mn[&File[]]&' )
     i = winio@  ('%mn[[&Open Data]]&',                   open_data_func)    ! uses get_filtered_file p299
     i = winio@  ('%mn[[&Open Results]]&',                open_res_func)
     i = winio@  ('%mn[[&Open Report List]]&',            open_lis_func)
     i = winio@  ('%mn[[&Open Beam Section]]&',           open_beam_sec_func)
     i = winio@  ('%mn[[&Open Load Combination]]&',       open_load_comb_func)
     i = winio@  ('%mn[[&Close Report]]&',                close_func)
     i = winio@  ('%mn[[E&xit]]&',                        exit_func)
...
    i = winio@  ('%mn[~&Options[]]&',     on_run )
     i = winio@  ('%mn[[#number nodes]]&',                I_LJTNUM, select_JTNUM_func)
     i = winio@  ('%mn[[#number elements]]&',             I_LELNUM, select_ELNUM_func)
     i = winio@  ('%mn[[#number properties]]&',           I_LPRNUM, select_PRNUM_func)
     i = winio@  ('%mn[[#use local numbering]]&',         I_LLOCAL, select_LOCAL_func)
     i = winio@  ('%mn[[|,#draw nodes]]&',                I_LJTDRW, select_JTDRW_func)
     i = winio@  ('%mn[[#draw elements]]&',               I_LELDRW, select_ELDRW_func)
     i = winio@  ('%mn[[#draw undeformed elements]]&',    I_LUDDRW, select_UDDRW_func)
...
    i = winio@ ('%mn[~&Interupt]&',       on_stop,        detect_interupt_func)
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed Aug 31, 2016 7:03 am    Post subject: Reply with quote

Thank you, John. Your line 1 is exactly what I need. I thought I had been trying that, but must have had the syntax slightly incorrect.

Perhaps it would be useful to add to the help pages (the one called "Menu format - %mn[menu specification]") an indication that [] will not require a callback function.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Wed Aug 31, 2016 9:11 am    Post subject: Reply with quote

It is deeply fascinating to me to see other people wrestle with Clearwin format codes as I have done for many years and that they miss some, what now (but didn't always), seem obvious subtlety. It makes me wonder what I am still missing too. Lots probably.

I have found that the various parts of (particularly main) windows benefit from being spread over a number of subroutines: menus, toolbars, style settings/fonts etc, and sometimes more than one routine for each category. The critical thing is to remember to preserve the WINIO@ return path or you sometimes get errors on shutdown.

It helps to follow the often unwritten conventions: File menu on the left, Help on the right, and other menus (to a total of not more than 11 apparently) spread out for data creation/editing, analysing and results presentation.

The Windows UX guide suggests that menu names should be short, and John's examples repeat 'Open' and 'number', where I would use submenus with 'Open ...' and 'Number ...', and indeed, in the latter, would put tick boxes against 'element', 'nodes' and 'properties', and also follow the current capitalization rules. Sticking to the conventions makes the user experience much more familiar.

I have to say that even when I am the sole user of what I have written, I find that an unconventional interface eventually irritates me! Other users can be even more critical. Experience has also taught me how vital it is to put 'save your work' options on program and even Windows shutdown, with 'are you sure?' on a 'no' answer.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group