home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 (1993) / nebula.bin / SourceCode / MiniExamples / FindIt / Controller.m < prev    next >
Encoding:
Text File  |  1991-10-09  |  1.7 KB  |  88 lines

  1. /* 
  2.  * Controller.m
  3.  *
  4.  * Purpose:
  5.  *        Manages the windows in this example and passes menu messages
  6.  *        to the other objects.
  7.  *
  8.  * You may freely copy, distribute, and reuse the code in this example.
  9.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  10.  * fitness for any particular use.
  11.  *
  12.  * Written by: Mary McNabb
  13.  * Created: Apr 91
  14.  *
  15.  */
  16.  
  17. #import "Controller.h"
  18. #import "FindObject.h"
  19. #import "InfoPanel.h"
  20. #import <appkit/ScrollView.h>
  21. #import <appkit/Text.h>
  22. #import <appkit/Application.h>
  23.  
  24. @implementation Controller
  25.  
  26. /*
  27.  * We need the handle for the text object in the scrollview.
  28.  */
  29. - appDidInit:sender
  30. {
  31.     fileDocView = [fileScrollView docView];
  32.     [[fileScrollView window] makeKeyAndOrderFront:self];
  33.     return self;
  34. }
  35.  
  36. /*
  37.  * User wants a find panel. Create it. Also, set the text to be searched to the
  38.  * firstResponder object.
  39.  */
  40. - findPanel:sender
  41. {
  42.     id myObject;
  43.     if (!findObject)
  44.         findObject = [[FindObject alloc] init];
  45.     myObject = [[NXApp keyWindow] firstResponder];
  46.     if (myObject == fileDocView)
  47.         [findObject setSearchMe:fileDocView];
  48.     else
  49.         [findObject setSearchMe:theMatrix];
  50.     [findObject findPanel:self];
  51.     return self;
  52. }
  53.  
  54. /*
  55.  * Find the Next instance of the string we are looking for.  Called when the user
  56.  * uses the menu.
  57.  */
  58. - findNext:sender
  59. {
  60.     if (findObject)
  61.         [findObject findNext:sender];
  62.     return self;
  63. }
  64.  
  65. /*
  66.  * Find the Previous instance of the string we are looking for.  Called when the user
  67.  * uses the menu.
  68.  */
  69. - findPrevious:sender
  70. {
  71.     if (findObject)
  72.         [findObject findPrevious:sender];
  73.     return self;
  74. }
  75.  
  76. /*
  77.  * User wants the Info panel...show it.
  78.  */
  79. - infoPanel:sender
  80. {
  81.     if (!infoPanel)
  82.         infoPanel = [[InfoPanel alloc] init];
  83.     [infoPanel orderInfoPanelFront:sender];
  84.     return self;
  85. }
  86.  
  87. @end
  88.