← Back to team overview

kicad-developers team mailing list archive

DIALOG_SHIM & DIALOG_EXTEND_WITH_SHIM

 

Jean-Pierre and Wayne:

Please grep for these two symbols in my latest commit.

It is an initial attempt to institute some common dialog behavior.   Two common behaviors
I really enjoy are:

1) ESC key aborts dialog

2) s_LastPos and s_LastSize handling, which retain dialog sizes, such as
eeschema/dialog_edit_label.cpp when editing large EESCHEMA multi-line texts.


Arguably 1) could be done in a class between wxDialog and formbuilder written class, and
done only one time, but this would entail having to tell formbuilder to derive from a
custom class, and I don't know if that works.


However 2) needs class specific storage, and is not easily done in a base class beneath
the formbuilder generated one.  Therefore you get pulled into place further up into the
class hierarchy.  A SHIM is a wedge between two layers.  So the two named symbols allow
putting a SHIM between the formbuilder class and the human written derivation.


Also grep for

 _SHIM(

With this support, added to dialog_helpers.h, I was able to outfit dialog_edit_label.cpp
with retentative dialog sizing in about 5 minutes, and most of that included bashing the
header file.  I do not know if this will work from a header file, it might need some
tuning to work from there.   That is, the macro DIALOG_EXTEND_WITH_SHIM might not
currently work from a header file.  And if it works on gcc, it may not work on another
compiler.  However, I think it is good practice to keep dialog classes hidden anyways, and
this might be good motivation to move more out of header files into an implementation
file.  Just need an invocation function to be public.


This DIALOG_SHIM template class is a place to do common stuff, perhaps much more than I
have added.

Let me know what you think.  If you have problems with it, I need to know soon.

One last experience item.  Since the constructor calls SetFocus(), this is no necessary
any more, but still can be done to put the focus somewhere specific, since the optional
additional SetFocus() will run AFTER the one in the template because of the way
constructors are nested.

Dick




Follow ups