Re: XML Question [message #42814] |
Wed, 23 February 2005 10:03  |
Karl Schultz
Messages: 341 Registered: October 1999
|
Senior Member |
|
|
On Wed, 23 Feb 2005 10:33:08 -0700, David Fanning wrote:
> Karl Schultz writes:
>
>> Hope this helps. I can help further, if needed.
>
> Oh, that *really* helps. Thanks!
Great!
> I've been reading my w3schools.com tutorials, and working my
> way through the relevant sections of Building Applications
> and it is beginning to make a lot of sense to me now. In fact,
> like most of the objects I work with, it generates more good
> ideas than I know what to do with! I can see all *kinds* of
> possibilities! :-)
That's exactly the thing to do. The IDL XMLDOM support is built on top of
the Xerces DOM library, so after you trip across that, the IDL stuff will
seem pretty familiar.
Here's an update to the program that lets you modify the widget values.
As the widget values change, the DOM tree contents are modified. When the
application is closed, the DOM tree is written back out to the XML file.
When you start the app again, you see your updated values in the widgets.
This code is really bare-bones for newsgroup-level brevity with a lot of
ugly shortcuts, but you'll get the idea.
Karl
pro demo_cleanup, w
WIDGET_CONTROL, w, GET_UVALUE=state
state.oDoc->Save, FILENAME='demo.xml'
OBJ_DESTROY, state.oDoc
end
pro demo_event, ev
WIDGET_CONTROL, ev.id, GET_VALUE=value, GET_UVALUE=oValue
oValue->SetNodeValue, STRING(value[0])
end
pro demo
oDoc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME='demo.xml')
oTopLevel = oDoc->GetDocumentElement()
oWidgetList = oTopLevel->GetElementsByTagName("widget")
wBase = WIDGET_BASE(/COL, TITLE=oTopLevel->GetAttribute("title"))
for i=0, oWidgetList->GetLength()-1 do begin
oWidget = oWidgetList->Item(i)
case oWidget->GetAttribute("type") OF
'slider': begin
wSlider = WIDGET_SLIDER(wBase, $
MINIMUM=FIX(oWidget->GetAttribute("min")), $
MAXIMUM=FIX(oWidget->GetAttribute("max")))
oValueList = oWidget->GetElementsByTagName("value")
oValue = oValueList->Item(0)
WIDGET_CONTROL, wSlider, $
SET_VALUE=FIX((oValue->GetFirstChild())->GetNodeValue()), $
SET_UVALUE=oValue->GetFirstChild()
end
'text': begin
wText = WIDGET_TEXT(wBase, /EDITABLE)
oValueList = oWidget->GetElementsByTagName("value")
oValue = oValueList->Item(0)
WIDGET_CONTROL, wText, $
SET_VALUE=(oValue->GetFirstChild())->GetNodeValue(), $
SET_UVALUE=oValue->GetFirstChild()
end
else: print, "Unknown widget type"
endcase
endfor
state = { $
oDoc: oDoc }
WIDGET_CONTROL, wBase, SET_UVALUE=state
WIDGET_CONTROL, wBase, /REALIZE
XMANAGER, 'demo', wBase, CLEANUP='demo_cleanup', /NO_BLOCK
end
|
|
|