; docformat = 'rst' ;+ ; Object-widget program to display a property sheet for a surface, making ; changes to the surface from the events to the property sheet. ;- ;+ ; Bring the surface property sheet to the foreground. ;- pro mgwidsurfaceproperties::show compile_opt strictarr widget_control, self.tlb, /show end ;+ ; Handle events for the property sheet i.e. property changes. ; ; :Params: ; event : in, required, type=structure ; event structure for any event generated by this widget program ;- pro mgwidsurfaceproperties::handleEvents, event compile_opt strictarr uname = widget_info(event.id, /uname) case uname of 'properties': begin value = widget_info(event.id, property_value=event.identifier) help, value, event.identifier, event.component event.component->setPropertyByIdentifier, event.identifier, value if (obj_valid(self.viewer)) then self.viewer->refreshDisplay end else: message, 'unknown widget generated event' endcase end ;+ ; Cleanup routine for widget program. ; ; :Params: ; tlb : in, optional, type=long ; top-level base widget identifier for this program ;- pro mgwidsurfaceproperties::cleanupWidgets, tlb compile_opt strictarr obj_destroy, self end ;+ ; Creates widget hierarchy. ;- pro mgwidsurfaceproperties::createWidgets compile_opt strictarr self.tlb = widget_base(title='Surface properties', /column, uvalue=self) surfaceProperties = widget_propertysheet(self.tlb, uname='properties', $ value=self.surface, $ xsize=50, ysize=20) end ;+ ; Realize the widget hierarchy. ;- pro mgwidsurfaceproperties::realizeWidgets compile_opt strictarr widget_control, self.tlb, /realize end ;+ ; Start event handling. ;- pro mgwidsurfaceproperties::startXmanager compile_opt strictarr xmanager, 'mgwidsurfaceproperties', self.tlb, /no_block, $ event_handler='mg_object_event_handler', $ cleanup='mg_object_cleanup' end ;+ ; Free resources of this object. ;- pro mgwidsurfaceproperties::cleanup compile_opt strictarr if (widget_info(self.tlb, /valid)) then widget_control, self.tlb, /destroy end ;+ ; Create a surface viewer object. ; ; :Returns: ; 1 for success, 0 for failure ; ; :Params: ; surface : in, required, type=IDLgrSurface ; surface to display properties of ; ; :Keywords: ; viewer : in, optional, type=object ; surface viewer that is displaying the surface ;- function mgwidsurfaceproperties::init, surface, viewer=viewer compile_opt strictarr self.surface = surface if (n_elements(viewer) gt 0L) then self.viewer = viewer self->createWidgets self->realizeWidgets self->startXmanager return, 1 end ;+ ; Define instance variables for the surface viewer. ; ; :Fields: ; tlb ; widget identifier for the top-level base ; surface ; IDLgrSurface to change properties of ; viewer ; surface viewer object-widget reference ;- pro mgwidsurfaceproperties__define compile_opt strictarr define = { MGwidSurfaceProperties, $ tlb: 0L, $ surface: obj_new(), $ viewer: obj_new() $ } end