Rob Lahaye wrote:
> Angus Leeming wrote:
>
>>
>> But, sure, this is a sample piece of code. You may find this preferable:
>> CheckedGlueLength(FL_OBJECT * input,
>> FL_OBJECT * choice,
>> FL_OBJECT * label=input);
>> Ie, the default value for the third arg is the same as the first, so
>> you can get away with writing just two.
>>
>> Or, indeed, this
>> CheckedGlueLength(FL_OBJECT * input,
>> FL_OBJECT * choice,
>> FL_OBJECT * label=0);
>>
>> although that means you'd have to alter checked_widgets.C a little too.
>
>
> I prefer to use the "label = input". May I then take it from here and add
> new code to your patch in my tree?
Angus,
I tried:
class CheckedGlueLength : public CheckedWidget {
public:
CheckedGlueLength(FL_OBJECT * input,
FL_OBJECT * label = input);
but my compiler doesn't like this and complains that the second "input"
is unknown. Is my compiler funny, or is this example code wrong?
To avoid the error, I do now:
class CheckedGlueLength : public CheckedWidget {
public:
CheckedGlueLength(FL_OBJECT * input,
FL_OBJECT * label = NULL);
and
CheckedGlueLength::CheckedGlueLength(FL_OBJECT * input,
FL_OBJECT * label)
: input_(input), label_(label ? label : input)
{
lyx::Assert(input && input->objclass == FL_INPUT);
}
Is that acceptable C++ coding?
As you can see here, I already removed the choice parameters to the
functions and works fine. So I guess they may go.
----------
BTW: since this works great, shall I now remove all the text_warning
stuff in the Forms. Your checkedWidgets code does automagically the
"isValid" checks. But for the text_warnings I have to do that again in
each FormFoobar.C to display the proper text.
Feels like by keeping the text_warnings we are forced to do things double.
The red coloring of the error-input widgets should be enough to indicate
that input is wrong. So: text_warnings shall go?
Regards,
Rob.