home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RB3641.ZIP / EX1 / TESTDLG2.CLS < prev    next >
Text File  |  1991-12-20  |  3KB  |  92 lines

  1.  
  2. DialogBox subclass: #TestDialog
  3.   instanceVariableNames: ''
  4.   classVariableNames: 
  5.     'ItemIds '
  6.   poolDictionaries: 
  7.     'PMConstants '    !
  8.  
  9.  
  10. !TestDialog class methods !
  11.   
  12. initialize
  13.         "Fill the ItemIds dictionary holding
  14.          the ID values of controls in the Dialog Box.
  15.  
  16.          This method must be written by application developer
  17.          in order to provide a link between dialog box
  18.          controls and application methods.
  19.          ItemIds dictionary can be generated 'manually'
  20.          ( like in here ) or by reading the include-file
  21.          (xxx.h) generated by Dialog Box Editor."
  22.  
  23.    ItemIds := Dictionary new.
  24.    ItemIds at: 101 put: #ok;
  25.      at: 'entryfield' put: 103;
  26.  
  27.      "Notice the checkbox has two entries. The first
  28.       associates the dialog ID with the symbolic name. The
  29.       second associates the control itself with the method
  30.       used to manipulate it."
  31.  
  32.      at: 'myCheckbox' put: 102;
  33.      at: 102 put: #myCheckbox.!
  34.    
  35. windowId
  36.         "Answer the dialog id of the TestDialog."
  37.     ^101! !
  38.  
  39.  
  40.  
  41. !TestDialog methods !
  42.    
  43. itemIds
  44.     "Returns the value of itemIds dictionary used to
  45.      correlate the IDs in the dialog .res file and the
  46.      symbolic names used here in the methods."
  47.  
  48.     ^ItemIds!
  49.   
  50. myCheckbox
  51.         "Private - The user clicked on the checkbox."
  52.     (self queryButton: (ItemIds at: 'myCheckbox'))
  53.       ifTrue: [
  54.               "Perhaps do some processing here..."
  55.  
  56.               ]
  57.       ifFalse: [
  58.                ]!
  59.   
  60. ok
  61.     "Called when the user selects the OK push button in
  62.      the dialog box. No processing is done, just closing
  63.      the dialog and printing out the contents of the
  64.      entryfield. Validation could be done here, for instance."
  65.  
  66.     Transcript nextPutAll: 'In the entryfield was ', (self queryItemText: (ItemIds at: 'entryfield')) ;
  67.       cr .
  68.  
  69. ^self close!
  70.   
  71. open
  72.     "Used for TestDialog to show how to open a dialog,
  73.      set a text limit on an entry field and fill in some
  74.      text and set the state of a checkbox."
  75.      
  76.     "Changed from ToDoAboutDialogBox."
  77.     self fromResFile: 'ex1\test.res'.  
  78.     " self fromModule:  (DynamicLinkLibrary open:'c:\stvpm\todo\dlgdll.dll') id: self class windowId."
  79.  
  80.     "Taken and changed from NewSubclassDialog."
  81.  
  82.      self setItemText: (ItemIds at: 'entryfield') string: 'hello world'. 
  83.      self setTextLimit: (ItemIds at: 'entryfield') to: 25.   "arbitrary"
  84.  
  85.     "New code."
  86.  
  87.     self setButton: (ItemIds at: 'myCheckbox') value: true.  
  88.     "Unchanged from ToDoAboutDialogBox."
  89.  
  90.     self showWindow.
  91.     self processInput! !
  92.