Discussion:
XRC working?
Steven Swerling
2006-07-19 15:18:01 UTC
Permalink
Hi Rob,

I wanted to work on the problem of WxMorphic panels surviving an image
save, and it seems that it doesn't work even for regular wx browsers.
Wasn't that working before?

Does it work for you, or did I manage to break something?
Rob Gayvert
2006-07-19 15:18:01 UTC
Permalink
Post by Steven Swerling
Hi Rob,
I wanted to work on the problem of WxMorphic panels surviving an image
save, and it seems that it doesn't work even for regular wx browsers.
Wasn't that working before?
Does it work for you, or did I manage to break something?
Yes, it was working in 0.3, but it's definitely busted now, even for the
simplest workspace. I'll have to track down what changed for the worse.
Steven Swerling
2006-07-19 15:18:01 UTC
Permalink
Post by Rob Gayvert
Post by Steven Swerling
Hi Rob,
I wanted to work on the problem of WxMorphic panels surviving an image
save, and it seems that it doesn't work even for regular wx browsers.
Wasn't that working before?
Does it work for you, or did I manage to break something?
Yes, it was working in 0.3, but it's definitely busted now, even for the
simplest workspace. I'll have to track down what changed for the worse.
Ok, so it wasn't something I did.

What are you working on these days?
Steven Swerling
2006-07-19 15:18:01 UTC
Permalink
Post by Rob Gayvert
Post by Steven Swerling
Hi Rob,
I wanted to work on the problem of WxMorphic panels surviving an image
save, and it seems that it doesn't work even for regular wx browsers.
Wasn't that working before?
Does it work for you, or did I manage to break something?
Yes, it was working in 0.3, but it's definitely busted now, even for the
simplest workspace. I'll have to track down what changed for the worse.
This is not the proposed fix, per se, but it will definitely get you
going in the right direction.

When WxStyledTextCtrlXmlHandler takes a look at the XML node for
WxPluggableTextView, it says it can handle it (using
#isOfClass:classname). But in #doCreateResource, it's hardwired to use
WxStyledTextCtrl. I fixed it in the following (probably unacceptable) way:

===1. Add an iv called "subclassToUse" to WxStyledTextCtrlXmlHandler
===2. #canHandle looks like this:
canHandle: xmlNode

"Transcript show: 'WxStyledTextCtrlXmlHandler.canHandle'; cr."

WxStyledTextCtrl withAllSubclassesDo: [:cls |

(self isOfClass: xmlNode classname: cls wxClassName) ifTrue: [
subclassToUse _ cls.
^true
].

].
^false

===3. #doCreateResource looks like this:
doCreateResource
ctrl := subclassToUse
parent: self getParentAsWindow
id: self getID
position: self getPosition
size: self getSize
style: (self getStyle: 'style' defaults: wxTabTraversal)
name: self getName.

ctrl setText: (self getText: 'value').
^ctrl
====
Note that connectEvents is still not working but I haven't figured out
why yet, it looks like the hookup is happening when you step through
connectEvents.
Rob Gayvert
2006-07-19 15:18:01 UTC
Permalink
Post by Steven Swerling
This is not the proposed fix, per se, but it will definitely get you
going in the right direction.
When WxStyledTextCtrlXmlHandler takes a look at the XML node for
WxPluggableTextView, it says it can handle it (using
#isOfClass:classname). But in #doCreateResource, it's hardwired to use
===1. Add an iv called "subclassToUse" to WxStyledTextCtrlXmlHandler
[...]
Getting the right xrcClass was one of the issues here. The attached
patches provide a temporary fix for this, but a more general solution is
needed.
Post by Steven Swerling
Note that connectEvents is still not working but I haven't figured out
why yet, it looks like the hookup is happening when you step through
connectEvents.
And this was another problem caused by some changes to the handle table.
Also, there were a couple of off-by-one bugs from the switch to 1-based
indexes.

-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 17 March 2005 at 4:45:31 pm'!

WxBase initializeClassNames!

!WxStatusBar methodsFor: 'xrc' stamp: 'rtg 3/17/2005 16:02'!
addXMLParametersTo: anElt

| nfields widths widthString |

super addXMLParametersTo: anElt.

nfields := self getFieldsCount.

self addXMLParameter: 'fields' value: nfields to: anElt.
nfields > 1 ifTrue: [
widths := (1 to: nfields) collect: [:i | (self getFieldRect: i) width].
widthString := widths inject: '' into: [:s :t | s isEmpty ifTrue: [ s, t asString ] ifFalse: [ s, ',', t asString ]].
self addXMLParameter: 'widths' value: widthString to: anElt.
].

! !
!WxListBox methodsFor: 'xrc' stamp: 'rtg 3/17/2005 16:03'!
addXMLParametersTo: anElt

| contentElt item |

super addXMLParametersTo: anElt.

contentElt := XMLElement named: 'content' attributes: Dictionary new..
1 to: self getCount do: [:i |
item := XMLElement named: 'item' attributes: Dictionary new.
item addContent: (XMLStringNode string: (self getString: i)).
contentElt addElement: item
].
anElt addElement: contentElt.
! !
!WxMenuBar methodsFor: 'xrc' stamp: 'rtg 3/17/2005 16:04'!
asXML

| elt menus |

elt := self basicXrcElementNamed: 'menubar'.
"self addXMLParametersTo: elt."

"add menus"
menus := self allMenus.
1 to: menus size do: [:i |
elt addElement: ((menus at: i) asXML: (self getLabelTop: i)).
].
^elt! !
!WxTopLevelPresenter methodsFor: 'as yet unclassified' stamp: 'rtg 3/17/2005 16:34'!
restoreView

| newChild |

view loadFromXRC: viewXRC.
view registerHandle.
viewChildren keysAndValuesDo: [:name :child |
newChild := view findWindowByName: name.
child handle: newChild handle.
child registerHandle.
].

view setIcon: WxIcon sample.
self connectView.
view reconnectEvents.

"the call to connectView may have updated the view state to match
its models, so we need to restore the state now"
viewChildren keysAndValuesDo: [:name :child |
child restoreState.
].

view show.
! !

!WxButton class methodsFor: 'xrc' stamp: 'rtg 3/17/2005 17:08'!
xrcClass

^'wxButton'! !
!WxListBox class methodsFor: 'xrc' stamp: 'rtg 3/17/2005 17:08'!
xrcClass

^'wxListBox'! !
!WxRadioButton class methodsFor: 'xrc' stamp: 'rtg 3/17/2005 17:09'!
xrcClass

^'wxRadioButton'! !
!WxTreeCtrl class methodsFor: 'xrc' stamp: 'rtg 3/17/2005 17:09'!
xrcClass

^'wxTreeCtrl'! !
!WxStyledTextCtrl class methodsFor: 'xrc' stamp: 'rtg 3/17/2005 17:10'!
xrcClass

^'wxStyledTextCtrl'! !

'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 17 March 2005 at 5:14:10 pm'!
!WxPluggableTextWidget methodsFor: 'as yet unclassified' stamp: 'rtg 3/17/2005 16:52'!
storeState

textContents := self getText.
selectionInterval := self getSelection.
! !

Loading...