[Developers] How to name individual input fields of a uiGenInput
Jaap Glas
Jaap.Glas at dgb-group.com
Mon Apr 7 17:55:14 CEST 2008
Dear fellow developers,
How to name individual input fields of a uiGenInput
===================================================
In my last contribution to this forum, I urged you all to start assigning
meaningful object names when initializing user interface objects. The
reason for this is that the new OpendTect 3.2 will contain a first version
of our command driver. The user can build a command file that specifies
which buttons to push, input fields to fill, items to select, etc.
And the primary way to address these ui-objects will be by their names.
In connection with this issue, the question came up how to name the
individual input fields of a uiGenInput (see uiTools/uigeninput.h).
This widely used class defines a varying number of input elements by
means of one or more DataInpSpec's, determining what kind of input
fields to incorporate (see General/datainpspec.h). The DataInpSpec
class has been extended with a chain function setName(,) to counter
that question:
virtual const DataInpSpec& setName( const char*, int idx=0);
One may assume that the individual input fields of any DataInpSpec
are indexed left-right and top-bottom, starting at zero. Let's take an
arbitrary example line from uiIo/uisurvinfoed.cc to show how it works:
ic0fld = new uiGenInput( crdgrp, "First In-line/Cross-line",
PositionInpSpec(psetup) );
Both position input fields specified by the PositionInpSpec are by default
inheriting the name "First In-line/Cross-line" from the uiGenInput that
incorporates them. It is of great help to all future command file writers
if the programmer assigns each input field its own name like this:
ic0fld = new uiGenInput( crdgrp, "First In-line/Cross-line",
PositionInpSpec(psetup).setName("Inl-field",0).setName("Crl-field",1) );
The mechanism of course applies to any uiGenInput with any number of
DataInpSpec's specifying any number of input fields.
Best regards,
Jaap Glas
--
-- dr. Jaap C. Glas
-- Software Engineer
-- dGB Earth Sciences
-- Nijverheidstraat 11-2
-- 7511 JM Enschede, The Netherlands
-- jaap.glas at dgb-group.com
-- http://www.dgb-group.com
-- Tel: +31 534315155, Fax: +31 534315104
More information about the Developers
mailing list