home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RB3641.ZIP / TODO / TODOAPPL.CLS < prev    next >
Text File  |  1992-01-13  |  71KB  |  2,674 lines

  1.  
  2. TopPane subclass: #CUATopPane
  3.   instanceVariableNames: ''
  4.   classVariableNames: ''
  5.   poolDictionaries: 
  6.     'CharacterConstants PMConstants ' !
  7. CUATopPane subclass: #SimpleTopPane
  8.   instanceVariableNames: ''
  9.   classVariableNames: ''
  10.   poolDictionaries: 
  11.     'PMConstants ' !
  12. CUATopPane subclass: #ToDoTopPane
  13.   instanceVariableNames: ''
  14.   classVariableNames: ''
  15.   poolDictionaries: 
  16.     'PMConstants '   !
  17. ListBox subclass: #ListBoxODraw
  18.   instanceVariableNames: 
  19.     'bMap tickBmap startPoint '
  20.   classVariableNames: ''
  21.   poolDictionaries: 
  22.     'PMConstants '  !
  23. Object subclass: #ToDoItem
  24.   instanceVariableNames: 
  25.     'type description priority deadline completed '
  26.   classVariableNames: 
  27.     'Defaults '
  28.   poolDictionaries: 
  29.     'CharacterConstants ' !
  30. Dictionary subclass: #ToDoPriorityList
  31.   instanceVariableNames: ''
  32.   classVariableNames: 
  33.     'Priorities '
  34.   poolDictionaries: ''   !
  35. OrderedCollection subclass: #ToDoList
  36.   instanceVariableNames: 
  37.     'sortKey sortOrder '
  38.   classVariableNames: ''
  39.   poolDictionaries: '' !
  40. Object subclass: #ToDoSettings
  41.   instanceVariableNames: 
  42.     'sortKey sortOrder country codePage includeCriterion defaultItem '
  43.   classVariableNames: ''
  44.   poolDictionaries: ''  !
  45. ViewManager subclass: #ToDoRowDisplay
  46.   instanceVariableNames: 
  47.     'fieldList deadline priority description type completed ctlWindow '
  48.   classVariableNames: ''
  49.   poolDictionaries: 
  50.     'CharacterConstants PMConstants ' !
  51. ViewManager subclass: #ToDoSettingsView
  52.   instanceVariableNames: 
  53.     'notebook nbControls sortPage defaultsPage countryPage includePage topPage ctlView ctlSettings '
  54.   classVariableNames: ''
  55.   poolDictionaries: 
  56.     'PMNotebookConstants PMConstants CharacterConstants '  !
  57. ViewManager subclass: #ToDoListView
  58.   instanceVariableNames: 
  59.     'settings itemList listLineHeight todoListBox rowDisp prevSelection statusField undoItem '
  60.   classVariableNames: ''
  61.   poolDictionaries: 
  62.     'CharacterConstants PMConstants '    !
  63. DragTransfer subclass: #DragString
  64.   instanceVariableNames: ''
  65.   classVariableNames: ''
  66.   poolDictionaries: 
  67.     'PMDragConstants PMConstants '  !
  68.  
  69.  
  70. !CUATopPane class methods !
  71.   
  72. fileMenu
  73.         "Private - Answer the File menu."
  74.     ^Menu new
  75.         appendItem: '~Open as ToDo List' selector: #openAsToDoList;
  76.         appendItem: 'Open as ~Settings' selector: #openAsSettings;
  77.         appendSeparator ;
  78.         appendItem: '~Save    ' selector: #accept  ;
  79.         appendSeparator ;
  80.         appendItem: '~Print    ' selector: #print  ;
  81.         appendItem: 'Print~All    ' selector: #printAll  ;
  82.         title: '~ThingsToDo'!
  83.    
  84. supportedEvents
  85.         "Answer the Set of events that SubPanes can notify
  86.          their owners about."
  87.     ^Set new
  88.         add: #close;
  89.         add: #opened;
  90.         add: #timer;
  91.         add: #menuBuilt;
  92.         add: #validated;
  93.         add: #activate;
  94.         add: #help;
  95.         add: #getMenu;
  96.         add: #getPopupMenu;
  97.         yourself! !
  98.  
  99.  
  100.  
  101. !SimpleTopPane class methods ! !
  102.  
  103.  
  104.  
  105. !ToDoTopPane class methods ! !
  106.  
  107.  
  108.  
  109. !ListBoxODraw class methods !
  110.  
  111. ownerDraw
  112.         "Answer an instance of the receiver where
  113.          the owner will be notified to draw each item."
  114.     | lb startPoint |
  115.     lb := self new. 
  116.     lb    style: lb ownerDrawFixed.
  117.     lb initStartPoint.
  118.     ^lb.! !
  119.  
  120.  
  121.  
  122. !ToDoItem class methods !
  123.  
  124. defaults
  125.     "set the default item settings as an array"
  126.  
  127.     ^Defaults!
  128.    
  129. defaults: anArray
  130.     "set the default item settings as an array"
  131.  
  132.     Defaults := anArray.!
  133.    
  134. new
  135.     
  136.     ^super new!
  137.  
  138. newItem
  139.     "create and initalize a new item"
  140.     ^super new initialize.!
  141.    
  142. typesAvailable
  143.  
  144.     "Returns a collection of the available values for Type"
  145.  
  146. ^#('Phone' 'Meeting' 'Report' 'Personal').! !
  147.  
  148.  
  149.  
  150. !ToDoPriorityList class methods !
  151.  
  152. new
  153.  
  154.     ^super new initialize.!
  155.  
  156. priorities
  157.     "return the priority descriptions as an array"
  158.  
  159.     ^Priorities!
  160.  
  161. priorities: anArray
  162.     "set the priority descriptions to the contents of the array"
  163.  
  164.     Priorities := anArray.! !
  165.  
  166.  
  167.  
  168. !ToDoList class methods ! !
  169.  
  170.  
  171.  
  172. !ToDoSettings class methods !
  173.  
  174. new
  175.  
  176. ^super new initialise! !
  177.  
  178.  
  179.  
  180. !ToDoRowDisplay class methods ! !
  181.  
  182.  
  183.  
  184. !ToDoSettingsView class methods ! !
  185.  
  186.  
  187.  
  188. !ToDoListView class methods !
  189.  
  190. startUp
  191.  
  192.     ^super new open! !
  193.  
  194.  
  195.  
  196. !DragString class methods ! !
  197.  
  198.  
  199.  
  200. !CUATopPane methods !
  201.  
  202. buildMenuBar
  203.         "Private - Create the menus that make up the menu bar."
  204.     | textPane eachMenu |
  205.     menuWindow addMenu: self fileMenu owner: self.
  206.     (self class canUnderstand: #saveAs) ifFalse: [
  207.         (eachMenu := menuWindow menuTitled: '~File') notNil
  208.             ifTrue: [eachMenu disableItem: #saveAs]].
  209.     textPane := self searchForDefaultTextPane.
  210.     textPane notNil ifTrue: [
  211.         menuWindow addMenu: (textPane class editMenu allOwners: textPane).
  212.         menuWindow addMenu: (textPane class smalltalkMenu allOwners: textPane).
  213.         ].
  214.     children do: [ :subpane |
  215.         eachMenu := subpane menu.
  216.         eachMenu notNil ifTrue: [
  217.             menuWindow addMenu: eachMenu.
  218.             ]].
  219.     menuWindow systemMenu
  220.         insertItem: '~Zoom Text    Alt+Z'
  221.         selector: #zoom
  222.         accelKey: $z
  223.         accelBits: AfChar | AfAlt
  224.         after: 5.
  225.     menuWindow systemMenu
  226.         insertItem: 'Fonts...'
  227.         selector: #setFonts
  228.         accelKey: nil
  229.         accelBits: nil
  230.         after: 6.
  231.  
  232.     menuWindow addMenu: self editMenu.
  233.     menuWindow addMenu: self viewMenu.
  234.  
  235.     self helpManager notNil
  236.         ifTrue: [self helpManager buildMenuBar].!
  237.    
  238. controlKeyInput: aCharacter
  239.         "Private - A control key was pressed by the user,
  240.          e.g. Backspace, Enter, Tab.  aCharacter contains
  241.          the ascii code for the key."
  242.  
  243.     (aCharacter = Tab) ifTrue: [
  244.         owner tabToNextField ].
  245.     ^super controlKeyInput: aCharacter!
  246.   
  247. openWindow: aRect
  248.         "Open the receiver on a desired position and size
  249.  
  250.         Author: Jouko Ruuskanen
  251.         16.10.1991 "
  252.  
  253.     ^self openIn: aRect.!
  254.   
  255. virtualKeyInput: anInteger
  256.         "Private - The user pressed a virtual (i.e. non-alphanumeric) key.
  257.          anInteger is a VkConstant from the PMConstants pool
  258.          dictionary."
  259.  
  260.     (anInteger = 7) ifTrue: [ owner tabToPrevField ].
  261.     ^super virtualKeyInput: anInteger! !
  262.  
  263.  
  264.  
  265. !SimpleTopPane methods !
  266.  
  267. buildMenuBar
  268.  
  269.     ^nil!
  270.   
  271. defaultFrameStyle
  272.         "Private - Answer the default PM frame style for the receiver."
  273.     ^FcfIcon!
  274.    
  275. virtualKeyInput: anInteger
  276.         "Private - The user pressed a virtual (i.e. non-alphanumeric) key.
  277.          anInteger is a VkConstant from the PMConstants pool
  278.          dictionary."
  279.  
  280.     (anInteger = 22) ifTrue: [ owner rowUp ].
  281.     (anInteger = 24) ifTrue: [ owner rowDown ].
  282.     (anInteger = VkF10) ifTrue: [ owner jumpToBar ].
  283.     ^super virtualKeyInput: anInteger! !
  284.  
  285.  
  286.  
  287. !ToDoTopPane methods !
  288.  
  289. addItem
  290.  
  291.     ^owner addItem!
  292.  
  293. buildMenuBar
  294.         "Private - Build menu bar."
  295.     | eachMenu empty|
  296.     super buildMenuBar.
  297.     (self owner respondsTo: #dummy) ifTrue: [
  298.         (eachMenu := menuWindow menuTitled: '~View') notNil
  299.             ifTrue: [eachMenu disableItem: #dummy]].
  300.     (self owner respondsTo: #dummy) ifTrue: [
  301.         (eachMenu := menuWindow menuTitled: '~Edit') notNil
  302.             ifTrue: [eachMenu disableItem: #dummy]].
  303.  
  304.     PMWindowLibrary openClipbrd: handle.
  305.     empty := PMWindowLibrary queryClipbrdData: handle fmt: 1.        "CF_TEXT = 1"
  306.     (empty = 0)
  307.         ifTrue:[ (self menuTitled:'Edit') disableItem:'~Paste' ].
  308.     PMWindowLibrary closeClipbrd: handle.
  309.  
  310.     self event: #menuBuilt!
  311.    
  312. copyItem
  313.  
  314.     "Copy an item to the clipboard"
  315.  
  316. ^owner copyItem: handle.!
  317.    
  318. create: parentWindow
  319.     title: aTitleString
  320.     frameStyle: aFrameStyle
  321.     frameCreateFlags: fcfConstants
  322.     clientStyle: aClientStyle
  323.         "Private - Create a PM window whose parent is
  324.          parentWindow with aTitleString as the title, and
  325.          aFrameStyle as the pCtlData.
  326.          The receiver's handle is set to the
  327.          resulting client window.  The receiver's parent
  328.          is set to the frame window."
  329.     | fcfParam |
  330.     (fcfConstants isInteger)
  331.         ifTrue: [fcfParam := PMLong fromInteger: fcfConstants]
  332.         ifFalse: [fcfParam := fcfConstants].
  333.     parent := FrameWindow fromBytes: (PMWindowLibrary createStdWindow: parentWindow asParameter
  334.         flStyle: aFrameStyle
  335.         pCtlData: (fcfParam asParameter)
  336.         pszClientClass: ('VPM' asParameter)
  337.         pszTitle: (aTitleString asParameter)
  338.         styleClient: aClientStyle
  339.         hmod: (DynamicLinkLibrary open: 'RES')
  340.         idResources: 262
  341.         phwndClient: (self asParameter)).
  342.     handle = NullHandle ifTrue: [^nil].
  343.     parent parent: parentWindow.
  344.     parent child: self.
  345.     handle containedIn: self.!
  346.  
  347. cutItem
  348.  
  349.     "Copy an item to the clipboard and then delete it."
  350.  
  351. self copyItem.
  352. self removeItem.!
  353.  
  354. dummy
  355.  
  356.     ^nil!
  357.  
  358. editMenu
  359.         "Private - Answer the SortBy... menu."
  360.  
  361.     ^Menu new
  362.  
  363.         appendItem: '~Undo' selector: #dummy;
  364.         appendItem: '~Redo' selector: #dummy;
  365.         appendSeparator;
  366.         appendItem: '~Copy' selector: #copyItem;
  367.         appendItem: 'C~ut' selector: #cutItem;
  368.         appendItem: '~Paste' selector: #pasteItem;
  369.         appendSeparator;
  370.         appendItem: '~New item' selector: #addItem;
  371.         appendItem: '~Delete item' selector: #removeItem ;
  372.         title: '~Edit';
  373.         owner: self.!
  374.  
  375. openAsSettings
  376.  
  377.     owner openAsSettings!
  378.  
  379. openAsToDoList
  380.  
  381. "    owner openDataBase "!
  382.    
  383. pasteItem
  384.  
  385.     "Paste an item from the clipboard into the list."
  386.  
  387. ^owner pasteItem: handle!
  388.  
  389. print
  390.         "Ask the owner (ToDoListView) to print the currently selected
  391.          item."
  392.  
  393.         owner printItem.!
  394.  
  395. printAll
  396.         "Ask the owner (ToDoListView) to print all the items in the list."
  397.  
  398.         owner printAllItems.!
  399.    
  400. redo
  401.  
  402. ^owner redo!
  403.  
  404. refresh
  405.  
  406.     owner refreshButton: nil!
  407.    
  408. removeItem
  409.  
  410.     ^owner removeItem!
  411.    
  412. sortByDeadline
  413.     
  414.     owner sortBy: 'deadline'.!
  415.   
  416. sortByDescription
  417.     
  418.         owner sortBy: 'description'.!
  419.    
  420. sortByMenu
  421.         "Private - Answer the SortBy... menu."
  422.     ^Menu new
  423.  
  424.         appendItem: '~Type' selector: #sortByType;
  425.         appendItem: '~Description' selector: #sortByDescription ;
  426.         appendItem: 'Dead~line' selector: #sortByDeadline ;
  427.         appendItem: '~Priority' selector: #sortByPriority ;
  428.         checkItem: '~Priority' ;
  429.         title: '~Sort By';
  430.         owner: self.!
  431.    
  432. sortByPriority
  433.     
  434.         owner sortBy: 'priority'.!
  435.  
  436. sortByType
  437.     
  438.     owner sortBy: 'type'.!
  439.   
  440. undo
  441.  
  442. ^owner undo!
  443.  
  444. viewMenu
  445.         "Private - Answer the SortBy... menu."
  446.     ^Menu new
  447.  
  448.         appendItem: '~List' selector: #dummy;
  449.         appendItem: 'Se~ttings' selector: #openAsSettings ;
  450.         appendSeparator;
  451.         appendItem: '~Sort...' selector: #dummy;
  452.         appendItem: '~Include...' selector: #dummy;
  453.         appendSeparator;
  454.         appendItem:  '~Refresh now' selector: #refresh;
  455.         title: '~View';
  456.         owner: self.!
  457.    
  458. wmSize: mp1 with: mp2
  459.  
  460.     self resize:
  461.         (rectangle origin extent: (mp2 lowHalf @ mp2 highHalf)).
  462.      owner sized. "Inform the owner"
  463.     ^nil! !
  464.  
  465.  
  466.  
  467. !ListBoxODraw methods !
  468.   
  469. drawBmap
  470.     
  471.     graphicsTool 
  472.         copyBitmap: bMap
  473.         from: bMap boundingBox
  474.         at: graphicsTool location.!
  475.  
  476. drawLine2: anItemlist
  477.     | penHeight str|
  478.  
  479.     penHeight := graphicsTool  location y + startPoint.
  480.     self drawBmap.
  481.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) deadline) at: 
  482.         (((handle rectangle) width )// (100/4)) @ penHeight.
  483.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) type) at: 
  484.         (((handle rectangle) width )// (100/15)) @ penHeight.
  485.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) description) at: 
  486.         (((handle rectangle) width )// (100/35)) @ penHeight.
  487.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) priority) at: 
  488.         (((handle rectangle) width )// (100/80)) @ penHeight.
  489.     (((anItemlist at: itemBeingDrawn) completed)  = true ) ifTrue: [
  490.         str := 'OK'.
  491.         graphicsTool  lineDisplay: str at: 
  492.             (((handle rectangle) width )// (100/90)) @ penHeight.
  493.     ].
  494.  
  495.     itemWasDrawn := true.
  496.  
  497.     ^self.!
  498.   
  499. drawLine: anItemlist
  500.     | penHeight |
  501.  
  502.     penHeight := graphicsTool  location y + startPoint.
  503.     self drawBmap.
  504.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) deadline) at: 
  505.         (((handle rectangle) width )// (100/4)) @ penHeight.
  506.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) type) at: 
  507.         (((handle rectangle) width )// (100/15)) @ penHeight.
  508.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) description) at: 
  509.         (((handle rectangle) width )// (100/35)) @ penHeight.
  510.     graphicsTool  lineDisplay: ((anItemlist at: itemBeingDrawn) priority) at: 
  511.         (((handle rectangle) width )// (100/80)) @ penHeight.
  512.     (((anItemlist at: itemBeingDrawn) completed)  = true ) ifTrue: [
  513.         graphicsTool  place: (((handle rectangle) width )// (100/91)) @ penHeight.
  514.         self drawTick.
  515.     ].
  516.  
  517.     itemWasDrawn := true.
  518.  
  519.     ^self.!
  520.    
  521. drawTick
  522.     
  523.     graphicsTool 
  524.         copyBitmap: tickBmap
  525.         from: bMap boundingBox
  526.         at: graphicsTool location.!
  527.  
  528. initStartPoint
  529.  
  530.     (Display extent = (640@480)) ifTrue: [ startPoint := 3 ]
  531.         ifFalse: [ startPoint := 6 ].
  532.  
  533.     bMap := Bitmap fromModule: 'TODO\RES.DLL' id: 258.
  534.     tickBmap := Bitmap fromModule: 'TODO\RES.DLL' id: 259.
  535.  
  536.     ^self! !
  537.  
  538.  
  539.  
  540. !ToDoItem methods !
  541.  
  542. asParameter
  543.  
  544.     ^(' ' asAsciiZ)!
  545.  
  546. asPercentDelimitedString
  547.  
  548.     | compStr |
  549.     compStr := ''.
  550.     (completed = true)  ifTrue: [ compStr := 'true' ].
  551.     (completed = false) ifTrue: [ compStr := 'false' ].
  552.     ^'%%',type,'%',description,'%',deadline,'%',priority,'%',compStr,'%%'!
  553.    
  554. asString
  555.  
  556.     | compStr |
  557.     compStr := ''.
  558.     (completed = true)  ifTrue: [ compStr := 'true' ].
  559.     (completed = false) ifTrue: [ compStr := 'false' ].
  560.     ^type,description,deadline,priority,compStr!
  561.  
  562. compareTo: aToDoItem using: aSortKey
  563.  
  564.     "Returns true if the receiver ToDoItem is less than or equal
  565.      to the argument ToDoItem, using the SortKey as the element
  566.      to be compared.
  567.  
  568.      This method was originally four IF statements. After working
  569.      with Smalltalk for a while longer it was obvious that this
  570.      case statement-like processing wasn't necessary in OO, if we
  571.      could work out how to do it otherwise.
  572.  
  573.      What happens here is that aSortKey (which has the value priority
  574.      or deadline etc, is converted into a symbol (unique occurance in
  575.      the system, like PM Atoms) which can then be used as the name of
  576.      a method. The perform: method executes the argument it is given
  577.      by sending it as a message to self (ie the item). So this one-liner
  578.      sets up the sort block as being a comparison between the two items'
  579.      values of one of their instance variables (like type or description).
  580.  
  581.      If aSortKey was equal to type then the expression would be
  582.  
  583.      ^self type <= aToDoItem type                                      "
  584.  
  585. ^(self perform: (aSortKey asSymbol)) <= (aToDoItem perform: (aSortKey asSymbol))!
  586.   
  587. compareTo: aToDoItem using: aSortKey order: aSortOrder
  588.  
  589.     "Returns true if the receiver ToDoItem is less than or equal (LTE)
  590.      to the argument ToDoItem, using the SortKey as the element
  591.      to be compared.    aSortOrder modifies the LTE to GTE.
  592.  
  593.      This method was originally four IF statements. After working
  594.      with Smalltalk for a while longer it was obvious that this
  595.      case statement-like processing wasn't necessary in OO, if we
  596.      could work out how to do it otherwise.
  597.  
  598.      What happens here is that aSortKey (which has the value priority
  599.      or deadline etc, is converted into a symbol (unique occurance in
  600.      the system, like PM Atoms) which can then be used as the name of
  601.      a method. The perform: method executes the argument it is given
  602.      by sending it as a message to self (ie the item). So this one-liner
  603.      sets up the sort block as being a comparison between the two items'
  604.      values of one of their instance variables (like type or description).
  605.  
  606.      If aSortKey was equal to type then the expression could be translated 
  607.      as:     ^self type <= aToDoItem type  "
  608.  
  609.     aSortOrder = 'descending'             "default is thus 'ascending' "
  610.         ifTrue: [
  611.             ^(self perform: (aSortKey asSymbol)) 
  612.                 >= (aToDoItem perform: (aSortKey asSymbol)) ]
  613.         ifFalse: [ 
  614.             ^(self perform: (aSortKey asSymbol)) 
  615.                 <= (aToDoItem perform: (aSortKey asSymbol)) ].!
  616.  
  617. completed
  618.     "returns the value of completed"
  619.  
  620.     ^completed!
  621.   
  622. completed: aValue
  623.     "Sets the value of completed"
  624.  
  625.     completed := aValue.!
  626.    
  627. copyYourself: aHandle
  628.  
  629.         "Copy the item to our clipboard"
  630.         |clipMgr|
  631.  
  632.     CursorManager execute change.
  633.  
  634.     clipMgr := ClipboardManager new.
  635.     clipMgr setString: (self asPercentDelimitedString).
  636.     clipMgr close.
  637.  
  638.    CursorManager normal change.!
  639.  
  640. deadline
  641.  
  642.     "Returns the value of deadline. Provided so that the instance
  643.      variables values can be seen by other objects."
  644.  
  645. ^deadline!
  646.    
  647. deadline: aDeadline
  648.  
  649.     "Sets the value of deadline to the argument aDeadline. Allows
  650.      other objects to alter the value of deadline. In the ideal OO
  651.      world this is the only place where a change in the structure
  652.      of deadline means any changes have to be made to the access
  653.      routines. Every object that is interested in setting deadline
  654.      has to come through here so one change is all you need."
  655.  
  656. deadline := aDeadline.!
  657.  
  658. description
  659.     "returns the value of description"
  660.  
  661.     ^description!
  662.  
  663. description: aDescription
  664.     "sets the value of description"
  665.  
  666.     description := aDescription.!
  667.  
  668. initialize
  669.  
  670.     |days aStream aString field1 field2 field3 |
  671.     days:=((Date today) addDays: (self class defaults at: 1)) formPrint.
  672.     aStream := days asStream.
  673.     field1 := aStream nextWord asLowerCase.
  674.     field2 := aStream nextWord asLowerCase.
  675.     field3 := aStream nextWord asLowerCase.
  676.     aString := WriteStream on: (String new: 8).
  677.     aString nextPutAll: field3; nextPutAll:'.'; nextPutAll: field1;nextPutAll:'.'; nextPutAll: field2. 
  678.     self deadline: aString contents. 
  679.     self type: (self class defaults at: 2).
  680.     self priority: (self class defaults at: 3).
  681.     self description:'new'.
  682.     self completed: false.
  683.     ^self.!
  684.   
  685. pdsAsItem: aString
  686.  
  687.         "Takes a Percent delimited string (from the clipboard paste operation)
  688.           and returns a ToDoItem. Uses verifyItem to make sure it is a valid item
  689.           being returned."
  690.  
  691.         |anArray loop |
  692.  
  693. "Loop through string, checking it is percent delimited. If so, change any
  694.   blanks into right-brackets. Then change all percents into blanks. If it wasn't
  695.   a valid pdstring, return error."
  696.  
  697. loop := 1.
  698. ((aString at: 1) = $%) & ((aString at: 2) = $%)                            "Is it a pasted item ?"
  699.     ifTrue:[ aString do: [ :char | (char = $ )
  700.                                                 ifTrue:[ aString at: loop put: ${].
  701.                    loop := loop + 1
  702.                    ].
  703.         loop := 1.
  704.         aString do: [ :char | (char = $%)
  705.                                     ifTrue:[ aString at: loop put: $ ].
  706.             loop := loop + 1
  707.             ].
  708.  
  709.         "Get an array of substrings from aString (split at each blank (or blanks) occurance."
  710.         anArray := aString asArrayOfSubstrings.
  711.         
  712.         "Fill in the item."
  713.         self type: (anArray at: 1).
  714.         self deadline: (anArray at: ((anArray size) - 2)).
  715.         self priority: (anArray at: ((anArray size) - 1)).
  716.         (anArray at: (anArray size)) = 'true'
  717.             ifTrue:[self completed:true]
  718.             ifFalse:[self completed:false].
  719.  
  720.         "If there was a non-blank description field, assign it and reconvert the right brackets
  721.           back to blanks."
  722.         (anArray size) = 5
  723.             ifTrue:[ loop := 1.
  724.                 self description: ((anArray at: 2) do:[ :char | (char = ${)
  725.                                                                                                             ifTrue:[ (anArray at: 2) at: loop put: $ ].
  726.                                                                                             loop := loop + 1
  727.                                                                                         ])
  728.                         ]
  729.             ifFalse:[anArray at: 5 put: 'new'.].
  730.             ^nil]
  731.         ifFalse:[^'error - clipboard does not contain a valid item: ',aString ].!
  732.    
  733. printYourself
  734.  
  735.         "Print the text lines."
  736.     | aHandle |
  737.     CursorManager execute change.
  738.     aHandle := FileHandle openDevice: 'LPT1'.
  739.     aHandle deviceWrite: '***************************'.
  740.     aHandle deviceWrite: (String with: Lf with: Cr).
  741.     aHandle deviceWrite: (deadline, '  ',  type, '  ', description, '  ', priority).
  742.     aHandle deviceWrite: (String with: Lf with: Cr).
  743. "    aHandle deviceWrite: 'ToDo item printed'."
  744.     aHandle deviceWrite: (String with: Lf with: Cr).
  745.     aHandle close.
  746.     CursorManager normal change!
  747.    
  748. priority
  749.     "returns the value of priority"
  750.     ^priority!
  751.    
  752. priority: aPriority
  753.     "takes a string value and sets the value of priority using integers"
  754.  
  755.     priority := aPriority!
  756.  
  757. type
  758.     "returns the value of type"
  759.     ^type!
  760.    
  761. type: aType
  762.     "sets the value of type"
  763.     type := aType.!
  764.   
  765. verifyItem
  766.  
  767.     "Checks that an item contains allowable values for priority and type."
  768.     |errorType errorPriority|
  769.  
  770. ((ToDoItem typesAvailable) includes: (self type))
  771.     ifFalse:[ errorType := self type.
  772.                     ^'Type: ', errorType, ' incorrect - item not pasted'].
  773.  
  774. ((ToDoPriorityList new prioritiesAvailable) includes: (self priority))
  775.     ifFalse:[ errorPriority := self priority.
  776.                     ^'Priority: ', errorPriority, ' incorrect - item not pasted'].
  777.  
  778. ^nil! !
  779.  
  780.  
  781.  
  782. !ToDoPriorityList methods !
  783.  
  784. initialize
  785.     |loop|
  786.     loop :=1.
  787.     self class priorities do: [ :a | self at: loop put: a.  
  788.                                                             loop := loop+1 ].
  789.  
  790. ^self.!
  791.  
  792. prioritiesAvailable
  793.  
  794.     ^self class priorities.! !
  795.  
  796.  
  797.  
  798. !ToDoList methods !
  799.    
  800. addItem: anItem
  801.  
  802.     "Add the item to the list.  "
  803.  
  804.     self add: anItem .
  805. "    self sortList.
  806.     ^(self indexOf: anItem)."
  807.     ^endPosition.!
  808.  
  809. readList
  810.  
  811.     "Read the ToDo list from disk.
  812.      The list is stored as a Smalltalk collection
  813.      (using the ObjectFiler).  It is read, then sorted.
  814.      This method is used  when ToDoList view is opened."
  815.  
  816.    |input tempList |
  817.  
  818.     input := Disk file: 'TODO\TODOFILE.OBJ'.
  819.     ((input contents) = '') 
  820.         ifFalse: [ tempList := ObjectFiler loadFromPathName: 'TODO\TODOFILE.OBJ'.
  821.             (self replaceFrom:1 to:(self size) with: tempList).
  822.         ].
  823.     input close.
  824. ^self.!
  825.  
  826. removeAll
  827.       " Remove the contents of the ToDoList"
  828.  
  829.        ^( super removeAll: self ) .!
  830.  
  831. removeItem:anItemIndex
  832.  
  833.     "Remove an item.  "
  834.  
  835.      super removeIndex: anItemIndex .
  836.  
  837.     ^self.!
  838.    
  839. sortList
  840.  
  841.     "Resort the list of items and return the list. "
  842.  
  843.       | tempList |
  844.  
  845.       ( self size  > 1 )
  846.              ifTrue: [ tempList := self asSortedCollection:
  847.                                     [ :a :b | a compareTo: b using: sortKey order: sortOrder] .
  848.                           self replaceFrom:1 to: (self size) with: tempList.
  849.                             ].
  850.       ^ self .!
  851.  
  852. sortList: aSortKey order: aSortOrder
  853.  
  854.     "Update the sortKey and Order "
  855.  
  856.     |pDict|
  857.  
  858.     sortKey := aSortKey .
  859.     sortOrder := aSortOrder.
  860.  
  861.     "Priority is stored as a string. To allow sorting, an integer value is put into priority for 
  862.       the sort. The value is based on ToDoPriorityList's entry for each priority value."
  863.  
  864.       (sortKey = 'priority')
  865.         ifTrue:[ pDict := ToDoPriorityList new initialize.
  866.              self do:[ :eachItem| eachItem priority: (pDict keyAtValue: ( eachItem priority))].
  867.              self sortList.
  868.              self do:[ :eachItem| eachItem priority: (pDict at: ( eachItem priority))].
  869.         ]
  870.         ifFalse:[ self sortList.].
  871. ^ self.!
  872.  
  873. updateItem:anItem at:anIndex
  874.  
  875.     "Change an item in the list.  "
  876.  
  877.     self at: anIndex  put: anItem .
  878. "    self sortList."
  879.     ^(self indexOf: anItem).!
  880.  
  881. writeList
  882.     "Write the ToDo list on disk using ObjectFiler. "
  883.  
  884. | saveFileName |
  885.  
  886.     saveFileName := 'TODO\TODOFILE.OBJ'.
  887.     ObjectFiler dump: self newFile: saveFileName.
  888. ^saveFileName.! !
  889.  
  890.  
  891.  
  892. !ToDoSettings methods !
  893.  
  894. codePage
  895.     ^codePage!
  896.    
  897. codePage: aCodePage
  898.  
  899.         "Values harcoded in ToDoSettingsView class (openCountry method)."
  900.     codePage := aCodePage!
  901.  
  902. country
  903.     ^country!
  904.  
  905. country: aCountry
  906.  
  907.         "Values harcoded in ToDoSettingsView class (openCountry method)."
  908.  
  909.     country := aCountry!
  910.    
  911. deadlineDefault: aDay
  912.  
  913.     defaultItem at: 1 put: aDay.!
  914.  
  915. defaultItem
  916.  
  917. ^defaultItem!
  918.  
  919. defaultItem: aCollection
  920.     "Sets the value of the currently held default Item"
  921.  
  922.     defaultItem := aCollection.
  923.     ToDoItem defaults: aCollection.!
  924.    
  925. defaultSettings
  926.  
  927.     "private - only used if no object stored on disk."
  928.  
  929.     self sortKey: 'priority';
  930.         sortOrder: 'ascending';
  931.         codePage: '850';
  932.         country:'UK';
  933.         includeCriterion: 'all'.
  934.         self setDefaultPriorities.!
  935.  
  936. exchangeWithSavedSettings: savedSettings
  937.  
  938.         "Exchange values so that this object has the values from the
  939.           disk-saved settings. Did this because you cannot assign self 
  940.           to an object."
  941.  
  942. self sortKey: savedSettings sortKey;
  943.     codePage: savedSettings codePage;
  944.     sortOrder: savedSettings sortOrder;
  945.     country: savedSettings country;
  946.     includeCriterion: savedSettings includeCriterion.
  947.  
  948.     (savedSettings defaultItem isNil)
  949.         ifTrue:[self setDefaultItem]
  950.         ifFalse:[self defaultItem: (savedSettings defaultItem)].!
  951.  
  952. includeCriterion
  953.     ^includeCriterion!
  954.    
  955. includeCriterion: anIncludeCriterion
  956.  
  957.         "Values possible are all, completed or uncompleted"
  958.  
  959.     includeCriterion := anIncludeCriterion!
  960.    
  961. initialise    
  962.  
  963.     "called from class method new, here we check for a previous
  964.      saved settings object; if we find one, we tell the view the 
  965.      settings it needs to display, else it comes up blank."
  966.  
  967.     self readSettings.!
  968.    
  969. priorityDefault: aPriority
  970.  
  971.     defaultItem at: 3 put: aPriority.!
  972.    
  973. readSettings
  974.  
  975.         "Here is where the settings get read from disk (using the ObjectFiler).
  976.           The defaults are hardwired in below. Other Jingoists may set their own!!
  977.         
  978.           Note that the order, country and code page are not implemented in the
  979.           ListView so it is only affected by the sortKey settings."
  980.  
  981.     | input tempSettings|
  982.     input := Disk file: 'TODO\TODOFILE.SET'.
  983.     input close.
  984.     input := Disk file: 'TODO\TODOFILE.SET'.
  985.     ((input contents) = '') ifTrue: [            
  986.                 self defaultSettings; 
  987.                     setDefaultItem.
  988.                ] 
  989.     ifFalse: [
  990.         tempSettings := ObjectFiler loadFromPathName: 'TODO\TODOFILE.SET'.
  991.         self exchangeWithSavedSettings: tempSettings.
  992.         self setDefaultPriorities.
  993.     ].
  994.  
  995.     input close.!
  996.   
  997. setDefaultItem
  998.  
  999.     "private - only used if no object stored on disk."
  1000.     | coll |
  1001.     coll := OrderedCollection new.
  1002.     coll add: 1; add: 'Phone'; add: 'High'.
  1003.     self defaultItem: coll.
  1004.     ^self.!
  1005.  
  1006. setDefaultPriorities
  1007.     "private - only used if no object stored on disk."
  1008.  
  1009.     ToDoPriorityList priorities: #('High' 'Medium' 'Low').
  1010.     ^self.!
  1011.   
  1012. settings
  1013.         "If asked, return ourselves ie a Settings object"
  1014.  
  1015.     ^self.!
  1016.    
  1017. sortKey
  1018.  
  1019.     ^sortKey!
  1020.    
  1021. sortKey: aKey
  1022.  
  1023.     sortKey := aKey!
  1024.   
  1025. sortOrder
  1026.     ^sortOrder!
  1027.  
  1028. sortOrder: aSortOrder
  1029.     sortOrder  := aSortOrder!
  1030.    
  1031. typeDefault: aType
  1032.  
  1033.     defaultItem at: 2 put: aType.!
  1034.    
  1035. writeSettings
  1036.  
  1037.     "Here is where the settings get written to disk (using the ObjectFiler)."
  1038.  
  1039.     |saveFileName|
  1040.  
  1041.     saveFileName := 'TODO\TODOFILE.SET'.
  1042.     ObjectFiler dump: self newFile: saveFileName.
  1043.  
  1044. ^saveFileName.! !
  1045.  
  1046.  
  1047.  
  1048. !ToDoRowDisplay methods !
  1049.    
  1050. aCheck: aCheckBox
  1051.  
  1052.         "aCheckBox has been clicked"
  1053.  
  1054.     ^nil!
  1055.  
  1056. addFields
  1057.  
  1058.     ((Display extent) = (640@480)) ifTrue: [ self addVgaFields ]
  1059.         ifFalse: [ self addXgaFields  ].!
  1060.  
  1061. addVgaFields
  1062.  
  1063. | fld |
  1064.  
  1065.     fieldList := OrderedCollection new.
  1066.  
  1067.     self addSubpane:
  1068.         ((deadline :=  EntryField new)
  1069.             owner: self;
  1070.             framingRatio: ((4/100) @ (82/100) 
  1071.                 extentFromLeftTop: (10/100) @ (64/100))).
  1072.  
  1073.     fieldList add: deadline.
  1074.  
  1075.   self
  1076.      addSubpane: 
  1077.             ( (type := SpinButton leftJustifiedText )
  1078.                  owner: self;
  1079.                  contents: ToDoItem typesAvailable;
  1080.                   framingRatio: ((15/100) @ (11/10) 
  1081.                 extentFromLeftTop: (20/100) @ 1)).
  1082.  
  1083.     fieldList add: type.
  1084.  
  1085.     self addSubpane:
  1086.         ((description :=  EntryField new)
  1087.             owner: self;          
  1088.             framingRatio: ((36/100) @ (82/100) 
  1089.                 extentFromLeftTop: (45/100) @ (64/100))).
  1090.  
  1091.     fieldList add: description.
  1092.  
  1093.  self addSubpane:
  1094.         ((priority := SpinButton leftJustifiedText )
  1095.             owner: self;
  1096.             contents: (ToDoPriorityList new prioritiesAvailable);        
  1097.             framingRatio: ((82/100) @ (11/10)  
  1098.                     extentFromLeftTop: (10/100) @ 1 )).
  1099.  
  1100.     fieldList add: priority.
  1101.  
  1102.     self
  1103.          addSubpane: 
  1104.             ((completed :=  CheckBox new)
  1105.                  owner: self;
  1106.                  contents: '';
  1107.                  when: #clicked perform: #aCheck: ;
  1108.                     framingRatio: ((94/100) @ 1  
  1109.                     extentFromLeftTop: (7/100) @ 1 )).
  1110.     fieldList  add: completed.!
  1111.  
  1112. addXgaFields
  1113.  
  1114. | fld |
  1115.  
  1116.     fieldList := OrderedCollection new.
  1117.  
  1118.     self addSubpane:
  1119.         ((deadline :=  EntryField new)
  1120.             owner: self;
  1121.             framingRatio: ((4/100) @ (75/100) 
  1122.                 extentFromLeftTop: (10/100) @ (65/100))).
  1123.  
  1124.     fieldList add: deadline.
  1125.  
  1126.   self
  1127.      addSubpane: 
  1128.             ( (type := SpinButton leftJustifiedText )
  1129.                  owner: self;
  1130.                  contents: ToDoItem typesAvailable;
  1131.                   framingRatio: ((15/100) @ 1 
  1132.                 extentFromLeftTop: (19/100) @ 1)).
  1133.  
  1134.     fieldList add: type.
  1135.  
  1136.     self addSubpane:
  1137.         ((description :=  EntryField new)
  1138.             owner: self;          
  1139.             framingRatio: ((35/100) @ (75/100) 
  1140.                 extentFromLeftTop: (45/100) @ (65/100))).
  1141.  
  1142.     fieldList add: description.
  1143.  
  1144.  self addSubpane:
  1145.         ((priority := SpinButton leftJustifiedText )
  1146.             owner: self;
  1147.             contents: (ToDoPriorityList new prioritiesAvailable);        
  1148.             framingRatio: ((81/100) @ 1  
  1149.                     extentFromLeftTop: (8/100) @ 1 )).
  1150.  
  1151.     fieldList add: priority.
  1152.  
  1153.     self
  1154.          addSubpane: 
  1155.             ((completed :=  CheckBox new)
  1156.                  owner: self;
  1157.                  contents: '';
  1158.                  when: #clicked perform: #aCheck: ;
  1159.                     framingRatio: ((93/100) @ 1  
  1160.                     extentFromLeftTop: (8/100) @ 1 )).
  1161.     fieldList  add: completed.!
  1162.   
  1163. checkDate
  1164.  
  1165.     "check that the date is valid"
  1166.     | aStream field1 field2 field3 day month year |
  1167.  
  1168.     aStream := (deadline contents) asStream.
  1169.     field1 := aStream nextWord asLowerCase.
  1170.     field2 := aStream nextWord asLowerCase.
  1171.     field3 := aStream nextWord asLowerCase.
  1172.     ((field2 asInteger) > 12) | ((field3 asInteger) < 1)
  1173.                 ifTrue: [^false]
  1174.                 ifFalse: [ 
  1175.                         month := Date nameOfMonth: (field2 asInteger).
  1176.                         year := field1 asInteger.
  1177.                         year < 100 ifTrue: [year := year + 1900].
  1178.                                 ].
  1179.     day := field3 asInteger.
  1180.     day > (Date daysInMonth: month forYear: year)
  1181.                 ifTrue: [^false].
  1182.     ^true.!
  1183.    
  1184. close: aWin
  1185.  
  1186.     ^super close!
  1187.    
  1188. ctlWindow: aWindow
  1189.  
  1190.     ctlWindow := aWindow!
  1191.  
  1192. currentItem
  1193.  
  1194.     | item |
  1195.  
  1196.     item := ToDoItem new.
  1197.  
  1198.     item deadline: deadline contents.
  1199.     item description: description contents.
  1200.     item type: type selection.
  1201.     item priority: priority selection.
  1202.     item completed: completed getValue.
  1203.     ^item!
  1204.  
  1205. displayItem: anItem
  1206.  
  1207.     deadline contents: anItem deadline.
  1208.     description contents: anItem description.
  1209.     type selection: anItem type.
  1210.     priority selection: anItem priority.
  1211.     completed selection: anItem completed.!
  1212.  
  1213. hide
  1214.  
  1215.     (views at: 1) hideWindow.
  1216.     ((views at: 1) parent ) hideWindow.!
  1217.    
  1218. initWindow
  1219.  
  1220.     self 
  1221.         labelWithoutPrefix: 'ToDo Row Display';
  1222.         owner: self;
  1223.         when: #close perform: #close: ;
  1224.         addFields.
  1225.     HelpManager for: (self mainView) title: 'Help' file: 'todo\todo.hlp'.
  1226.  
  1227.     ^self!
  1228.  
  1229. initWindow: anOwner
  1230.  
  1231.     ^self labelWithoutPrefix: 'Row Display';
  1232.         owner: anOwner;
  1233.         when: #close perform: #close: ;
  1234.         addFields.!
  1235.    
  1236. initWindowSize
  1237.         "Private - Answer the initial size of the receiver."
  1238.  
  1239.     ^(Display width * 19 //20) @ (Display height * 1 // 18).!
  1240.   
  1241. moveAbsolute: aRect
  1242.     
  1243.     | rect |
  1244.  
  1245.     rect := aRect.
  1246.     PMWindowLibrary setWindowPos: (((views at: 1) parent) handle)
  1247.         hwndInsertBehind: HwndTop
  1248.         x: rect origin x
  1249.         y: rect origin y 
  1250.         cx: rect width
  1251.         cy: rect height
  1252.         fs: SwpMove | SwpSize | SwpZorder!
  1253.    
  1254. newItem
  1255.     "this is the method we would change if we wanted to 
  1256.     change any of the default ToDoItem settings in the settings view.
  1257.     Today, this method simply copies the selected item."
  1258.  
  1259.     ^ToDoItem newItem.!
  1260.    
  1261. newItem: anItem
  1262.  
  1263.     deadline contents: anItem deadline.
  1264.     description contents: anItem description.
  1265.     type selection: anItem type.
  1266.     priority selection: anItem priority.
  1267.     completed selection: anItem completed.!
  1268.  
  1269. open
  1270. self halt.
  1271.     self initWindow.
  1272.  
  1273.     self openWindow.!
  1274.    
  1275. openWindow: aRect
  1276.  
  1277.     ^((views at: 1) openWindow: aRect )!
  1278.   
  1279. rowDown
  1280.  
  1281.     ctlWindow rowDown!
  1282.   
  1283. rowUp
  1284.  
  1285.     ctlWindow rowUp!
  1286.   
  1287. show
  1288.  
  1289.     (views at: 1) showWindow.
  1290.  
  1291.     ((views at: 1) parent ) showWindow.!
  1292.  
  1293. tabToNextField
  1294. | index |
  1295.  
  1296.     index := 0.
  1297.  
  1298.     fieldList do: 
  1299.         [ :field |
  1300.             index := index + 1.
  1301.             (field haveFocus) ifTrue: [
  1302.                 ((index+1) = 5) ifTrue: [ index := 0 ].
  1303.                 (fieldList at: (index+1)) setFocus.
  1304.                 ^ nil ].                
  1305.         ]!
  1306.  
  1307. tabToPrevField
  1308.  
  1309.     ^nil!
  1310.  
  1311. topPaneClass
  1312.         "Private - Answer the default top pane class."
  1313.     ^SimpleTopPane! !
  1314.  
  1315.  
  1316.  
  1317. !ToDoSettingsView methods !
  1318.   
  1319. addCountryPage
  1320. | page |
  1321.  
  1322.     page := NotebookPage new
  1323.                     window: countryPage. 
  1324.     page
  1325.         minor
  1326.         tab: ('Country').
  1327.     notebook appendPage: page.!
  1328.  
  1329. addDefaultPage
  1330. | page |
  1331.  
  1332.     page := NotebookPage new
  1333.                     window: defaultsPage. 
  1334.     page
  1335.         minor
  1336.         tab: ('Sorting').
  1337.     notebook appendPage: page.
  1338.     topPage := page.!
  1339.  
  1340. addDefaultsPage
  1341. | page |
  1342.  
  1343.     page := NotebookPage new
  1344.                     window: defaultsPage. 
  1345.     page
  1346.         minor
  1347.         tab: ('Defaults').
  1348.     notebook appendPage: page.
  1349.     topPage := page.!
  1350.   
  1351. addIncludePage
  1352. | page |
  1353.  
  1354.     page := NotebookPage new
  1355.                     window: includePage. 
  1356.     page
  1357.         minor
  1358.         tab: ('Include').
  1359.     notebook appendPage: page.!
  1360.  
  1361. addSortPage
  1362. | page |
  1363.  
  1364.     page := NotebookPage new
  1365.                     window: sortPage. 
  1366.     page
  1367.         minor
  1368.         tab: ('Sorting').
  1369.     notebook appendPage: page.
  1370.     topPage := page.!
  1371.    
  1372. allPress: aButton
  1373.     
  1374.         "User pressed the radio button that includes all items in the
  1375.           list view. "
  1376.  
  1377.     ctlSettings includeCriterion: 'all'.!
  1378.    
  1379. applyButton: aButton
  1380.  
  1381.         "When the apply button is pressed, this view finds which settings
  1382.           are currently selected and tells the settings model. It then informs
  1383.           the ListView that things have changed ie do a refresh. To get back
  1384.           to the previous settings, the user needs to do a RESET."
  1385.  
  1386.     "ctlSettings "
  1387.     ctlView refreshButton: nil.!
  1388.    
  1389. ascendingPress: aButton
  1390.     
  1391.         "User pressed the radio button that chooses an ascending sort order in the
  1392.           list view. "
  1393.  
  1394.     ctlSettings sortOrder: 'ascending'.!
  1395.  
  1396. close: aView
  1397.  
  1398.  "    ctlView showRow."
  1399.     ^super close.!
  1400.    
  1401. codePageChanged: aComboBox
  1402.  
  1403.         "A different value has been choosen for the codePagesetting -
  1404.           this is where it gets updated."
  1405.  
  1406.     ctlSettings codePage: ( aComboBox text ).!
  1407.    
  1408. compPress: aButton
  1409.     
  1410.         "User pressed the radio button that includes only completed items in the
  1411.           list view. "
  1412.  
  1413.     ctlSettings includeCriterion: 'completed'.!
  1414.  
  1415. countryChanged: aComboBox
  1416.  
  1417.         "A different value has been choosen for the country setting -
  1418.           this is where it gets updated."
  1419.  
  1420.     ctlSettings country: ( aComboBox text ).!
  1421.  
  1422. ctlView: aView andSettings: aToDoSettings
  1423.  
  1424.  
  1425.         "aView - This is the ToDoListView that opened this SettingsView,
  1426.           and aToDoSettings is the Settings object in force (opened by
  1427.           ToDoListView)."
  1428.  
  1429.     ctlView := aView. 
  1430.     ctlSettings := aToDoSettings.
  1431.  
  1432.         "The SettingsView (this object) then gets its setting info from
  1433.           the ToDoSetting object previously saved on disk."
  1434.  
  1435.     self initialiseControls.!
  1436.    
  1437. deadlineDefaultChange: aSpinButton
  1438.  
  1439. ctlSettings deadlineDefault: aSpinButton selection.!
  1440.   
  1441. deadlinePress: aButton
  1442.     
  1443. | settings |
  1444.  
  1445.     settings := ctlView settings.
  1446.     settings sortKey: 'deadline'.
  1447.     ctlView settings: settings.!
  1448.  
  1449. descendingPress: aButton
  1450.     
  1451.         "User pressed the radio button that chooses an descending sort order in the
  1452.           list view. "
  1453.  
  1454.     ctlSettings sortOrder: 'descending'.!
  1455.   
  1456. descriptionPress: aButton
  1457.     
  1458. | settings |
  1459.  
  1460.     settings := ctlView settings.
  1461.     settings sortKey: 'description'.
  1462.     ctlView settings: settings.!
  1463.   
  1464. initialiseControls
  1465.  
  1466.         "Get the settings from the saved version and initialise the buttons
  1467.           and fields to reflect the settings. If no saved version available,
  1468.           put in some defaults.
  1469.  
  1470.           Warning: Implementation kludge!! All the notebook's controls are
  1471.           saved in a Dictionary when created - this is how  we get
  1472.           to them to set the initial state. We used a Dictionary rather than
  1473.           many instance variables cluttering up the class. The location of 
  1474.           each control in the Dictionary is dependant on the order of adding 
  1475.           them. "
  1476.  
  1477.     "First the sortField radioButtons"
  1478.     "Next the sortOrder radioButtons"
  1479.     "Next the includeCriterion radioButtons"
  1480.     "Next the defaultItem settings for when a new item is added to the list."
  1481.     "Finally the country and codePage combo boxes"
  1482.  
  1483.     (nbControls at: (ctlSettings sortKey)) selection: true.
  1484.     (nbControls at: (ctlSettings sortOrder)) selection: true.
  1485.     (nbControls at: (ctlSettings includeCriterion)) selection: true.
  1486.      (nbControls at: 'deadlineDefault') selection: (ctlSettings defaultItem at:1).
  1487.      (nbControls at: 'priorityDefault') selection: (ctlSettings defaultItem at:3).
  1488.      (nbControls at: 'typeDefault') selection: (ctlSettings defaultItem at:2).
  1489.     (nbControls at: 'codePage') selectItem: (ctlSettings codePage).
  1490.     (nbControls at: 'country') selectItem: (ctlSettings country).!
  1491.    
  1492. initWindowSize
  1493.         "Private - Answer the initial size of the receiver."
  1494.  
  1495.     ^(Display width * 3//5) @ (Display height * 4//7).!
  1496.  
  1497. menuSetup
  1498.  
  1499.     (self menuTitled:'ThingsToDo') disableItem:'Open as ~Settings'. 
  1500.     (self menuTitled:'Edit') disableItem:'~Undo'. 
  1501.     (self menuTitled:'Edit') disableItem:'~Redo'. 
  1502.     (self menuTitled:'View') disableItem:'Se~ttings'.!
  1503.    
  1504. open
  1505.  
  1506.     self labelWithoutPrefix: ' Things To-Do Settings View';
  1507.         owner: self.
  1508.     self when: #close perform: #close: .
  1509.    
  1510.      self addSubpane: ( notebook := Notebook new
  1511.         owner:self;
  1512.         pageButtonExtent: 30 @ 30;
  1513.         majorTabExtent: 10 @ 20;
  1514.         minorTabExtent: 70 @ 20;
  1515.          style: BksPolygontabs;
  1516.         framingRatio: ((1/20) @ (19/20)
  1517.             extentFromLeftTop: (18/20) @ (4/5))).
  1518.  
  1519.     self addSubpane: (Button new
  1520.         owner: self;
  1521.         when: #clicked perform: #applyButton: ;
  1522.         contents: '~Apply';
  1523.         framingRatio: ((1/15) @ (1/40) 
  1524.                 extent: (1/4) @ (1/10))).
  1525.  
  1526.      self addSubpane: (Button new
  1527.         owner: self;
  1528.         when: #clicked perform: #saveButton: ;
  1529.         contents: '~Save';
  1530.         framingRatio: ((11/32) @ (1/40) 
  1531.                 extent: (1/4) @ (1/10))).
  1532.  
  1533.     self addSubpane: (Button new
  1534.         owner: self;
  1535.         when: #clicked perform: #resetButton: ;
  1536.         contents: '~Reset';
  1537.         framingRatio: ((5/8) @ (1/40) 
  1538.                 extent: (1/4) @ (1/10))).
  1539.  
  1540.         "At some point we must fill in the settings that have been retrieved
  1541.           from the ctlSettings object. nbControls is the dictionary that accesses
  1542.           the controls used in the notebook. It is set up in the following methods:
  1543.           sortGroup, OrderGroup, IncludeGroup & CountryWindow. Here we just
  1544.           instantiate the object. The actual settings are done in initialiseControls,
  1545.           which is called from ctlView:andSettings:."
  1546.  
  1547.     nbControls := Dictionary new.
  1548.     
  1549.  
  1550.     self openSortWindow;
  1551.         openIncludeWindow;
  1552.         openCountryWindow;
  1553.         openDefaultsWindow;
  1554.         addCountryPage;
  1555.         addIncludePage;
  1556.         addDefaultsPage;
  1557.         addSortPage.
  1558.  
  1559.     notebook selection: topPage.
  1560.     HelpManager for: (self mainView) title: 'Help' file: 'todo\todo.hlp'.
  1561.     self     openWindow.
  1562.  
  1563.     "Since we opened as a ToDoSetting (rather than a List) grey out the
  1564.       inappropriate menu options."
  1565.     self menuSetup.!
  1566.  
  1567. openCountryWindow
  1568.  
  1569.     | mainWindow |
  1570.     notebook addSubpane: (countryPage := GroupPane new
  1571.         owner: self).
  1572.     countryPage style: (countryPage frameStyle - FcfBorder).
  1573.  
  1574.     countryPage 
  1575.         addSubpane: 
  1576.              ( ( StaticText new )
  1577.                     contents: 'Codepage';
  1578.                     framingRatio: ((1/2) @ 1 
  1579.                 extentFromLeftTop: (1/4) @ (1/7))).
  1580.  
  1581.     countryPage addSubpane: (nbControls at: 'codePage' put:  (ComboBox new "dropDown" 
  1582.                 owner: self;
  1583.                 contents: #( '850' '437'  '285'  '007'  );
  1584.               when: #textChanged perform: #codePageChanged:; 
  1585.                 framingRatio: ((1/2) @ (2/3) 
  1586.           extentFromLeftTop: (1/3) @ (1/2)))).
  1587.  
  1588.     countryPage 
  1589.         addSubpane: 
  1590.              ( ( StaticText new )
  1591.                     contents: 'Country';
  1592.                     framingRatio: ((1/16) @ 1 
  1593.                 extentFromLeftTop: (1/4) @ (1/7))).
  1594.  
  1595.     countryPage addSubpane: (nbControls at: 'country' put:  (ComboBox new "dropDown"
  1596.                 owner: self;
  1597.                 contents: #( 'UK' 'Japan' 'Belgium' 'Finland' 'South Africa'  'Germany'  'Italy'  );
  1598.               when: #textChanged perform: #countryChanged:; 
  1599.                 framingRatio: ((1/16) @ (2/3) 
  1600.           extentFromLeftTop: (1/3) @ (1/2)))).
  1601.  
  1602. "Authors: 6/12/91 ITSC Boca
  1603.  
  1604.     Jouko Ruuskanen
  1605.     Giffin Lorimer
  1606.     Osamu Ochiai
  1607.     Raj Singh"!
  1608.   
  1609. openDefaultsWindow
  1610.  
  1611.     | mainWindow |
  1612.     notebook addSubpane: (defaultsPage := GroupPane new
  1613.         owner: self).
  1614.     defaultsPage style: (defaultsPage frameStyle - FcfBorder).
  1615.  
  1616.     defaultsPage 
  1617.         addSubpane: 
  1618.              ( ( StaticText new )
  1619.                     contents: 'Application Defaults';
  1620.                     framingRatio: ((1/4) @ 1 
  1621.                 extentFromLeftTop: (1/2) @ (1/7))).
  1622.  
  1623.     defaultsPage 
  1624.         addSubpane: 
  1625.              ( ( StaticText new )
  1626.                     contents: 'Deadline - Today plus';
  1627.                     framingRatio: ( ( ( Rectangle leftTopUnit right: ( 1/32 ) ) down: 1/5)
  1628.                      extentFromLeftTop: 6 @ 3/16 )).
  1629.  
  1630.     defaultsPage
  1631.         addSubpane:  (nbControls at: 'deadlineDefault' put: (SpinButton numeric
  1632.             minimum: 0;
  1633.             maximum: 31;
  1634.             when: #textChanged perform: #deadlineDefaultChange: ;    
  1635.             framingRatio: ( ( (Rectangle leftTopUnit right: ( 7/16 ) ) down: 1/5)
  1636.                      extentFromLeftTop: 3/4@ 1/8 ))).
  1637.  
  1638. defaultsPage 
  1639.         addSubpane: 
  1640.              ( ( StaticText new )
  1641.                     contents: 'days';
  1642.                     framingRatio: ( ( ( Rectangle leftTopUnit right: ( 9/16 ) ) down: 1/5)
  1643.                      extentFromLeftTop: 3/2 @ 3/16 )).
  1644.  
  1645.     defaultsPage 
  1646.         addSubpane: 
  1647.              ( ( StaticText new )
  1648.                     contents: 'Type';
  1649.                     framingRatio: ( ( ( Rectangle leftTopUnit right: ( 1/32 ) ) down: 2/5)
  1650.                      extentFromLeftTop: 3/2 @ 3/16 )).
  1651.  
  1652.     defaultsPage
  1653.         addSubpane:  (nbControls at:'typeDefault' put: (SpinButton leftJustifiedText
  1654.             contents: (ToDoItem typesAvailable) ;
  1655.             when: #textChanged perform: #typeDefaultChange: ;    
  1656.             framingRatio: ( ( (Rectangle leftTopUnit right: ( 7/16 ) ) down: 2/5)
  1657.                      extentFromLeftTop: 5/2 @ 1/8 ))).
  1658.  
  1659.     defaultsPage 
  1660.         addSubpane: 
  1661.              ( ( StaticText new )
  1662.                     contents: 'Priority';
  1663.                     framingRatio: ( ( ( Rectangle leftTopUnit right: ( 1/32 ) ) down: 3/5)
  1664.                      extentFromLeftTop: 3/2 @ 1/4 )).
  1665.  
  1666.     defaultsPage
  1667.         addSubpane:  (nbControls at: 'priorityDefault' put: (SpinButton leftJustifiedText
  1668.             contents: (ToDoPriorityList new prioritiesAvailable);
  1669.             when: #textChanged perform: #priorityDefaultChange: ;    
  1670.             framingRatio: ( ( (Rectangle leftTopUnit right: ( 7/16 ) ) down: 3/5)
  1671.                      extentFromLeftTop: 2 @ 1/8 ))).
  1672.  
  1673. "Authors: 6/12/91 ITSC Boca
  1674.  
  1675.     Jouko Ruuskanen
  1676.     Giffin Lorimer
  1677.     Osamu Ochiai
  1678.     Raj Singh"!
  1679.  
  1680. openIncludeGroup: groupPane 
  1681.     | height inset |
  1682.     inset := 1/16.
  1683.     height := 1/5.
  1684.     groupPane
  1685.         addSubpane:
  1686.             (
  1687.             GroupBox new
  1688.                 owner: self;
  1689.                 style: GroupPane noBorderFrameStyle;
  1690.                 contents: 'Sort field:';
  1691.                 framingRatio: ( 0@0 extent: 1@1 );
  1692.                 yourself
  1693.             );
  1694.         addSubpane: 
  1695.             ( nbControls at: 'all' put: (RadioButton new        
  1696.                       owner: self;   
  1697.                      contents: 'All Items';   
  1698.                      when: #clicked perform: #allPress:; 
  1699.             framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 1/4 )
  1700.               extentFromLeftTop: 7/8  @ height )
  1701.             ));
  1702.         addSubpane: 
  1703.             ( nbControls at: 'completed' put: (RadioButton new
  1704.                        owner: self;   
  1705.                     contents: 'Completed Items only';    
  1706.                     when: #clicked perform: #compPress:;
  1707.             framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 2/4 )
  1708.               extentFromLeftTop: 7/8  @ height )
  1709.             ));
  1710.     addSubpane: 
  1711.             ( nbControls at: 'uncompleted' put: (RadioButton new
  1712.                      owner: self;   
  1713.                       contents: 'Uncompleted Items only';    
  1714.                 when: #clicked perform: #uncompPress:;
  1715.             framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 3/4 )
  1716.               extentFromLeftTop: 7/8  @ height )
  1717.             )).!
  1718.  
  1719. openIncludeWindow
  1720.  
  1721.     | mainWindow group |
  1722.     notebook addSubpane: (includePage := GroupPane new
  1723.         owner: self).
  1724.     includePage style: (includePage frameStyle - FcfBorder).
  1725.  
  1726.     includePage 
  1727.         addSubpane: 
  1728.              ( ( StaticText new )
  1729.                     contents: 'Include defaults';
  1730.                     framingRatio: ((1/4) @ 1 
  1731.                 extentFromLeftTop: (1/2) @ (1/7))).
  1732.  
  1733.     includePage addSubpane:
  1734.             (
  1735.             group := GroupPane new
  1736. "            style: GroupPane noBorderFrameStyle;"
  1737.             framingRatio: 
  1738.                 ( ( ( Rectangle leftTopUnit right: (1/16) ) down: 1/6 )
  1739.                       extentFromLeftTop: ( 1/2 ) @ ( 3/4 ) );
  1740.             yourself
  1741.             ).
  1742.         self openIncludeGroup: group.!
  1743.    
  1744. openOrderGroup: groupPane 
  1745.     | height inset |
  1746.     inset := 1/16.
  1747.     height := 1/5.
  1748.     groupPane
  1749.         addSubpane:
  1750.             (
  1751.             GroupBox new
  1752.                 owner: self;
  1753. "                style: GroupPane noBorderFrameStyle;"
  1754.                 contents: 'Sort order:';
  1755.                 framingRatio: ( 0@0 extent: 1@1 );
  1756.                 yourself
  1757.             );
  1758.         addSubpane: 
  1759.             ( nbControls at: 'ascending' put: (RadioButton new        
  1760.                         owner: self;   
  1761.                         contents: 'Ascending';    
  1762.                      when: #clicked perform: #ascendingPress:; 
  1763.             framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 1/4 )
  1764.               extentFromLeftTop: 7/8  @ height )
  1765.             ));
  1766.     addSubpane: 
  1767.         ( nbControls at: 'descending' put: (RadioButton new
  1768.                 owner: self;   
  1769.                 contents: 'Descending';    
  1770.               when: #clicked perform: #descendingPress:; 
  1771.         framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 1/2 )
  1772.             extentFromLeftTop: 7/8  @ height )
  1773.         )).!
  1774.   
  1775. openSortGroup: groupPane 
  1776.  
  1777.         "This is where the controls in the sort field of the default (sort) page of the 
  1778.           notebook control  are set up. The dimensions of the group first, then the 
  1779.           controls themselves inside the group pane."
  1780.         
  1781.     | height inset|
  1782.     inset := 1/16.
  1783.     height := 1/5.
  1784.     groupPane
  1785.         addSubpane:
  1786.             (
  1787.             GroupBox new
  1788.                 owner: self;
  1789. "                style: GroupPane noBorderFrameStyle;"
  1790.                 contents: 'Sort field:';
  1791.                 framingRatio: ( 0@0 extent: 1@1 );
  1792.                 yourself
  1793.             ).        
  1794.  
  1795.     groupPane    
  1796.       addSubpane: 
  1797.         ( nbControls at: 'description' put: (RadioButton new        
  1798.             owner: self;   
  1799.             contents: 'Description';
  1800.             when: #clicked perform: #descriptionPress:; 
  1801.         framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 1/8 )
  1802.           extentFromLeftTop: 7/8  @ height )
  1803.         )).
  1804.  
  1805.  
  1806.     groupPane
  1807.       addSubpane: 
  1808.         ( nbControls at: 'deadline' put: (RadioButton new        
  1809.             owner: self;   
  1810.             contents: 'Deadline';   
  1811.             when: #clicked perform: #deadlinePress:; 
  1812.         framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 5/16 )
  1813.           extentFromLeftTop: 7/8  @ height )
  1814.         )).
  1815.  
  1816.     groupPane
  1817.       addSubpane: 
  1818.         ( nbControls at: 'type' put: (RadioButton new
  1819.             owner: self;   
  1820.             contents: 'Type';    
  1821.             when: #clicked perform: #typePress:;
  1822.         framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 1/2 )
  1823.           extentFromLeftTop: 7/8  @ height )
  1824.         )).
  1825.  
  1826.     groupPane
  1827.       addSubpane: 
  1828.         ( nbControls at: 'priority' put: (RadioButton new
  1829.             owner: self;   
  1830.             contents: 'Priority';    
  1831.             when: #clicked perform: #priorityPress:;
  1832.           framingRatio: ( ( ( Rectangle leftTopUnit right: inset ) down: 11/16 )
  1833.         extentFromLeftTop: 7/8  @ height )
  1834.            )).!
  1835.   
  1836. openSortWindow
  1837.  
  1838.     | mainWindow group |
  1839.     notebook addSubpane: (sortPage := GroupPane new
  1840.         owner: self).
  1841.     sortPage style: (sortPage frameStyle - FcfBorder).
  1842.  
  1843.     sortPage 
  1844.         addSubpane: 
  1845.              ( ( StaticText new )
  1846.                     contents: 'Application Sorting';
  1847.                     framingRatio: ((1/4) @ 1 
  1848.                 extentFromLeftTop: (1/2) @ (1/7))).
  1849.  
  1850.     sortPage addSubpane:
  1851.             (
  1852.             group := GroupPane new
  1853.             style: GroupPane noBorderFrameStyle ;
  1854.             framingRatio: 
  1855.                 ( ( ( Rectangle leftTopUnit right: (1/16) ) down: 1/6 )
  1856.                       extentFromLeftTop: ( 2/5 ) @ ( 3/4 ) );
  1857.             yourself
  1858.             ).
  1859.         self openSortGroup: group.
  1860.  
  1861.     sortPage addSubpane:
  1862.             (
  1863.             group := GroupPane new
  1864.             style: GroupPane noBorderFrameStyle;
  1865.             framingRatio: 
  1866.                 ( ( ( Rectangle leftTopUnit right: (1/16 + 1/2) ) down: (1/6) )
  1867.                       extentFromLeftTop: ( 2/5 ) @ ( 3/4 ) );
  1868.             yourself
  1869.             ).
  1870.         self openOrderGroup: group.!
  1871.  
  1872. priorityDefaultChange: aSpinButton
  1873.  
  1874. ctlSettings priorityDefault: aSpinButton selection.!
  1875.   
  1876. priorityPress: aButton
  1877.     
  1878. | settings |
  1879.  
  1880.     settings := ctlView settings.
  1881.     settings sortKey: 'priority'.
  1882.     ctlView settings: settings.!
  1883.  
  1884. readUserSelections
  1885.  
  1886.         "This method checks all the controls in the notebook, notes their settings
  1887.           and returns a settings object that can be used to update the ctlSettings
  1888.           object when the apply button is pushed."!
  1889.  
  1890. resetButton: aButton
  1891.  
  1892.         "When reset is pressed, this view asks the Settings model to return
  1893.           the last saved settings. It then gives thses settings to the ListView
  1894.           so that it may return to those settings."
  1895.  
  1896.         ctlView settings: (ctlSettings readSettings).
  1897.     self initialiseControls.
  1898.     ctlView refreshButton: nil.!
  1899.  
  1900. saveButton: aButton 
  1901.  
  1902.         "When save is pressed, tell the ToDoSettings object (ctlSettings) to save
  1903.           itself on disk."
  1904.  
  1905.     ctlSettings writeSettings.!
  1906.    
  1907. sized
  1908.  
  1909.     ^nil!
  1910.  
  1911. topPaneClass
  1912.  
  1913.     ^ToDoTopPane!
  1914.   
  1915. typeDefaultChange: aSpinButton
  1916.  
  1917. ctlSettings typeDefault: aSpinButton selection.!
  1918.   
  1919. typePress: aButton
  1920.     
  1921. | settings |
  1922.  
  1923.     settings := ctlView settings.
  1924.     settings sortKey: 'type'.
  1925.     ctlView settings: settings.!
  1926.  
  1927. uncompPress: aButton
  1928.     
  1929.         "User pressed the radio button that includes only uncompleted items in the
  1930.           list view. "
  1931.  
  1932.     ctlSettings includeCriterion: 'uncompleted'.! !
  1933.  
  1934.  
  1935.  
  1936. !ToDoListView methods !
  1937.   
  1938. aChoice: aLBox
  1939.  
  1940.     "A new selection has been made in the listbox.
  1941.     Check if the contents of the edit fields have been changed.
  1942.     If they have, update the todo list."
  1943.  
  1944.     self clrStatusFields.
  1945.  
  1946.     (rowDisp checkDate) 
  1947.         ifFalse: [ (statusField backColor: ClrRed;  contents: 'Error in date - change not accepted').
  1948.                          todoListBox selection: prevSelection.
  1949.                          ^self displayItem ].
  1950.     self changedItem.
  1951.     self displayItem.!
  1952.   
  1953. addButtons
  1954.  
  1955.     self addSubpane: (Button new
  1956.         owner: self;
  1957.         when: #clicked perform: #saveButton: ;
  1958.         contents: 'Save';
  1959.                  framingBlock: [:box|
  1960.                    box origin + ( 4*listLineHeight @ ( listLineHeight) )
  1961.                   corner: 7@
  1962.                     2*listLineHeight ]).
  1963.  
  1964.     self addSubpane: (Button new
  1965.         owner: self;
  1966.         when: #clicked perform: #newButton: ;
  1967.         contents: 'New item';
  1968.                  framingBlock: [:box|
  1969.               box origin + ( 9*listLineHeight @ ( listLineHeight) )
  1970.                   corner: 12@
  1971.                     2*listLineHeight ]).
  1972.     self addSubpane: (Button new
  1973.         owner: self;
  1974.         when: #clicked perform: #refreshButton: ;
  1975.         contents: 'Refresh';
  1976.                  framingBlock: [:box|
  1977.               box origin + ( 14*listLineHeight @ ( listLineHeight) )
  1978.                   corner: 17@
  1979.                     2*listLineHeight ]).!
  1980.    
  1981. addHeaders: aPane
  1982.     aPane 
  1983.         addSubpane: 
  1984.              ( ( StaticText new )
  1985.                 contents: 'Deadline';
  1986.                 owner: self;
  1987.                 framingRatio: ((4/100) @ (1/10) 
  1988.                 extent: (10/100) @ (8/10))).
  1989.     aPane 
  1990.         addSubpane: 
  1991.              ( ( StaticText new )
  1992.                 contents: 'Type';
  1993.                 owner: self;
  1994.                 framingRatio: ((15/100) @ (1/10) 
  1995.                 extent: (15/100) @ (8/10))).
  1996.     aPane 
  1997.         addSubpane: 
  1998.              ( ( StaticText new )
  1999.                 contents: 'Description';
  2000.                 owner: self;
  2001.                 framingRatio: ((35/100) @ (1/10) 
  2002.                 extent: (20/100) @ (8/10))).
  2003.  
  2004.     aPane 
  2005.         addSubpane: 
  2006.              ( ( StaticText new )
  2007.                 contents: 'Priority';
  2008.                 owner: self;
  2009.                 framingRatio: ((80/100) @ (1/10) 
  2010.                 extent: (8/100) @ (8/10))).
  2011.  
  2012.     aPane 
  2013.         addSubpane: 
  2014.              ( ( StaticText new )
  2015.                 contents: 'Done';
  2016.                 owner: self;
  2017.                 framingRatio: ((89/100) @ (1/10) 
  2018.                 extent: (11/100) @ (8/10))).!
  2019.    
  2020. addItem
  2021.  
  2022.     | tempItem |
  2023.     self changedItem.
  2024.     tempItem := ToDoItem newItem.    
  2025.     itemList add: tempItem.
  2026.  
  2027.     self addUndoItem: tempItem atValue: ''.
  2028.     self undoToRedo.
  2029.  
  2030.     todoListBox contents: itemList.
  2031.     todoListBox selection: (itemList size).
  2032.     self aChoice: nil.
  2033.  
  2034.     statusField backColor: ClrYellow;
  2035.         contents: 'New item added!! - use Defaults page in Settings to alter new item defaults'!
  2036.  
  2037. addOwnerDragListBox
  2038.  
  2039.     | dragProtocol |
  2040.  
  2041.     self addSubpane:
  2042.             ((todoListBox := ListBoxODraw ownerDraw)
  2043.                  owner: self;
  2044.                  itemHeight: listLineHeight;
  2045.                  when: #select perform: #aChoice:;
  2046.                  when: #getMenu perform: #menu:;
  2047.                   when: #drawItem perform: #drawLine: ;
  2048.                 when: #startDrag perform: #startDragLBox:;
  2049.                 when: #dragComplete perform: #dragCompleteLBox:;
  2050.  
  2051.                  framingBlock: [:box|
  2052.                 box origin + ( 0 @ (2*listLineHeight) )
  2053.                     corner: (box width ) @
  2054.                     (box height- (listLineHeight))]).
  2055.  
  2056.     dragProtocol := DragDrop for: todoListBox.
  2057.     dragProtocol 
  2058.         container: 'dummy';
  2059.         mechanisms: ( Array with: DragString new ).
  2060.  
  2061.     todoListBox dragDrop: dragProtocol.!
  2062.    
  2063. addStatus
  2064.  
  2065.  
  2066.     self addSubpane: (statusField := StaticText new
  2067.         owner: self;
  2068.         contents: 'Status messages displayed here';
  2069.                  framingBlock: [:box|
  2070.             box origin + (0 @ 0)
  2071.             corner: box width @20 ]).!
  2072.    
  2073. addUndoItem: aKey  atValue:aValue                  
  2074.                                                                   
  2075.         "store the new and original ToDoItemsfor undo"  
  2076.                                                                              
  2077.          undoItem key: aKey; value: aValue.
  2078.        ^self.                                               
  2079.                                                                   
  2080.        "The following items may be stored:                  
  2081.             if new,          save key + '' (nil)                  
  2082.             if changed,  save key + original value                
  2083.             if deleted,    save nil + original value  .           
  2084.         This allows us to test for each, and perform              
  2085.         adds, deletes and changes as required"!
  2086.   
  2087. calcRowPos2: aRow
  2088.     "Calculate the new location of the row display window.
  2089.         Created:     November 6, 1991
  2090.         Author:        Jouko Ruuskanen "
  2091.  
  2092.     |diff  rect rect2  yMax  xRight |
  2093.  
  2094.     rect := ((views at: 1) parent) rectangle.   "Frame rectangle "
  2095.     rect2 := todoListBox rectangle.                "Listbox rect"
  2096.  
  2097.     yMax := rect rightBottom y + rect2 leftTop y -  rect2 leftBottom y.
  2098.     xRight := rect rightBottom x - 24.
  2099.  
  2100.     diff := listLineHeight*(aRow -  (todoListBox getTopIndex) ).
  2101.     ^rect := (rect  leftTop x @ (yMax+ (2*listLineHeight) + 3 - diff )) 
  2102.             rightBottom: (xRight @ ((yMax - diff + listLineHeight) - 2)).!
  2103.  
  2104. calcRowPos: aRow
  2105.     "Calculate the new location of the row display window.
  2106.         Created:     October 17, 1991
  2107.         Author:        Jouko Ruuskanen "
  2108.  
  2109.     |diff  rect  |
  2110.  
  2111.     rect := todoListBox rectangle.                "Listbox rect"
  2112.  
  2113.     diff := listLineHeight*(aRow -  (todoListBox getTopIndex) ).
  2114.     ^rect := (rect leftTop x @ (rect leftTop y   - diff + 2)) 
  2115.             rightBottom: ((rect rightBottom x - listLineHeight + 7) @ ((rect leftTop y) - diff - listLineHeight - 3)).!
  2116.  
  2117. changedItem
  2118.     (((itemList at: prevSelection) asString) = ((rowDisp currentItem) asString))
  2119.     ifFalse: [
  2120.         itemList at: prevSelection put: rowDisp currentItem.
  2121.      ].!
  2122.   
  2123. close: aWin 
  2124.  
  2125. "    itemList writeList."
  2126. "      rowDisp close."
  2127.     ^super close!
  2128.  
  2129. clrStatusFields
  2130.  
  2131.     statusField backColor: ClrWhite;
  2132.         contents: ''.!
  2133.   
  2134. copyItem
  2135.         
  2136.     "This method eliminates the problem caused by the pop-up context menu
  2137.         which gets called from ToDoListView, and the menu structure, which
  2138.         comes from ToDoTopPane."
  2139.  
  2140. self copyItem: (views at: 1) handle.!
  2141.  
  2142. copyItem: aHandle
  2143.  
  2144.     "Copy an Item to the Clipboard"
  2145.  
  2146.     (itemList at: (todoListBox selection)) copyYourself: aHandle.
  2147.  
  2148.     statusField backColor: ClrYellow;
  2149.         contents: 'Item copied to Clipboard'!
  2150.   
  2151. cutItem
  2152.  
  2153. (views at: 1) cutItem.!
  2154.   
  2155. displayItem
  2156.     rowDisp hide.
  2157.     rowDisp moveAbsolute: (self calcRowPos: todoListBox selection).
  2158.     rowDisp newItem: (itemList at: (todoListBox selection)).
  2159.     prevSelection := todoListBox selection.
  2160.     rowDisp show.!
  2161.  
  2162. dragCompleteLBox: aPane
  2163.  
  2164. "    inform todoListBox of the end of drag/drop operation 
  2165. "!
  2166.    
  2167. drawLine: aListBoxODraw    
  2168.     (( todoListBox selection ) isNil ) ifFalse: [
  2169.     aListBoxODraw drawLine: itemList ]!
  2170.   
  2171. dropCompletePrt: aPane
  2172.  
  2173.     self printItem.
  2174. " if you want to print the item (a more sophisticated way) , do this: 
  2175.  
  2176.     aPane dragDrop items do: [ :item | (item userInfo) printYourself ].
  2177.  
  2178. "!
  2179.  
  2180. dropCompleteTrash: aPane
  2181.  
  2182.     self removeItem.
  2183. " if you want to print the item , do this: 
  2184.  
  2185.     aPane dragDrop items do: [ :item | item printYourself ].
  2186.  
  2187. "!
  2188.  
  2189. dummy
  2190.  
  2191.     ^nil!
  2192.  
  2193. initWindowSize
  2194.         "Private - Answer the initial size of the receiver."
  2195.     (Display extent = (640@480)) ifTrue: [
  2196.     ^(Display width * 19 //20) @ (Display height * 4 // 7)]
  2197.     ifFalse: [
  2198.         ^(Display width * 15 //20) @ (Display height * 4 // 7)]!
  2199.  
  2200. menu: aPane
  2201.  
  2202.     "Private - Set the To Do pane menu. Sets the option menu
  2203.      up.  Notice this method gets called whenever there is a 
  2204.     getMenu event and that this menu pops up when mouse 
  2205.     button 2 is pressed in the listPane."
  2206.  
  2207.     todoListBox  setMenu: (( self menuWindow menuTitled: '~Edit' ))!
  2208.    
  2209. menuSetup
  2210.  
  2211.     (self menuTitled:'ThingsToDo') disableItem:'~Open as ToDo List'. 
  2212.     (self menuTitled:'Edit') disableItem:'~Undo'. 
  2213.     (self menuTitled:'Edit') disableItem:'~Redo'. 
  2214.     (self menuTitled:'View') disableItem:'~List'.
  2215.     (self menuTitled:'Edit') changeItem:'~Undo' selector:#undo.
  2216.     (self menuTitled:'Edit') changeItem:'~Redo' selector:#redo.!
  2217.   
  2218. newButton: aButton
  2219.  
  2220.     self addItem.!
  2221.    
  2222. open
  2223.     "Open a ToDoListView which contains a list of the items."
  2224.  
  2225. | hPane tempToDoTopPane |
  2226.  
  2227.     self setItemHeight.
  2228.  
  2229.     self
  2230.         owner: self;
  2231.         labelWithoutPrefix: 'Things To-Do List View'.
  2232.  
  2233.     self when: #close perform: #close: .
  2234.  
  2235.     self 
  2236.         addSubpane: 
  2237.              ( ( hPane := GroupPane new )
  2238.                 owner: self;
  2239.                 style: GroupPane noBorderFrameStyle;
  2240.                 framingBlock: [:box|
  2241.                     box origin x @ (
  2242.                     box height - listLineHeight) corner:
  2243.                        box width  @  box height]).
  2244.  
  2245.     self addHeaders: hPane.
  2246.  
  2247.     self addOwnerDragListBox.
  2248.  
  2249.     "Open up the ToDoSettings object and retrieve the default settings."
  2250.         settings := ToDoSettings new.
  2251.     settings settings.
  2252.  
  2253.     self addStatus.
  2254.     self addButtons.
  2255.  
  2256.     "Open a ToDoList and read contents into it."
  2257.     self openList.
  2258.  
  2259.     "Set up the undoItem"
  2260.     undoItem := Association new.
  2261.  
  2262.     HelpManager for: (self mainView) title: 'Help' file: 'todo\todo.hlp'.
  2263.     self openWindow.
  2264.  
  2265.     "Since we opened as a ToDoList (rather than settings) grey out the
  2266.       inappropriate menu options."
  2267.     self menuSetup.
  2268.  
  2269.     "Open up the secondary window that sits on top of the list box and
  2270.       allows direct changes to be made to the list."
  2271.     ((itemList size) = 0)
  2272.         ifFalse:[    self openRow: (itemList at: 1)].!
  2273.    
  2274. openAsSettings
  2275.  
  2276.     | aView |
  2277.     
  2278.     aView := ToDoSettingsView new.
  2279.     aView parent: ((views at: 1) parent).
  2280.     aView open.    
  2281.     aView ctlView: self andSettings: settings.
  2282.     rowDisp hide.!
  2283.    
  2284. openList
  2285.  
  2286.     itemList := ToDoList new readList.
  2287.     (itemList size = 0)
  2288.         ifTrue:[ itemList add: (ToDoItem newItem).
  2289.                       statusField backColor: ClrRed;
  2290.                       contents: 'Could not find a ToDoList - default list created'.
  2291.                     ].!
  2292.   
  2293. openRow: aToDoItem
  2294.  
  2295.     rowDisp := ToDoRowDisplay new
  2296.         parent: (views at: 1).
  2297.     rowDisp initWindow.
  2298.     rowDisp openWindow: ((1000@1000) rightBottom: ( 1001@999)).
  2299.     rowDisp ctlWindow: self.    
  2300.     prevSelection := 1.
  2301.  
  2302.     rowDisp newItem: aToDoItem.
  2303.  
  2304.     self refreshButton: nil.!
  2305.   
  2306. pasteItem
  2307.         
  2308.     "This method eliminates the problem caused by the pop-up context menu
  2309.         which gets called from ToDoListView, and the menu structure, which
  2310.         comes from ToDoTopPane."
  2311.  
  2312. self pasteItem: (views at: 1) handle.!
  2313.    
  2314. pasteItem: aHandle
  2315.  
  2316.         "Paste the item from the clipboard"
  2317.         | clipMgr newItem itemString errMsg|
  2318.  
  2319.     self changedItem.
  2320.     CursorManager execute change.
  2321.     clipMgr := ClipboardManager new.
  2322.     itemString := clipMgr getString.
  2323.     clipMgr close.
  2324.  
  2325.     newItem := ToDoItem new.
  2326.     errMsg := newItem pdsAsItem: itemString.
  2327.     (errMsg isNil)
  2328.         ifFalse:[ statusField backColor: ClrRed;
  2329.                         contents: errMsg.
  2330.                         CursorManager normal change.
  2331.                         ^nil]
  2332.         
  2333.         "Call verifyItem. If an error is returned, print error."
  2334.         ifTrue:[errMsg := newItem verifyItem.
  2335.                         (errMsg isNil)
  2336.                             ifTrue:[self addUndoItem: newItem atValue: ''.
  2337.                                           self undoToRedo. 
  2338.                                           itemList add: newItem.
  2339.                                           self refresh.                                        
  2340.                                           statusField backColor: ClrYellow;
  2341.                                             contents: 'Item pasted from Clipboard'.
  2342.                                         ]
  2343.                             ifFalse:[statusField backColor: ClrRed;
  2344.                                             contents: errMsg.
  2345.                                         ]
  2346.                     ].
  2347.  
  2348.     CursorManager normal change.!
  2349.   
  2350. printAllItems
  2351.         "Prints every item in the list."
  2352.  
  2353.         itemList do: [ :item | item printYourself].!
  2354.  
  2355. printItem
  2356.  
  2357.     (itemList at: (todoListBox selection)) printYourself.
  2358.  
  2359.     statusField backColor: ClrRed;
  2360.         contents: 'Item printed'!
  2361.  
  2362. printLines: lines
  2363.         "Private - Print the text lines."
  2364.     | aHandle |
  2365.     CursorManager execute change.
  2366.     aHandle := FileHandle openDevice: 'LPT1'.
  2367.     lines do: [ :line |
  2368.         aHandle deviceWrite: line.
  2369.         aHandle deviceWrite: (String with: Lf with: Cr)].
  2370.     aHandle close.
  2371.     CursorManager normal change!
  2372.    
  2373. redo
  2374.         "redo last change."
  2375.     |oldItem newItem |
  2376.  
  2377.     oldItem := undoItem key.
  2378.     newItem := undoItem value.
  2379.     oldItem = '' ifTrue: [ itemList addItem: newItem. ]
  2380.                         ifFalse: [ (newItem = '') 
  2381.                                             ifTrue: [ itemList removeItem: (itemList indexOf: oldItem).
  2382.                                                             prevSelection := 1.
  2383.                                                             ]
  2384.                                             ifFalse: [ itemList updateItem: oldItem 
  2385.                                                                             at: (itemList indexOf: newItem)
  2386.                                                             ]
  2387.                                         ].
  2388.     self refresh.
  2389.     self addUndoItem: newItem atValue: oldItem.
  2390.     self undoToRedo.
  2391.     ^self.!
  2392.  
  2393. refresh
  2394.  
  2395. "1. check if current item has changed; if so write it out to itemList
  2396.   2. sort itemList
  2397.   3. check if itemList has finished its sort
  2398.   4. when finished, get itemList into todoListBox,
  2399.   5. that forces a refresh
  2400.   6. select an item (here we always select the first item after a sort)
  2401.   7. display the secondary window (rowDisp) over the selected item."
  2402.  
  2403.     self changedItem.
  2404.     itemList sortList: (settings sortKey) order: (settings sortOrder).
  2405.  
  2406.     todoListBox contents: itemList.
  2407.     todoListBox selection: 1.
  2408.     self displayItem.
  2409.  
  2410.     statusField backColor: ClrYellow;
  2411.         contents: 'List refreshed, sortkey: ' , settings sortKey,' sortOrder: ',settings sortOrder.
  2412.  
  2413.     "and then use country, codePage, includeCriterion etc"!
  2414.    
  2415. refreshButton: aButton
  2416.  
  2417. ^self refresh.!
  2418.    
  2419. removeItem
  2420.     ((itemList size) = 1)
  2421.         ifTrue:[ statusField backColor: ClrRed;
  2422.                         contents: 'Cannot delete last Item in list'
  2423.                         ]
  2424.         ifFalse:[    self addUndoItem: '' atValue: (itemList at: (todoListBox selection)).
  2425.                         self undoToRedo. 
  2426.                         itemList remove: (itemList at: (todoListBox selection)).
  2427.         
  2428.                         rowDisp newItem: (itemList at: 1).
  2429.                         todoListBox contents: itemList.
  2430.                         prevSelection := 1.
  2431.                         todoListBox selection: 1.
  2432.                         self aChoice: nil.
  2433.  
  2434.                         statusField backColor: ClrYellow;
  2435.                                                 contents: 'Item deleted'.
  2436.                         ].
  2437.     ^self.!
  2438.   
  2439. removeItem: anItem
  2440. self halt.
  2441. itemList remove: anItem.
  2442.  
  2443.             undoItem itemCopy: (itemList at: (todoListBox selection)) action: 'remove'.
  2444.             self undoToRedo. 
  2445.         
  2446.             rowDisp newItem: (itemList at: 1).
  2447.             todoListBox contents: itemList.
  2448.             prevSelection := 1.
  2449.             todoListBox selection: 1.
  2450.             self aChoice: nil.
  2451.  
  2452.             statusField backColor: ClrYellow;
  2453.                 contents: 'Item deleted'.!
  2454.  
  2455. rowDown
  2456.  
  2457.     ((todoListBox selection) = (itemList size)) ifTrue: [ ^nil ].
  2458.     todoListBox selection: (todoListBox selection + 1).
  2459.     self aChoice: nil.!
  2460.    
  2461. rowUp
  2462.  
  2463.     ((todoListBox selection) = 1) ifTrue: [ ^nil ].
  2464.     todoListBox selection: (todoListBox selection - 1).
  2465.     self aChoice: nil.!
  2466.    
  2467. saveButton: aButton
  2468.  
  2469.     | saveFileName |
  2470.  
  2471.     saveFileName := itemList writeList.
  2472.  
  2473.     statusField backColor: ClrYellow;
  2474.         contents: 'List saved!! - in file ', saveFileName!
  2475.  
  2476. setItemHeight
  2477.     "Set the proper height of the Ownerdraw listbox line"
  2478.  
  2479.     | vga bga|
  2480.     vga := 640 @ 480.
  2481.     bga := 1024 @ 768.
  2482.  
  2483.     "Check the size of the display. If it is an 8514 with adaptor,
  2484.       or an XGA display,
  2485.      use a higher height. (Display is a special class pertinent to the
  2486.      monitor in use)."
  2487.  
  2488.     (Display extent = bga)
  2489.       ifTrue: [
  2490.              listLineHeight := 30 ]
  2491.       ifFalse: [ listLineHeight := 25   ] .!
  2492.  
  2493. settings
  2494.  
  2495.     ^settings!
  2496.  
  2497. settings: aSetting
  2498.  
  2499.     settings := aSetting!
  2500.  
  2501. showRow
  2502.  
  2503.     rowDisp show!
  2504.    
  2505. sized
  2506.     "Our window is sized, so redisplay the child"
  2507.     | savedSel |
  2508.  
  2509.     (todoListBox selection notNil) ifTrue: [
  2510.         rowDisp hide.
  2511.         rowDisp show.
  2512. "
  2513.         savedSel := todoListBox selection.
  2514.         todoListBox selection: nil.
  2515.         todoListBox selection: savedSel.
  2516.         self aChoice: nil.    
  2517. "    ]
  2518.  
  2519.  
  2520.  
  2521. "
  2522.     ((todoListBox contents) notNil) ifTrue: [
  2523.         self calcRowPos: (todoListBox selection)].
  2524. "!
  2525.   
  2526. sortBy: aSortKey
  2527.  
  2528.     self changedItem.
  2529.     itemList sortList: (aSortKey) order: (settings sortOrder).
  2530.    
  2531.     rowDisp newItem: (itemList at: 1).
  2532.     prevSelection := 1.
  2533.     todoListBox contents: itemList.
  2534.     todoListBox selection: 1.
  2535.  
  2536.     statusField backColor: ClrYellow;
  2537.         contents: 'List updated, sortkey: ' , settings sortKey.
  2538.  
  2539.     ^self displayItem.!
  2540.   
  2541. startDragLBox: aPane
  2542.         "Initiate a drag drop session."
  2543.  
  2544.     | dragList dragItems listName dragObject|
  2545.  
  2546.  
  2547.     "Build a list of items to export to the desktop."
  2548.     dragItems := OrderedCollection new.
  2549.     dragItems add: (itemList at: aPane selection). 
  2550.     dragList := dragItems
  2551.         collect: [ :item | 
  2552.             ( DragItem new ) 
  2553.                 name: item description; 
  2554.                 type: #( 'Unknown' ); 
  2555.                 format: #( 'DRF_UNKNOWN' );
  2556.                 userInfo: item;     "Store every item in userInfo"
  2557.                 container: 'dummy'
  2558.         ].
  2559.  
  2560.     "Initiate a drag operation with the system."
  2561.     aPane dragDrop drag: dragList.!
  2562.  
  2563. tabToNextField
  2564.     "This method can be called if focus is on list window.
  2565.     We are not doing anything here at the moment."
  2566.  
  2567.     ^nil!
  2568.   
  2569. topPaneClass
  2570.  
  2571.     "Private - set the default toppane class "
  2572.  
  2573.     ^ToDoTopPane!
  2574.  
  2575. undo
  2576.         "undo last change."
  2577.     |oldItem newItem |
  2578.  
  2579.     oldItem := undoItem key.
  2580.     newItem := undoItem value.
  2581.     oldItem = '' ifTrue: [ itemList addItem: newItem. ]
  2582.                         ifFalse: [ (newItem = '') 
  2583.                                             ifTrue: [ itemList removeItem: (itemList indexOf: oldItem).
  2584.                                                             prevSelection := 1.
  2585.                                                             ]
  2586.                                             ifFalse: [ itemList updateItem: oldItem 
  2587.                                                                             at: (itemList indexOf: newItem)
  2588.                                                             ]
  2589.                                         ].
  2590.     self refresh.
  2591.     self addUndoItem: newItem atValue: oldItem.
  2592.     (self menuTitled:'Edit') disableItem:'~Undo'. 
  2593.     (self menuTitled:'Edit') enableItem:'~Redo'.
  2594.     ^self.!
  2595.    
  2596. undoToRedo
  2597.  
  2598.     (self menuTitled:'Edit') enableItem:'~Undo'. 
  2599.     (self menuTitled:'Edit') disableItem:'~Redo'.! !
  2600.  
  2601.  
  2602.  
  2603. !DragString methods !
  2604.  
  2605. renderingMechanism
  2606.         "Answer a string which describes the rendering
  2607.         mechanism implemented."
  2608.     ^'DRM_OS2FILE'!
  2609.  
  2610. sourceTransfer: item
  2611.         "Private - The source will render the item."
  2612.     | dragTransfer |
  2613.     dragTransfer := PMDragTransfer size: 1.
  2614.     dragTransfer
  2615.         cb: PMDragTransfer sizeInBytes;
  2616.         hwndClient: owner owner handle;
  2617.         pditem: item pmItem contents contents;
  2618.         selectedRMF: ( '<', self renderingMechanism, ',', item format first, '>' );
  2619.         renderToName: ( owner target, item pmItem targetName );
  2620.         ulTargetInfo: 0;
  2621.         usOperation: owner operation;
  2622.         fsReply: 0.
  2623.  
  2624.     ( dragTransfer sendMsg: DmRender to: item pmItem hwndItem with: 0 )
  2625.         ifTrue: [ ^nil ]
  2626.         ifFalse: [
  2627.             item pmItem 
  2628.                 sendTransferMsg: DmEndconversation
  2629.                 response: DmflTargetfail.
  2630.             owner freeTransferItem: item
  2631.         ]!
  2632.    
  2633. targetTransfer: item
  2634.         "Private - The target will perform the rendering
  2635.         operation without the direct involvement of the source."
  2636.     ( self transfer: item to: ( owner target, item name ) )
  2637.         ifTrue: [
  2638.             item pmItem
  2639.                 sendTransferMsg: DmEndconversation
  2640.                 response:  DmflTargetsuccessful.
  2641.         ]
  2642.         ifFalse: [
  2643.             item pmItem
  2644.                 sendTransferMsg: DmEndconversation
  2645.                 response:  DmflTargetfail.
  2646.         ].
  2647.     owner freeTransferItem: item!
  2648.   
  2649. transfer: item
  2650.         "Private - Begin the direct manipulation operation."
  2651.     | hstrSrc |
  2652.     hstrSrc := PMHandle fromBytes: item pmItem hstrSourceName.
  2653.     ( hstrSrc = NullHandle or: [ ( owner isNativeFormat: item ) not ] )
  2654.         ifTrue: [ self sourceTransfer: item ]
  2655.         ifFalse: [ self targetTransfer: item ]!
  2656.   
  2657. transfer: item to: dest
  2658.         "Private - Perform the actual operation and return true if successful."
  2659.     | src operation transItem |
  2660.     operation := owner operation.
  2661.     src := item pmItem containerName, item pmItem sourceName.
  2662.     ( src  = dest  )
  2663.         ifTrue: [ ^true ].
  2664.     ( ( operation = DoDefault ) or: [ operation = DoMove ] )
  2665.         ifTrue: [            
  2666. "            File copy: src to: dest.
  2667.             File remove: src
  2668. "        ].
  2669.     operation = DoCopy
  2670.         ifTrue: [
  2671. "            File copy: src to: dest.
  2672. "        ].
  2673.     ^true! !
  2674.