next up previous
Next: View methods Up: RECView.m Program Listing Previous: Copying and printing Views

Browser delegate methods

The program for the NeXTSTEP browser goes to considerable effort to create sliding panels, embody them in an attractive framework, fill them with information, and respond to the activities of the mouse. It still needs to be provided with information to display, and to be told how to respond. The program using the browser has to take charge, which it does by having been designated as a delegate. There are some methods which the browser supervisor expects to find, such as fillMatrix::: described below.

/*---------------- B R O W S E R  D E L E G A T E -------------------*/

- (int)browser:sender fillMatrix: matrix inColumn: (int)col {int  i, n;
    n=0;
    printf("browser\n");
    switch(col) {
      case 0: 
        for(i=0; i<NMU; i++) {
          [matrix addRow];
          [[matrix cellAt: i: 0]  setLeaf : NO ];     
          [[matrix cellAt: i: 0]  setLoaded : YES ];   
          [[matrix cellAt: i: 0]  setEnabled : YES ];
          [[matrix cellAt: i: 0]  setEnabled : YES ];
          }
        [[matrix cellAt: 0: 0]  setStringValue: "operators"];     
        [[matrix cellAt: 1: 0]  setStringValue: "predefined"];     
        [[matrix cellAt: 2: 0]  setStringValue: "skeletons"];
        [[matrix cellAt: 3: 0]  setStringValue: "initial polygons"];
        [[matrix cellAt: 4: 0]  setStringValue: "demonstrations"];
        n=NMU;
        break;
      case 1:
        if(strcmp([[sender selectedCell] stringValue],"demonstrations") == 0){
          for(i=0; i<NY; i++) {
            [matrix addRow];
            [[matrix cellAt: i: 0]  setStringValue: recrule[i]];
            [[matrix cellAt: i: 0]  setLeaf : YES ];     
            [[matrix cellAt: i: 0]  setLoaded : YES ];   
            [[matrix cellAt: i: 0]  setEnabled : YES ];
            }
          n=NY;}

        if(strcmp([[sender selectedCell] stringValue],"predefined") == 0){
          for(i=0; i<1; i++) {
            [matrix addRow];
            [[matrix cellAt: i: 0]  setStringValue: idef[i]];
            [[matrix cellAt: i: 0]  setLeaf : YES ];     
            [[matrix cellAt: i: 0]  setLoaded : YES ];   
            [[matrix cellAt: i: 0]  setEnabled : YES ];
            }
          n=1;}

        if(strcmp([[sender selectedCell] stringValue],"operators") == 0){
          for(i=0; i<95; i++) {
            [matrix addRow];
            [[matrix cellAt: i: 0]  setStringValue: dtbl[i].r_cmnt];
            [[matrix cellAt: i: 0]  setLeaf : YES ];     
            [[matrix cellAt: i: 0]  setLoaded : YES ];   
            [[matrix cellAt: i: 0]  setEnabled : YES ];
            }
          n=95;}
        if(strcmp([[sender selectedCell] stringValue],"initial polygons") == 0){
           for(i=0; i<NIP; i++) {
            [matrix addRow];
            [[matrix cellAt: i: 0]  setStringValue: inpollies[i].title];
            [[matrix cellAt: i: 0]  setLeaf : YES ];     
            [[matrix cellAt: i: 0]  setLoaded : YES ];   
            [[matrix cellAt: i: 0]  setEnabled : YES ];
           }
          n=NIP;}
        if(strcmp([[sender selectedCell] stringValue],"skeletons") == 0){
           for(i=0; i<NIP; i++) {
            [matrix addRow];
            [[matrix cellAt: i: 0]  setStringValue: skeletons[i]];
            [[matrix cellAt: i: 0]  setLeaf : YES ];     
            [[matrix cellAt: i: 0]  setLoaded : YES ];   
            [[matrix cellAt: i: 0]  setEnabled : YES ];
           }
          n=NSK;}

            break;
        default: n=0; break; }
      return n;
    }

/* to distract the single click in a browser double click */
- nhul: sender {return self;}

- browserDoubleClick:sender {int i, j, k; 
   if (strcmp([browser titleOfColumn: [browser selectedColumn]],
        "initial polygons") == 0) {
        k=[[sender matrixInColumn: [sender selectedColumn]] selectedRow];
        pgon=inpollies[k].order;
        edge = 0;
        for (i=0; i<pgon; i++) for (j=0; j<3; j++) 
                pointbase[i][j] = inpollies[k].points[i][j];
           [execLine setStringValue: "(CP;)"];
          strcpy(cstr,"(CP;)");}
   else if (strcmp([browser titleOfColumn: [browser selectedColumn]],
        "demonstrations") == 0) {
           [value setStringValue: " "];
           [execLine setStringValue: [sender stringValue]];
          strcpy(cstr,[sender stringValue]);
        }
   else if (strcmp([browser titleOfColumn: [browser selectedColumn]],
        "skeletons") == 0) {
           [value setStringValue: " "];
           [execLine setStringValue: [sender stringValue]];
        }
   [lilView display];
return self;
  }



Microcomputadoras
2000-09-28