From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Perfecting my checkbox functionalities
Date: Fri, 10 Sep 2010 18:00:00 +0200 [thread overview]
Message-ID: <69FD6C90-67F8-4F94-B461-7877DB5EB46A@gmail.com> (raw)
In-Reply-To: <87iq2ekoq4.fsf@linux-lqcw.site>
Am 10.09.2010 um 10:05 schrieb Cecil Westerhof:
> I am learning to work with ConTeXt. At the moment I have the following
> defined:
I guess we need a context programmers guide.
> \newdimen\CheckBoxMargin
> \CheckBoxMargin=2em
> \newdimen\CheckBoxWidth
> \CheckBoxWidth=2.5em
> \newdimen\CheckBoxDistance
> \CheckBoxDistance=.5em
Get rid of this stuff and use a setup command:
\def\setupCheckBox
{\dodoubleargument\getrawparameters[CheckBox]}
\setupCheckBox
[Margin=2em,
Width=2.5em,
Distance=.5em]
> \definesymbol[CheckBox][{[~~~]}]
> \def\startcheckbox[#1]{
> \blank
> \leftaligned{#1}
> \startitemize[packed, intro, joinedup][margin=\CheckBoxMargin,
> symbol=CheckBox, width=\CheckBoxWidth,
> distance=\CheckBoxDistance]
> }
>
> \def\stopcheckbox{
> \stopitemize
> \blank
> \crlf
> }
Brr, latex style. Why \crlf at the end of \stopcheckbox, to get a bigger space use \blank[...].
> \def\GetNiveauOfService[#1]{
> \blank
> #1 {\switchtobodyfont[0.5em](1 = low, 9 = high)}
> \startitemize[packed, intro, joinedup, columns][n=9,
> symbol=CheckBox, width=\CheckBoxWidth,
> distance=\CheckBoxDistance]
> \dorecurse{9}{
> \item \recurselevel
> }
> \stopcheckbox
> }
\def\GetNiveauOfService
{\dodoubleempty\doGetNiveauOfService}
\def\doGetNiveauOfService[#1][#2]%
{\blank
#1 {\switchtobodyfont[0.5em]\doifsomethingelse{#2}{#2}{(1 = \translate[en=low,nl=weinig], 9 = \translate[en=high,nl=veel])}}
\startitemize[packed,intro,joinedup,columns][n=9,symbol=CheckBox, width=\CheckBoxWidth,distance=\CheckBoxDistance]
\dorecurse{9}{\item \recurselevel}
\stopitemize}
> I have a few questions about this.
>
> In GetNiveauOfService 9 is used three times. I like DRY, so I was
> wondering if there would be a better way to do this?
???
(Note: I switched your following two questions)
> Lastly, in GetNiveauOfService there is text. How can I make this
> language dependent. For example in English I want:
> (1 = low, 9 = high)
> but in Dutch:
> (1 = weinig, 9 = veel)
> and properly it would be a good idea to have two optional parameters
> when you want other descriptions.
> How would I do this?
See my version of the command, there is a second optional argument which
can be used to set a alternative text.
> Next step would be that the number of checkboxes could be a parameter.
> The default would be nine and if given, the given value would be used.
> How would I do this?
>
> Then the 'normal' checkboxes. The default is one column. But I would
> like to have the possibility to use a parameter to for example make
> checkboxes in three columns. How would I do this?
For the last question i showed you how you can use a optional parameter
to set alternative text but as you want more and more parameter you
should first think about the interface for you commands (e.g. key-value
makes more sense than lots of text arguments because you can’t make
all of them optional in this case.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2010-09-10 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-10 8:05 Cecil Westerhof
2010-09-10 16:00 ` Wolfgang Schuster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69FD6C90-67F8-4F94-B461-7877DB5EB46A@gmail.com \
--to=schuster.wolfgang@googlemail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).