Andre Poenitz wrote:
> On Fri, Aug 30, 2002 at 03:30:28AM +0900, R. Lahaye wrote:
> 
>>I did this, because we were continuously translating between the
>>GUI-keywords, the LyX-keywords, and the LaTeX keywords. This complicated
>>scheme is reduced to the commen GUI - LyX/LaTeX conversion, using a
>>Translator for that.
>>
>>Patch attached.
> 
> 
> I like the idea but not really the implementation. I.e there are two or
> three places of switches like that:
> 
> -     int const origin_pos = fl_get_choice(extra_->choice_origin);
> -     igp.rotateOrigin = origins_[origin_pos-1];
> +     switch (fl_get_choice(extra_->choice_origin)) {
> +             case 11: igp.origin = frnt::RightBottom; break;
> +             case 10: igp.origin = frnt::RightTop; break;
> +             case  9: igp.origin = frnt::RightBaseline; break;
> +             case  8: igp.origin = frnt::LeftBottom; break;
> +             case  7: igp.origin = frnt::LeftTop; break;
> +             case  6: igp.origin = frnt::LeftBaseline; break;
> +             case  5: igp.origin = frnt::CenterBottom; break;
> +             case  4: igp.origin = frnt::CenterTop; break;
> +             case  3: igp.origin = frnt::CenterBaseline; break;
> +             case  2: igp.origin = frnt::Center; break;
> +             case  1:
> +             default:  igp.origin = frnt::DefaultOrigin;
> +     }
> 
> As enums could be explicitly converted to ints I don't think they are
> necessary. 


No, do not agree with this. Doing the enum to int conversion automatically
without switch will make it fully depend on the exact order in the enum
list, which is in a totally different .h file. That's a very bad idea.

Using a switch like here, keeps everything localized. Xforms has its own
choice-list in the Xforms dialog and that is here properly connected as a
switch statement in FormGraphics.C.

Qt does something similar in QGraphics.C, but with its own choice list.

I say: keep the switches for the sake of localization per UI.
It's simple and straightforward.

Rob.

Reply via email to