;+ ; NAME: ; widget_lay1 ; ; PURPOSE: ; Example widget with the following attributes ; - state is saved XXX ; - journalling, macros, and command access to widget events ; - tabs ; ; CALLING SEQUENCE: ; widget_lay1 ; ; INPUTS: ; none when called ; ; OPTIONAL INPUT: ; None ; ; OPTIONAL INPUT KEYWORD: ; None ; ; OUTPUTS: ; Journal file ; ; RESTRICTIONS: ; None ; ; EXAMPLE: ; widget_lay1 ; ; PROCEDURE ; widget structure is as follows: ; + wTopLevelBase - top-level base widget ; == wTab - Tab ; --- wSetTab - Tab with setting ; .... wGreetingRow - Base to put the greeing in one row ; ._._._. wGreetingLabel ; ._._._. wGreeting ; .... wGreeting - Text box ; --- wActionTab - Tab with actions (buttons) ; .... bGreet - button ; .... bDone - button ; --- wJournalTab - First Tab ; .... wBrowseMacro ; .... wMacroName ; .... wLoadMacro ; .... wJournal ; .... wBrowseJournal ; .... wJournalName ; .... wSaveJournal ; == wCommand - text box ; ; data structure elements are as follows: ; macroName ; journalName ; journal ; greeting ; ; MODIFICATION HISTORY: ; WRITTEN, Leslie Young, SwRI, May 2010 ;- pro widget_lay1_event, ev print, ev.top widget_control, ev.top, get_uvalue=state, /no_copy help, state, /str ; help, ev, /str ; uname = widget_info(ev.id, /uname) ; widget_control, ev.id, get_uvalue=uval ; if n_elements(uval) eq 0 then return ; print, uval ; print, uname ; case uval of ; bGreet: widget_lay1_greet, ev ; bDone: widget_lay1_done, ev ; else: ; end widget_control, ev.top, set_uvalue=state, /no_copy end pro widget_lay1_done, ev end pro widget_lay1 ; CREATE THE DATA STRUCTURE journal = '; Journal widget_lay1 '+systime() journal = [journal,journal,journal] state = { $ macroName:'macro.txt', $ ; Name of macro to load journalName: 'journal.txt', $ ; Name of journal to save journal: journal, $ ; Contents of journal greeting: 'Hello', $ ; Greeting greetrep : 3 $ ; number of times to repeat greeting } ; + wTopLevelBase wTopLevelBase = WIDGET_BASE(/COLUMN, title = 'WIDGET_LAY1', UVALUE=state, UNAME='wTopLevelBase') ; WIDGET_CONTROL, wTopLevelBase, SET_UVALUE=state ; == wTab - Tab wTab = WIDGET_TAB(wTopLevelBase) ; --- wSetTab - Tab with settings wSetTab = WIDGET_BASE(wTab, TITLE='Settings', /COLUMN) wGreetingRow = WIDGET_BASE(wSetTab, /ROW) wGreetingLabel = WIDGET_LABEL(wGreetingRow, VALUE='Enter Text for Greeting') tGreeting = WIDGET_TEXT(wGreetingRow, /EDITABLE, VALUE=state.greeting, $ UVALUE='tGreetng', UNAME = 'tGreetng') wGreetRepRow = WIDGET_BASE(wSetTab, /ROW) wGreetRepLabel = WIDGET_LABEL(wGreetRepRow, VALUE='Enter Number of times to repeat greeting') wGreetingRep = WIDGET_TEXT(wGreetRepRow, /EDITABLE, $ UVALUE='tGreetng', UNAME='tGreetng', $ VALUE=string(state.greetrep)) ; --- wActionTab - Tab with actions (buttons) wActionTab = WIDGET_BASE(wTab, TITLE='Actions', /COLUMN, UVAL='wActionTab') bGreet = WIDGET_BUTTON(wActionTab, VALUE='Greet', UVAL='bGreet', UNAME='bGreet') bDone = WIDGET_BUTTON(wActionTab, VALUE='Done', UVAL='bDone', UNAME='bDone') ; --- wJournalTab - Tab with Journal things wJournalTab = WIDGET_BASE(wTab, TITLE='Journal', /COLUMN) wMacroRow = WIDGET_BASE(wJournalTab, /ROW) ; .... wBrowseMacro wBrowseMacro = WIDGET_BUTTON(wMacroRow, VALUE='Choose Macro File', $ UVAL='wBrowseMacro', UNAME='wBrowseMacro') ; .... wMacroName wMacroLabel = WIDGET_LABEL(wMacroRow, VALUE='Macro File') wMacroName = WIDGET_TEXT(wMacroRow, /EDITABLE, $ UVALUE='wMacroName', UNAME='wMacroName', $ VALUE=string(state.macroName)) ; .... wLoadMacro wLoadMacro = WIDGET_BUTTON(wMacroRow, VALUE='Load Macro File', $ UVAL='wLoadMacro', UNAME='wLoadMacro') ; .... wJournal ; .... wJournal wJournal = WIDGET_TEXT(wJournalTab, /scroll, ysize = 10, $ UVALUE='wJournal', UNAME='wJournal', $ VALUE=string(state.journal)) wJournalRow = WIDGET_BASE(wJournalTab, /ROW) ; .... wBrowseJournal wBrowseJournal = WIDGET_BUTTON(wJournalRow, VALUE='Choose Journal File', $ UVAL='wBrowseJournal', UNAME='wBrowseJournal') ; .... wJournalName wJournalLabel = WIDGET_LABEL(wJournalRow, VALUE='Journal File') wJournalName = WIDGET_TEXT(wJournalRow, /EDITABLE, $ UVALUE='wJournalName', UNAME='wJournalName', $ VALUE=string(state.journalName)) ; .... wSaveJournal wSaveJournal = WIDGET_BUTTON(wJournalRow, VALUE='Save Journal File', $ UVAL='wSaveJournal', UNAME='wSaveJournal') ; Use XMANAGER to manage the widgets WIDGET_CONTROL, wTopLevelBase, /REALIZE XMANAGER, 'widget_lay1', wTopLevelBase end