Chapter07TextContextWidgetTT.pro
Upload User: pyaf88
Upload Date: 2020-01-10
Package Size: 165k
Code Size: 2k
Category:

Special Effects

Development Platform:

IDL

  1. ; Chapter07TextContextWidgetTT.pro
  2. PRO CTE_ColumnEvent, event
  3.   titleLabel = WIDGET_INFO(event.TOP, FIND_BY_UNAME = 'xyLabel')
  4.   WIDGET_CONTROL, titleLabel, SET_VALUE = 'Column:  '
  5. END
  6. PRO CTE_RowEvent, event
  7.   titleLabel = WIDGET_INFO(event.TOP, FIND_BY_UNAME = 'xyLabel')
  8.   WIDGET_CONTROL, titleLabel, SET_VALUE = 'Row:  '
  9. END
  10. PRO CTE_DoneEvent, event
  11.   WIDGET_CONTROL, event.TOP, /DESTROY
  12. END
  13. PRO CTE_TextEvents, event
  14.   IF (TAG_NAMES(event,/STRUCTURE_NAME) EQ 'WIDGET_CONTEXT') THEN BEGIN
  15.     contextBase = WIDGET_INFO(event.TOP, FIND_BY_UNAME = 'contextMenu')
  16.     WIDGET_DISPLAYCONTEXTMENU, event.ID, event.X, event.Y, contextBase
  17.   ENDIF ELSE BEGIN
  18.     WIDGET_CONTROL, event.ID, GET_VALUE = textString
  19.     ON_IOERROR, badnum
  20.     IF ((FIX(textString) GE 0) AND (FIX(textString) LE 360)) THEN BEGIN
  21.       textValue = FIX(textString)
  22.     ENDIF ELSE BEGIN
  23.       badnum:
  24.       dialog=DIALOG_MESSAGE('Please enter a number between 0 and 360')
  25.       WIDGET_CONTROL, event.ID, SET_VALUE=''
  26.       RETURN
  27.     ENDELSE
  28.     titleLabel = WIDGET_INFO(event.TOP, FIND_BY_UNAME = 'xyLabel')
  29.     WIDGET_CONTROL, titleLabel, GET_VALUE = MyLabel
  30.     MyMessage = MyLabel + textString
  31.     Result = DIALOG_MESSAGE( MyMessage, /INFORMATION)
  32.   ENDELSE
  33. END
  34. PRO Chapter07TextContextWidgetTT
  35.   topLevelBase = WIDGET_BASE(/COLUMN)
  36.   bigBase = WIDGET_BASE(topLevelBase, /COLUMN, /FRAME)
  37.   bigLabel = WIDGET_LABEL(bigBase,VALUE='Enter a number between 1-360',$
  38.     /DYNAMIC_RESIZE)
  39.   textBase = WIDGET_BASE(bigBase, /ROW)
  40.   titleLabel = WIDGET_LABEL(textBase, VALUE = 'My Title: ', $
  41.     /DYNAMIC_RESIZE, UNAME = 'xyLabel')
  42.   locationText = WIDGET_TEXT(textBase, VALUE = '180', $
  43.     /EDITABLE, UNAME = 'xyText', /CONTEXT_EVENTS, $
  44.     UVALUE = location, EVENT_PRO = 'CTE_TextEvents',XSIZE = 80)
  45.   contextBase = WIDGET_BASE(topLevelBase, /CONTEXT_MENU, UNAME = 'contextMenu')
  46.   columnButton = WIDGET_BUTTON(contextBase, $
  47.     VALUE = 'Column', EVENT_PRO = 'CTE_ColumnEvent')
  48.   rowButton = WIDGET_BUTTON(contextBase, $
  49.     VALUE = 'Row', EVENT_PRO = 'CTE_RowEvent')
  50.   doneButton = WIDGET_BUTTON(contextBase, VALUE = 'Done', $
  51.     /SEPARATOR, EVENT_PRO = 'CTE_DoneEvent')
  52.   WIDGET_CONTROL, topLevelBase, /REALIZE
  53.   XMANAGER, 'Chapter07TextContextWidgetTT', topLevelBase
  54. END