[partial fix] XRC restore view

Rob Gayvert rtg at rochester.rr.com
Thu Mar 17 23:59:19 UTC 2005


Steven Swerling wrote:

> 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:
> [...]

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.

> 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.
	! !



More information about the Wxsqueak mailing list