home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / timeline / region.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  18.8 KB  |  541 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/TimeLine/RCS/region.c,v 1.0 91/09/30 17:02:37 chua Exp Locker: drapeau $ */
  25. /* $Log:    region.c,v $
  26.  * Revision 1.0  91/09/30  17:02:37  chua
  27.  * Update to version 1.0
  28.  * 
  29.  * Revision 0.49  91/09/23  17:19:37  chua
  30.  * The Show Region Info item is now in the Options menu button.
  31.  * 
  32.  * Revision 0.48  91/09/19  17:29:05  chua
  33.  * Make sure that variables are initialized properly.  Change formatting slightly,
  34.  * so that (if, for, while) statements with only one statement in them will not have
  35.  * braces.
  36.  * 
  37.  * Revision 0.47  91/09/17  17:18:40  chua
  38.  * Renamed Region to tlRegion.
  39.  * 
  40.  * Revision 0.46  91/09/04  15:13:32  chua
  41.  * Use AlertMessage whenever a notice_prompt is to be displayed.
  42.  * 
  43.  * Revision 0.45  91/08/16  17:06:45  chua
  44.  * Removed some variables which are not used.
  45.  * 
  46.  * Revision 0.44  91/08/05  16:53:32  chua
  47.  * Deleted the RepaintCanvas routine, as it is no longer necessary.  In places where it
  48.  * is called, just call the ScrollToFirstQuarter routine, which will do the necessary
  49.  * repaint as well.
  50.  * 
  51.  * Revision 0.43  91/08/05  13:06:21  chua
  52.  * In the InsertRegion routine, check first that a region has been selected, before attempting to
  53.  * insert a new entry in the region list.  
  54.  * 
  55.  * Revision 0.42  91/07/30  17:33:13  chua
  56.  * When a region is added or deleted, set the change flag to 1.
  57.  * 
  58.  * Revision 0.41  91/07/26  17:30:11  chua
  59.  * 
  60.  * 
  61.  * Revision 0.40  91/07/26  17:14:26  chua
  62.  * This file contains the routines that deals with inserting and deleting annotated
  63.  * regions from the TimeLine document.
  64.  *  */
  65.  
  66. static char regionrcsid[] = "$Header: /Source/Media/collab/TimeLine/RCS/region.c,v 1.0 91/09/30 17:02:37 chua Exp Locker: drapeau $";
  67.  
  68. #include "main.h"
  69.  
  70. /*
  71.  * Menu handler for `OptionsMenu (Show Region Info ...)'.
  72.  * Opens the region info popup window.
  73.  */
  74. Menu_item ShowRegionInfoHandler(item, op)
  75.      Menu_item    item;
  76.      Menu_generate    op;
  77. {
  78.   TimeLineFramePtr tlFrame;
  79.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  80.  
  81.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  82.   switch (op) 
  83.   {
  84.    case MENU_DISPLAY:
  85.     break;
  86.    case MENU_DISPLAY_DONE:
  87.     break;
  88.    case MENU_NOTIFY:
  89.     xv_set(tlFrame->RegionPopup->RegionPopup,
  90.        FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  91.     xv_set(tlFrame->RegionPopup->RegionPopup,
  92.        XV_SHOW, TRUE, NULL);
  93.     break;
  94.    case MENU_NOTIFY_DONE:
  95.     break;
  96.   }
  97.   return item;
  98. }
  99.  
  100. /*
  101.  * Function that will return a pointer to the appropriate region node given its relative position in the region list.
  102.  */
  103. tlRegion *FindRegion(tlFrame)
  104.      TimeLineFramePtr tlFrame;
  105. {
  106.   int         i;
  107.   tlRegion *currentRegion;
  108.   
  109.   currentRegion = tlFrame->regionHead;                       
  110.   for (i=0; i < tlFrame->regionEdit && currentRegion != NULL; i++)
  111.     currentRegion = currentRegion->next;
  112.   return currentRegion;
  113. }
  114.  
  115. /*
  116.  * Notify callback function for `RegionList'.
  117.  * On a PANEL_LIST_OP_DESELECT operation, this function will reset the selected region message to zero, and also the regionEdit and selectedRegion
  118.  * variables to indicate that no edit has been selected.
  119.  * On a PANEL_LIST_OP_SELECT operation, this function will set the regionEdit and selectedRegion variables to point to the selected node and scroll
  120.  * the canvas so that the selected region will be visible.
  121.  */
  122. int RegionListNotify(item, string, client_data, op, event)
  123.      Panel_item    item;
  124.      char        *string;
  125.      Xv_opaque    client_data;
  126.      Panel_list_op    op;
  127.      Event        *event;
  128. {
  129.   int selection;
  130.   char selected[4];
  131.   TimeLineFramePtr tlFrame;
  132.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  133.   Window    owner = xv_get(ip->RegionPopup, XV_OWNER);
  134.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  135.   
  136.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  137.   switch(op) 
  138.   {
  139.    case PANEL_LIST_OP_DESELECT:
  140.     tlFrame->regionEdit = -1;
  141.     tlFrame->selectedRegion = NULL;
  142.     sprintf(selected, "%d", tlFrame->regionEdit + 1);
  143.     xv_set(tlFrame->RegionPopup->RegionSelectValueMsg, PANEL_LABEL_STRING, selected, NULL);
  144.     break;
  145.    case PANEL_LIST_OP_SELECT:
  146.     sscanf(string, "%d", &selection);                    /* Get the number of the edit which has been selected */
  147.     tlFrame->regionEdit = selection - 1;
  148.     tlFrame->selectedRegion = (tlRegion *) FindRegion(tlFrame);
  149.     ScrollToFirstQuarter(tlFrame, tlFrame->selectedRegion->startX, 0);
  150.     sprintf(selected, "%d", tlFrame->regionEdit + 1);
  151.     xv_set(tlFrame->RegionPopup->RegionSelectValueMsg, PANEL_LABEL_STRING, selected, NULL);
  152.     if (tlFrame->areaSelected)                        /* Clear the previously selected area */
  153.       XFillRectangle(tlFrame->dpyDraw, tlFrame->xidDraw, tlFrame->gcLine, (tlFrame->startX  / tlFrame->zoomLevel) - tlFrame->canvasStart, 
  154.              tlFrame->startY, (tlFrame->endX - tlFrame->startX) / tlFrame->zoomLevel,
  155.              tlFrame->endY - tlFrame->startY);
  156.     DrawPlaybackHead(-1, tlFrame);                    /* Remove the playback head from the canvas */
  157.     tlFrame->startX = tlFrame->selectedRegion->startX;
  158.     tlFrame->endX = tlFrame->selectedRegion->endX;
  159.     tlFrame->startY = 0;
  160.     tlFrame->endY = tlFrame->numberOfApps * (IconHeight + IconGap);
  161.     DeselectNote(tlFrame);                        /* Deselect any currently selected note first */
  162.     DrawSelectArea(tlFrame);
  163.     xv_set(tlFrame->RegionPopup->RegionLabelText, PANEL_VALUE, 
  164.        tlFrame->selectedRegion->label, NULL);
  165.     break;
  166.    case PANEL_LIST_OP_VALIDATE:
  167.     break;
  168.    case PANEL_LIST_OP_DELETE:
  169.     break;
  170.   }
  171.   return XV_OK;
  172. }
  173.  
  174. /*
  175.  * This function will update the region panel list which indicates where all the annotated regions are.
  176.  * It goes through the Region list for the frame and updates the panel list accordingly.
  177.  */
  178. void UpdateRegionList(tlFrame)
  179.      TimeLineFramePtr tlFrame;
  180. {
  181.   tlRegion *currentRegion;
  182.   char     buf[100], numRegions[5], selected[4];
  183.   int     count = 0, i;
  184.   int     oldlines, replace;
  185.   
  186.   sprintf(numRegions, "%d", tlFrame->numRegion);            /* Update the display for the number of regions */
  187.   xv_set(tlFrame->RegionPopup->RegionCountMsg,
  188.      PANEL_LABEL_STRING, numRegions, NULL);
  189.   oldlines = xv_get(tlFrame->RegionPopup->RegionList,            /* Get the number of rows currently in the panel list */
  190.             PANEL_LIST_NROWS);
  191.   replace = oldlines;
  192.   if (tlFrame->numRegion <= oldlines) 
  193.     replace = tlFrame->numRegion;
  194.   currentRegion = tlFrame->regionHead;
  195.   xv_set(tlFrame->RegionPopup->RegionList,                /* Hide the panel list while updating is done */
  196.      XV_SHOW, FALSE, NULL);
  197.   for (i=0; i < replace; i++)                        /* Replace the old strings by the new ones. */
  198.   {
  199.     sprintf(buf, "   %4d.    %-25.22s%4d:%02d  %4d:%02d",
  200.         count+1, currentRegion->label,
  201.         currentRegion->startMin, currentRegion->startSec,
  202.         currentRegion->endMin, currentRegion->endSec); 
  203.     xv_set (tlFrame->RegionPopup->RegionList,
  204.         PANEL_LIST_STRING, i, buf,
  205.         PANEL_LIST_FONT, i, font,
  206.         NULL);
  207.     count++;
  208.     currentRegion = currentRegion->next;
  209.   }
  210.   if (tlFrame->numRegion > oldlines) 
  211.   {
  212.     for (i=oldlines; i < tlFrame->numRegion; i++)            /* Insert the additional new strings */
  213.     {
  214.       sprintf(buf, "   %4d.    %-25.22s%4d:%02d  %4d:%02d",
  215.                 count+1, currentRegion->label,
  216.           currentRegion->startMin, currentRegion->startSec,
  217.           currentRegion->endMin, currentRegion->endSec); 
  218.       xv_set (tlFrame->RegionPopup->RegionList,
  219.           PANEL_LIST_INSERT, i,
  220.           PANEL_LIST_STRING, i, buf,
  221.           PANEL_LIST_FONT, i, font,
  222.           NULL);
  223.       count++;
  224.       currentRegion = currentRegion->next;
  225.     }
  226.   }
  227.   else                                    /* Delete the excess old strings */
  228.     for (i=tlFrame->numRegion; i < oldlines; i++)
  229.       xv_set(tlFrame->RegionPopup->RegionList,
  230.          PANEL_LIST_DELETE, tlFrame->numRegion,
  231.          NULL);
  232.   if (tlFrame->regionEdit >= 0) 
  233.     xv_set(tlFrame->RegionPopup->RegionList,                /* Select the newly added entry on the panel list */
  234.        PANEL_LIST_SELECT, tlFrame->regionEdit, 
  235.        TRUE, NULL);
  236.   sprintf(selected, "%d", tlFrame->regionEdit + 1);            /* Update the selected Region field */
  237.   xv_set(tlFrame->RegionPopup->RegionSelectValueMsg, PANEL_LABEL_STRING, selected, NULL);
  238.   xv_set(tlFrame->RegionPopup->RegionList,
  239.      XV_SHOW, TRUE, NULL);
  240. }
  241.  
  242. /*
  243.  * This procedure will insert a new region node in the Region list.  
  244.  * It will return the position of the new node in the region list.
  245.  */
  246. int InsertNewRegion(tlFrame, newRegion)
  247.      TimeLineFramePtr tlFrame;
  248.      tlRegion *newRegion;
  249. {
  250.   int selected;
  251.   int found;
  252.   tlRegion *currentRegion;
  253.   
  254.   selected = 0;
  255.   if (tlFrame->regionHead == NULL)                    /* Region list is empty.  Insert at the beginning. */
  256.     tlFrame->regionHead = newRegion;
  257.   else                                    /* Go down the note list to find the appropriate startX to insert */
  258.   {
  259.     currentRegion = tlFrame->regionHead;
  260.     found = 0;
  261.     if (currentRegion->startX > newRegion->startX) 
  262.     {
  263.       found = 1;
  264.       newRegion->next = currentRegion;
  265.       tlFrame->regionHead = newRegion;
  266.     }
  267.     else while (currentRegion->next != NULL && !found)
  268.     {
  269.       selected ++;
  270.       if (currentRegion->next->startX < newRegion->startX) 
  271.     currentRegion = currentRegion->next;
  272.       else 
  273.       {
  274.     newRegion->next = currentRegion->next;
  275.     currentRegion->next = newRegion;
  276.     found = 1;
  277.       }
  278.     }
  279.     if (!found)                                /* Insert at the end of list */
  280.     {
  281.       selected ++;
  282.       currentRegion->next = newRegion;
  283.     }
  284.   }
  285.   return selected;
  286. }
  287.  
  288. /*
  289.  * Notify callback function for `InsertRegionButton'.
  290.  * This function will insert a new region node in the region list and updates the region panel list.
  291.  */
  292. void InsertRegion(item, event)
  293.      Panel_item    item;
  294.      Event        *event;
  295. {
  296.   tlRegion *newRegion;
  297.   int selected;
  298.   TimeLineFramePtr tlFrame;
  299.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  300.   Window    owner = xv_get(ip->RegionPopup, XV_OWNER);
  301.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  302.  
  303.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  304.   if (tlFrame->startX == tlFrame->endX || tlFrame->noteSelected)    /* Check if a region has been selected */
  305.   {
  306.     AlertMessage(tlFrame, "Please select a region first.", NULL, NULL);
  307.     return;
  308.   }
  309.   newRegion = (tlRegion *) malloc (sizeof(struct tlRegion));
  310.   newRegion->next = NULL;
  311.   newRegion->startX = tlFrame->startX;
  312.   newRegion->endX = tlFrame->endX;
  313.   newRegion->startMin = 0;
  314.   newRegion->startSec = newRegion->startX / PixelsPerSecond;
  315.   strcpy (newRegion->label, (char *) xv_get(tlFrame->RegionPopup->RegionLabelText, PANEL_VALUE));
  316.   while (newRegion->startSec >= 60) 
  317.   {
  318.     newRegion->startMin ++;
  319.     newRegion->startSec -= 60;
  320.   }
  321.   newRegion->endMin = 0;
  322.   newRegion->endSec = newRegion->endX / PixelsPerSecond;
  323.   while (newRegion->endSec >= 60) 
  324.   {
  325.     newRegion->endMin ++;
  326.     newRegion->endSec -= 60;
  327.   }
  328.   selected = InsertNewRegion(tlFrame, newRegion);
  329.   tlFrame->numRegion++;
  330.   tlFrame->regionEdit = selected;
  331.   tlFrame->selectedRegion = newRegion;
  332.   ScrollToFirstQuarter(tlFrame, newRegion->startX, 0);            /* Scroll to make the newly inserted Region marker visible */
  333.   if (tlFrame->areaSelected)                        /* Clear the previously selected area */
  334.     XFillRectangle(tlFrame->dpyDraw, tlFrame->xidDraw, tlFrame->gcLine, (tlFrame->startX  / tlFrame->zoomLevel) - tlFrame->canvasStart, 
  335.            tlFrame->startY, (tlFrame->endX - tlFrame->startX) / tlFrame->zoomLevel,
  336.            tlFrame->endY - tlFrame->startY);
  337.   tlFrame->startY = 0;
  338.   tlFrame->endY = tlFrame->numberOfApps * (IconHeight + IconGap);
  339.   DrawSelectArea(tlFrame);
  340.   UpdateRegionList(tlFrame);
  341.   tlFrame->change = 1;                            /* Set the change flag to 1 */
  342.   UpdateHeader(tlFrame, 1);
  343. }
  344.  
  345. /*
  346.  * Notify callback function for `DeleteRegionButton'.
  347.  * Deletes the currently selected entry from the region info panel list and also the corresponding node from the region list.
  348.  */
  349. void DeleteRegion(item, event)
  350.      Panel_item    item;
  351.      Event        *event;
  352. {
  353.   TimeLineFramePtr tlFrame;
  354.   tlRegion *currentRegion, *prevRegion;
  355.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  356.   int found;
  357.   Window    owner = xv_get(ip->RegionPopup, XV_OWNER);
  358.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  359.   
  360.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  361.   if (tlFrame->regionHead == NULL || tlFrame->regionEdit == -1)        /* Region list is empty, or there is no edit chosen */
  362.     return;    
  363.   xv_set(tlFrame->RegionPopup->RegionList,                /* Deselect the selected entry on the panel list */
  364.      PANEL_LIST_SELECT, tlFrame->regionEdit, 
  365.      FALSE, NULL);
  366.   currentRegion = tlFrame->regionHead;
  367.   if (currentRegion == tlFrame->selectedRegion) 
  368.     tlFrame->regionHead = currentRegion->next;
  369.   else 
  370.   {
  371.     prevRegion = currentRegion;
  372.     currentRegion = currentRegion->next;
  373.     found = 0;
  374.     while (currentRegion != NULL && !found) 
  375.     {
  376.       if (currentRegion == tlFrame->selectedRegion) 
  377.       {
  378.     prevRegion->next = currentRegion->next;
  379.     found = 1;
  380.       }
  381.       prevRegion = currentRegion;
  382.       if (!found) 
  383.     currentRegion = currentRegion->next;
  384.     }
  385.   }
  386.   tlFrame->numRegion --;
  387.   tlFrame->regionEdit = -1;
  388.   tlFrame->selectedRegion = NULL;
  389.   free (currentRegion);
  390.   UpdateRegionList(tlFrame);
  391.   tlFrame->change = 1;                            /* Set the change flag to 1 */
  392.   UpdateHeader(tlFrame, 1);
  393. }
  394.  
  395. /*
  396.  * Notify callback function for `ModifyRegionButton'.
  397.  * Modifies the currently selected entry in the region info panel list.
  398.  */
  399. void ModifyRegion(item, event)
  400.      Panel_item    item;
  401.      Event        *event;
  402. {
  403.   char buf[100];
  404.   TimeLineFramePtr tlFrame;
  405.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  406.   Window    owner = xv_get(ip->RegionPopup, XV_OWNER);
  407.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  408.   
  409.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  410.   if (tlFrame->selectedRegion != NULL) 
  411.   {
  412.     tlFrame->selectedRegion->startX = tlFrame->startX;
  413.     tlFrame->selectedRegion->endX = tlFrame->endX;
  414.     strcpy (tlFrame->selectedRegion->label, (char *) xv_get(tlFrame->RegionPopup->RegionLabelText, PANEL_VALUE));
  415.     tlFrame->selectedRegion->startMin = 0;
  416.     tlFrame->selectedRegion->startSec = tlFrame->selectedRegion->startX / PixelsPerSecond;
  417.     while (tlFrame->selectedRegion->startSec >= 60) 
  418.     {
  419.       tlFrame->selectedRegion->startMin ++;
  420.       tlFrame->selectedRegion->startSec -= 60;
  421.     }
  422.     tlFrame->selectedRegion->endMin = 0;
  423.     tlFrame->selectedRegion->endSec = tlFrame->selectedRegion->endX / PixelsPerSecond;
  424.     while (tlFrame->selectedRegion->endSec >= 60) 
  425.     {
  426.       tlFrame->selectedRegion->endMin ++;
  427.       tlFrame->selectedRegion->endSec -= 60;
  428.     }
  429.     sprintf(buf, "   %4d.    %-25.22s%4d:%02d  %4d:%02d",
  430.         tlFrame->regionEdit + 1, tlFrame->selectedRegion->label,
  431.         tlFrame->selectedRegion->startMin, tlFrame->selectedRegion->startSec,
  432.         tlFrame->selectedRegion->endMin, tlFrame->selectedRegion->endSec); 
  433.     xv_set(tlFrame->RegionPopup->RegionList,
  434.        PANEL_LIST_STRING, tlFrame->regionEdit, buf,
  435.        PANEL_LIST_FONT, tlFrame->regionEdit, font,
  436.        NULL);
  437.     tlFrame->change = 1;                        /* Set the change flag to 1 */
  438.     if (tlFrame->areaSelected)                        /* Clear the previously selected area */
  439.       XFillRectangle(tlFrame->dpyDraw, tlFrame->xidDraw, tlFrame->gcLine, (tlFrame->startX  / tlFrame->zoomLevel) - tlFrame->canvasStart, 
  440.              tlFrame->startY, (tlFrame->endX - tlFrame->startX) / tlFrame->zoomLevel,
  441.              tlFrame->endY - tlFrame->startY);
  442.     tlFrame->startY = 0;
  443.     tlFrame->endY = tlFrame->numberOfApps * (IconHeight + IconGap);
  444.     DrawSelectArea(tlFrame);
  445.     UpdateHeader(tlFrame, 1);
  446.   }
  447. }
  448.  
  449. /*
  450.  * Notify callback function for `ClearAllRegionButton'.
  451.  * Clear the whole region list of all entries.
  452.  */
  453. void ClearAllRegion(item, event)
  454.      Panel_item    item;
  455.      Event        *event;
  456. {
  457.   TimeLineFramePtr tlFrame;
  458.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  459.   Window    owner = xv_get(ip->RegionPopup, XV_OWNER);
  460.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  461.  
  462.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  463.   if (tlFrame->numRegion > 0) 
  464.   {
  465.     tlFrame->change = 1;                        
  466.     UpdateHeader(tlFrame, 1);
  467.     FreeRegion(tlFrame);
  468.     UpdateRegionList(tlFrame);
  469.   }
  470. }
  471.  
  472. /*
  473.  * Notify callback function for `RegionDoneButton'.
  474.  * Close the region info popup window.
  475.  */
  476. void CloseRegionPopup(item, event)
  477.      Panel_item    item;
  478.      Event        *event;
  479. {
  480.   Region_RegionPopup_objects    *ip = (Region_RegionPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  481.  
  482.   xv_set(ip->RegionPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  483.   xv_set(ip->RegionPopup, XV_SHOW, FALSE, NULL);
  484. }
  485.  
  486. /*
  487.  * This procedure will free all the Region nodes in a Region list.
  488.  */
  489. void FreeRegion(tlFrame)
  490.      TimeLineFramePtr tlFrame;
  491. {
  492.   tlRegion *region, *freeRegion;
  493.   
  494.   region = tlFrame->regionHead;                        /* Free all the Region nodes */
  495.   while (region != NULL) 
  496.   {
  497.     freeRegion = region;
  498.     region = region->next;
  499.     free (freeRegion);
  500.   }
  501.   tlFrame->regionHead = NULL;
  502.   tlFrame->regionEdit = -1;
  503.   tlFrame->selectedRegion = NULL;
  504.   tlFrame->numRegion = 0;
  505. }
  506.  
  507. /*
  508.  * This function will set the start and end fields in the region info popup window.
  509.  */
  510. void SetStartEndRegion(tlFrame, startX, endX)
  511.      TimeLineFramePtr tlFrame;
  512.      int startX;
  513.      int endX;
  514. {
  515.   int min, sec;
  516.   char buf[7];
  517.  
  518.   sec = startX / PixelsPerSecond;
  519.   min = 0;
  520.   while (sec >= 60) 
  521.   {
  522.     min ++;
  523.     sec -= 60;
  524.   }
  525.   sprintf (buf, "%4d:%02d", min, sec);
  526.   xv_set(tlFrame->RegionPopup->StartRegionValueMsg, PANEL_LABEL_STRING, buf, NULL);
  527.   sec = endX / PixelsPerSecond;
  528.   min = 0;
  529.   while (sec >= 60) 
  530.   {
  531.     min ++;
  532.     sec -= 60;
  533.   }
  534.   sprintf (buf, "%4d:%02d", min, sec);
  535.   xv_set(tlFrame->RegionPopup->EndRegionValueMsg, PANEL_LABEL_STRING, buf, NULL);
  536.   
  537. }
  538.  
  539.  
  540.  
  541.