XRC-related question

Cees De Groot cdegroot at gmail.com
Wed Jul 27 14:02:22 UTC 2005


The layout thing indeed fixes it. I've studied the wx docs, but
they're not really clear...

With the #registerHandle stuff, I get better results indeed. Which is
good, because I really like doing layouts with XRC tools a whole lot
better :). Hadn't noticed the XRC support in WxTopLevelPresenter yet,
thanks for bringing my attention to it.

On 7/27/05, Rob Gayvert <rtg at rochester.rr.com> wrote:
> Hi Cees,
> 
> The main problem here is that I haven't added all of the hooks you need
> to make this easy.
> If you look at WxTopLevelPresenter>>restoreView, you'll see that after
> #loadFromXRC:,
> the view and its children need to be "registered". If they're not, then
> when a callback comes
> in, it can't find an object to notify, so the events are just ignored.
> 
> For now, give the following a try. When loading the resource, use
> 
>     view := res loadDialog: nil name: 'dialog_1'.
>     view registerHandle.
>     view getAllChildren
>         do: [:child | child registerHandle].
> 
> Also, it doesn't look like #setSizeHints: is sufficient here. Instead, try
> 
>     self view getSizer layout.
> 
> .. Rob
> 
> >Hi,
> >
> >I have an XRC file (attached) created with wxGlade. There are two
> >issues with this I cannot seem to solve... Here's what I do with the
> >XRC:
> >
> >DGVMessageDialogMetVinkjePresenter >>view
> >       | res |
> >       view ifNil: [
> >               res := WxXmlResource new.
> >               res initAllHandlers.
> >               res loadFromString: self class resourceText.
> >               view := res loadObject: nil name: 'dialog_1' className: 'wxDialog'.
> >               res destroy].
> >       ^view
> >
> >DGVMessageDialogMetVinkjePresenter >>connectView
> >       | messageField  |
> >       messageField _ self view findWindowByName: 'message'.
> >       messageField setLabel: 'this is a test. It is a bit longer than a
> >single line, so we can check whether this is really a good idea,
> >you know the painting and stuff...'.
> >
> >       okButton _ self view findWindowByName: 'okButton'.
> >       okButton on: #wxEvtCommandButtonClicked send: #okButtonClicked: to: self.
> >
> >       self view getSizer setSizeHints: self view
> >
> >Test code:
> >dlg _ DGVMessageDialogMetVinkjePresenter new.
> >dlg connectView.
> >dlg view showModal
> >
> >Two things don't really work out right. In wxGlade, on the sizer
> >there's a button "fit parent". It will resize the dialog according to
> >whatever label you've set on the message field. If tried different
> >things here (the #setSizeHints: being the last attempt), but I cannot
> >seem to get the dialog to resize around the text. Further, my
> >#okButtonClicked: never triggers....
> >
> >Is there anything I'm missing? Generally or XRC related? This is my
> >first attempt at using XRC, being fed up with creating handcoded
> >#createView methods :)
> >
> >TIA,
> >
> >Cees
> >
> >
> 
>



More information about the Wxsqueak mailing list