View previous topic :: View next topic |
Author |
Message |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Fri Mar 14, 2014 11:01 am Post subject: Same button, many functions. |
|
|
G'day, folks
Can ClearWin do this?
In a program such as Piriform's CCleaner the same button can assume many functions, according to the task selected.
For instance, without changing either its location or its appearance, it can successively denote 'Analyze', 'Cancel', 'Scan for issues', and 'Cancel scan'.
That certainly makes for very efficient use of window area, something I'd like to use in my programs. I was wondering if it's something that ClearWin could already achieve.
Eric |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Fri Mar 14, 2014 11:36 am Post subject: |
|
|
Yes. You attach a callback function to the button.
You need some mechanism to set a flag to indicate the response required then the callback can use the flag to carry out the selected task.
You can also change the text on the button depending on the flag by calling change_button_text@. For this you need to use %lc immediately after %bt or %bb or %tt. |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sat Mar 15, 2014 6:41 pm Post subject: Re: |
|
|
PaulLaidler wrote: | Yes. You attach a callback function to the button.
You need some mechanism to set a flag to indicate the response required then the callback can use the flag to carry out the selected task.
You can also change the text on the button depending on the flag by calling change_button_text@. For this you need to use %lc immediately after %bt or %bb or %tt. |
Thankyou Unfortunately I couldn't find any mention of the syntax for change_button_text@ in my manual's list of Library References (Chapter 27). The only 'change' items described are change_hypertext@ and change_pen@.
Thinking my manual could be out-of-date I checked at http://www.silverfrost.com/manuals/clearwin.pdf but couldn't find any mention there, either.
change_button_text@ sounds exactly what I need. Would you mind posting the syntax for this very useful operation? Thanks, in advance
Eric |
|
Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Sat Mar 15, 2014 8:17 pm Post subject: |
|
|
At the risk of stating the obvious, you only get one callback function per button, and you need to keep a tally of which caption is on the button at any moment in time, and the callback has to address all possibilities.
The Windows User Interface Guidelines say "Don't do it", but then Microsoft doesn't obey its own rules!
As well as the printed documentation, you also need to refer to FTN95.CHM, and one of my personal favourites for unexpected gems, the cwplus.enh file (in the docs folder of ftn95) - this gives a list of enhancements to Clearwin+ over many years. Read it and you'll discover lots of things!
Eddie |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sat Mar 15, 2014 8:22 pm Post subject: Re: |
|
|
Yes, that looks to be remarkably close to what I'm looking for Thankyou, Wilfried!
It also highlights that I need the Clearwin+ Users Guide, not just the manual.
Thanks again
Eric |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sat Mar 15, 2014 8:28 pm Post subject: Re: |
|
|
LitusSaxonicum wrote: |
As well as the printed documentation, you also need to refer to FTN95.CHM, and one of my personal favourites for unexpected gems, the cwplus.enh file (in the docs folder of ftn95) - this gives a list of enhancements to Clearwin+ over many years. Read it and you'll discover lots of things!
Eddie |
Looks like I have a voyage of discovery ahead of me Many thanks, Eddie!
Eric |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sat Mar 15, 2014 9:17 pm Post subject: Constant-size button |
|
|
An interesting footnote to the change_button_text discussion is that the compiler, or whatever, can 'sense' in advance what will be the longest text string.
It's my casual observation, post-discussion, that the button size (width) is unchanged as the length of the text string varies.
Eric |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sun Mar 16, 2014 9:43 am Post subject: |
|
|
Yes. When you change the button text dynamically, the button size will not change automatically. But there are functions to move the button and change its size.
The simplest way would be to compile using the button text that is longest and then change to the desired start up text using change_button_text@ within a %sc callback. The button will then be big enough for every case and the text will be automatically centred in the button. |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sun Mar 16, 2014 11:24 am Post subject: Re: |
|
|
Thankyou
PaulLaidler wrote: | ... But there are functions to move the button and change its size... |
That reminds me of a 'survey' in which every choice (button) except one did a random jump to a new location whenever the mouse was hovered over it
Seriously, though, consider a program which is compiled with the longest button text. Now, to be effective, where in relation to %bt should %sc be placed? %sc BEFORE %bt or %sc AFTER %bt
Eric |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Sun Mar 16, 2014 1:10 pm Post subject: |
|
|
Eric,
It doesn't matter, although for organisational reasons I usually start with anything to do with style, then follow with %sc and the variants of %cc (%cc and %`cc) before getting round to layout and controls. Indeed, I usually put all the 'style' format codes in a subroutine and call that immediately after %ca so that all my windows have common attributes which I get hold of in one line (although if you like lots of format codes in one line you do it as you see fit). My personal experience is that too many format codes in one line make the source look ugly and difficult to follow.
Also in my experience, different button styles (%bt, %tt, %bb etc) have different width-sizing rules, and some of them have bigger size jumps than others. If you want a lot all the same width you need to think carefully. One way to make %bt buttons all the same size is to specify the size on each e.g. %6bt and also make use of %ob[invisible] ... %cb to get them to line up vertically.
Eddie |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Mon Mar 17, 2014 1:36 am Post subject: Re: |
|
|
LitusSaxonicum wrote: | ... make the source look ugly and difficult to follow.
|
Thankyou Eddie
The term 'self-documenting' comes to mind, but I get your point. It's important to remember that more than an inanimate compiler may want to understand what we've written.
Eric |
|
Back to top |
|
 |
|