Le 20/03/2012 14:14, Wayne Stambaugh a écrit :
On 3/19/2012 5:12 PM, Dick Hollenbeck wrote:
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.

Dick,

Nice work.  I particularly like the use of the C stringification
expansion.  It's an elegant solution to a ticklish problem.  We may be
able to extend the shim over time to include other useful dialog
behavior.  Making the position and size persistent between sessions
would be useful.  We currently have several different methods to handle
dialog position and size persistence.  Distilling them into a single
solution in the shim would be a cleaner way to go.  Thank you for your
efforts.  I'll make a note whenever I'm making changes to any of the
wxFormbuilder dialogs to add this shim to them.

Thanks,

Wayne


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

Very clever!
I'll use it ASAP.


--
Jean-Pierre CHARRAS
KiCad Developers team.
KiCad Developers <[email protected]>

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to