home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / quotemkr / qtmkrdfs.h < prev    next >
Encoding:
Text File  |  1993-06-15  |  19.1 KB  |  508 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 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/QuoteMaker/RCS/quoteMakerDefs.h,v 2.2 92/05/29 12:41:29 drapeau Exp $ */
  25. /* $Log:    quoteMakerDefs.h,v $
  26.  * Revision 2.2  92/05/29  12:41:29  drapeau
  27.  * Modified code to track new name of the MAEstro "Selection" structure;
  28.  * it is now named "MAESelection".
  29.  * 
  30.  * Revision 2.1  92/05/14  15:41:58  drapeau
  31.  * * Updated copyright information.
  32.  * * Removed declaration of SemiHighlightSelection() as it is no longer used.
  33.  * 
  34.  * Revision 2.0  91/09/30  15:02:54  derek
  35.  * Version number changed to 2.0.
  36.  * 
  37.  * Revision 1.33  91/09/15  20:06:39  derek
  38.  * The following things are done:
  39.  * 1.      The foreground of mainTextPane and Quote Window are set to be black.
  40.  *         Also, the color of all the text fields are set to black.
  41.  * 2.      Now the quoted text will be shown directly on the Quote Window
  42.  *         when a panel-item selection is made.  The text will also be shown
  43.  *         while the author is highlighting a selection in the text window.
  44.  * 3.      The inconsistency problem regarding text selection is being taken
  45.  *         care of.  When the mouse cursor re-enters the text window,
  46.  *         the selection will be highlighted again.
  47.  * 4.      When the play button is pressed, the text currently selected
  48.  *         in the text window (rather than the text initially associated
  49.  *         with the edit) will be displayed.
  50.  * 5.      The name of the menu_option "Show Quote Window Specifications panel"
  51.  *         is shortened to be "Quote Window Options ..."
  52.  * 6.      A notify_interpose_destroy_func() is being added to fix the bug
  53.  *         that QuoteMaker might exit without killing the Quote Window (which
  54.  *         is also a base window).
  55.  * 7.      When a different font family or font style is selected, the change
  56.  *         will be automatically be reflected on the Quote Window (without the
  57.  *         need to "play" the edit in order to verify the font).  For font
  58.  *         size, the change will be reflected when either a return character is
  59.  *         entered at the text field or when one of those numeric "arrows"
  60.  *         are pressed.
  61.  * 8.      The play button will now flash when an edit is being played.
  62.  *         Pause button will also glow when playing is paused.
  63.  * 9.      In the course of playing, when another edit is selected,
  64.  *         the playing will be stopped.
  65.  * 10.     I have used Saber to clean up the code.
  66.  * 11.     The left-over "NewEditListPopUp" window is removed.
  67.  * 12.     The bug that when quote window is iconified, it wont be un-iconified
  68.  *         when the edit is played in timeline, is fixed.
  69.  * 13.     The DurationEstimate function is changed so that it no longer
  70.  *         needs an edit to be selected first.  It will take textWindowStart
  71.  *         and textWindowEnd directly as input parameters.
  72.  * 
  73.  * 
  74.  * 
  75.  * Revision 1.32  91/09/05  15:48:08  derek
  76.  * The following changes are made:
  77.  * 1.      The name "Quoted Text Window" has been changed to "Quote Window"
  78.  *         in the app.
  79.  * 2.      ShowApplication() and HideApplication() is changed because of the
  80.  *         the change of quote window from a popup to a basewindow.
  81.  * 3.      The QuitProc of QuoteMaker is fixed so that the quote window,
  82.  *         as a base window, will be destroyed separately.
  83.  * 4.      Now hitting return in the label field will not result in adding
  84.  *         a new edit.
  85.  * 5.      Copyright messages are included in front of every .h and .c file.
  86.  * 6.      The scrollbar and the footer of the Quote Window are hidden.
  87.  * 7.      I have changed the include openpanel.h statement in QuoteMaker.c
  88.  *         to include Browse.h.
  89.  * 8.      The delete bug corresponding to the change that the panel-list
  90.  *         must have a choice -- is fixed.  Also, the corresponding bug
  91.  *         for deleteAll is also fixed.
  92.  * 9.      Now, deleteAll and deletion of the last item in Panel_list
  93.  *         will cause the panel-list to be destroyed and a new one will
  94.  *         be created.
  95.  * 10.     GetOpt files have been removed from the directory.  Corresponding
  96.  *         changes are made.
  97.  * 11.     The start and end byte fields are removed from the main panel.
  98.  * 12.     I have put iconify, hide and show quote window to be buttons
  99.  *         instead of menu options.
  100.  * 13.     I have removed the PreviewPanelPopup and incorporated its features into
  101.  *         the main panel.  The three buttons:  pause, play and stop and
  102.  *         the DurationGauge are moved to the main panel.  But the
  103.  *         StatusMessage is removed.
  104.  * 14.     The EnableLocationChange and EnableSizeChange choice setting
  105.  *         are removed.  There are no longer such choices.
  106.  * 15.     Right now if a panel-item is selected and if another panel-item
  107.  *         is picked, the DeselectList() operation in the middle is
  108.  *         eliminated.  This operation involves updating of text fields and
  109.  *         messages and its removal speeds up the program.  The panel-list
  110.  *         must now take at least one choice.  (A choice must be selected
  111.  *         whenever there is at least one item on the list).  And now
  112.  *         there is no way to deselect a list by the user.
  113.  * 16.     The "modified bit" associated with the CurrentSelectionNumberLabel
  114.  *         is implemented.  Now, if a selection is picked, and if either
  115.  *         the quote window is moved or any text fields are changed, the
  116.  *         modified bit will be on.
  117.  * 17.     The Show-text-window button and the Show-quote-window-specifications-popup
  118.  *         button are removed.  They are now menu options under the Options Menu.
  119.  * 18.     The Modify button has its name changed to "Update Edit".
  120.  * 
  121.  * Revision 1.31  91/08/27  14:37:45  derek
  122.  * The following things are done:
  123.  * 1.    The QuotedTextWindow is changed from a base window to a popup window
  124.  *     (now it's called QuotedMaker_quotedTextBaseWindow).  I have also
  125.  *     added a few options: show, hide and iconify QTW and also created
  126.  *     an icon for QTW.
  127.  * 2.    The quoted text will be set in PerformSelection() instead of 
  128.  *     in SetSelection().
  129.  * 3.    I have changed the Document field and the EditList field of 
  130.  *     QuoteMaker so that they will display fill paths.
  131.  * 
  132.  * Revision 1.30  91/08/26  12:10:30  derek
  133.  * The following things are done:
  134.  * 1.    I have added a few notice_prompts to the linkProtocol (network)
  135.  *     functions to give warnings about invalid document names.
  136.  * 2.    The quoted text window will by default be hidden during "blank"
  137.  *     times. ie. when it is not displaying any text.  The interface has
  138.  *     been changed so that it now has a HideQuotedTExtWindowAfterPreview
  139.  *     check box.  The QuotedTextWindow will either stay on the screen
  140.  *     or be hidden as the author desires.
  141.  * 3.    Make the changes corresponding to the changing of name from OpenPanel
  142.  *     to Browse.
  143.  * 4.    The return value bug for OpenHandler, SaveHandler is fixed.
  144.  * 5.    I have changed the code so that Save and SaveAs will behave correctly.
  145.  *     The SaveAs PopUp/Open PopUp are removed.  Browse check is 
  146.  *     incorporated in the applications.
  147.  * 6.    The QuoteMaker file format has been changed.  An EditNumber field    
  148.  *     has been added.
  149.  * 7.    Changes corresponding to the return value by OpenDoc and SetSelection
  150.  *     are made.
  151.  * 8.    GetAppIcon() has been implemented.
  152.  * 9.    Fonts specified in the Edit-list will be preloaded in OpenDoc().
  153.  *     This will hopefully eliminate the startup delay needed to load
  154.  *     the font when we put text onto the Quoted TExt Window for the 
  155.  *     first time.
  156.  * 10.    The "play" button will now play things specified in the 
  157.  *     QuotedTExtWindowSpecificationsPopUp (instead of those specified
  158.  *     in the editList).
  159.  * 11.    The show selection button is replaced by the set selection button.
  160.  *     The Set Selection button willl now not only set the current
  161.  *     edit parameters but will also highlight the corresponding section
  162.  *     in the text.  Also, when one item on the panel-list is clicked on,
  163.  *     the corresponding segment in the text will also be highlighted.
  164.  * 12.    Notify events which tells the app to show the size and location 
  165.  *     of the Quoted Text Window are set up.  ie. those text-fields
  166.  *     on the interface will be updated instantaneously.
  167.  * 16.    editList.label is being sent across the network.
  168.  * 17.    The title bar and the footer of the QuotedTExtWindow are hidden.
  169.  * 
  170.  * Revision 1.29  91/08/13  22:53:01  derek
  171.  * I have incorporated the openpanel/savepanel stuff.
  172.  * 
  173.  * Revision 1.28  91/08/09  18:18:55  derek
  174.  * I removed all the free() statements from the code to
  175.  * fix the bug and improve run-time efficiency.
  176.  * 
  177.  * Revision 1.27  91/07/22  16:47:10  derek
  178.  * I have added 4 buttons to get and set the current
  179.  * location and size of the quoted text window.
  180.  * 
  181.  * Revision 1.26  91/07/15  12:20:34  derek
  182.  * 1.      I have added font selection panel to the application.
  183.  *         Now a user can specify a font by choosing a font family, a font
  184.  *         style and font size.
  185.  * 2.      Location and size fields are added to the application.  User
  186.  *         can specify the size and location of the QuotedTextWindow.
  187.  * 3.      A duration estimate button is added to estimate how long the
  188.  *         the quoted text should last.
  189.  * 4.      Interface has been redesigned to accomodate the addition of
  190.  *         font, size and location functionalities.
  191.  * 6.      EditList file format has been changed to accomodate the new
  192.  *         fields.  They are:  location (x,y), width, height, font family,
  193.  *         font style, font width for QuotedTextWindow.
  194.  * 5.      Two timers have been added in an attempt to ensure accuracy
  195.  *         of gauge-updating in the preview panel.
  196.  * 6.      Command line args are now supported.
  197.  * 7.      I have cleaned up the code by using saber.
  198.  * 8.      Several bugs from previous revision are fixed.
  199.  * 
  200.  * 
  201.  * Revision 1.25  91/07/02  15:08:02  derek
  202.  * QuoteMaker now fully speaks the new MAEstro protocol.
  203.  * 
  204.  * Revision 1.24  91/07/01  18:51:58  derek
  205.  * The following things are done:
  206.  * 1.    The interface is redesigned.  Duration fields are added to each 
  207.  *     edit list.
  208.  * 2.    The function panel (functions Window) is implemented.  The 
  209.  *     application is now capable of being "played", "stopped" and
  210.  *     "paused".  The sense of "time" is now complete.
  211.  * 3.    Makefile fixed.  
  212.  * 4.    Declaration errors left by previous author are cleaned up.
  213.  * 5.    Redundant malloc statements removed.   Certain other
  214.  *     functions are changed to improve code efficiency.
  215.  * 6.    Code cleaned up by saber.  Removed redundant
  216.  *     variables.
  217.  * 
  218.  * Revision 1.23  91/06/28  13:16:07  derek
  219.  * Blank functions added to the code to make the application "compatible"
  220.  * with the new protocol.
  221.  * 
  222.  * Revision 1.22  91/06/27  18:21:27  derek
  223.  * I have cleaned up some of the comments.  No change in code.
  224.  * 
  225.  * Revision 1.21  91/06/19  17:44:44  drapeau
  226.  * No changes; changing RCS revision numbers.
  227.  * 
  228.  * Revision 1.2  91/05/06  01:54:21  drapeau
  229.  * Using new version of RCS for this module; no other changes have been made.
  230.  * 
  231.  * Revision 1.1  90/12/04  17:21:58  drapeau
  232.  * Initial revision
  233.  *  */
  234.  
  235. static char quoteMakerDefsRcsid[] = "$Header: /Source/Media/collab/QuoteMaker/RCS/quoteMakerDefs.h,v 2.2 92/05/29 12:41:29 drapeau Exp $";
  236.  
  237. #include "QuoteMaker_ui.h"
  238.  
  239. #ifndef _selection_c_                            /* Is this being included by the selection.c file? */
  240. #include "Sender.h"                            /* No, it's okay to include defs for the Link... */
  241.                                     /* ...Protocol.  */
  242. #include "Receiver.h"
  243. #endif
  244.  
  245. #define MAXLISTSIZE    1000
  246.  
  247. typedef char BOOL;
  248.  
  249. typedef struct EditList                            /* Structure to hold the data in an edit list */
  250. {
  251.   int        numItems;
  252.   int        start[MAXLISTSIZE];
  253.   int        end[MAXLISTSIZE];
  254.   double    duration[MAXLISTSIZE];
  255.   int        locX[MAXLISTSIZE];
  256.   int        locY[MAXLISTSIZE];
  257.   int        sizeWidth[MAXLISTSIZE];
  258.   int        sizeHeight[MAXLISTSIZE];
  259.   int        fontFamily[MAXLISTSIZE];
  260.   int        fontStyle[MAXLISTSIZE];
  261.   int        fontSize[MAXLISTSIZE];
  262.   int        hideQTWAfterPlayingEdit[MAXLISTSIZE];
  263.   char        *label[MAXLISTSIZE];
  264. } EditList;
  265.  
  266.  
  267. #define    NO_CURRENT_EDIT     -10
  268. #define PRIMARY_SELECTION     1   
  269. #define MAX_ENTRY_LEN         44 
  270. #define LABEL_START         4
  271. #define LABEL_END         23
  272. #define MAX_LABEL_LEN         20
  273.  
  274. #define MAX_MESSAGE_LEN     50                    /* Because label goes from char 4 to 23, labels... */
  275.                                     /* ... should be allocated to MAX_LABEL_LEN + 1.   */
  276. #define MAX_EDITLIST_LENGTH    200
  277. #define MAX_FILETYPE_LEN    50
  278. #define MAX_TEXTSW_LEN         500000
  279. #define LINK_EDITOR         -1
  280. #define USER             -2
  281. #define YES             1
  282. #define NO             0
  283.     
  284.  
  285. /* ----------------------------------------------------------------------------
  286.    Globals
  287. */
  288.  
  289. extern Attr_attribute    INSTANCE;                    /* XView makes this global necessary. */
  290. extern Xv_Server    server;
  291.  
  292. extern void        OpenDoc();                    /* Functions that the link editor needs.*/
  293. extern void        SetSelection();
  294. extern void        PerformSelection();
  295. extern char**        GetDoc();
  296. extern void        HaltSelection();
  297. extern void        PauseSelection();
  298. extern void        ResumeSelection();
  299. extern void         HideApplication();
  300. extern void        ShowApplication();
  301. extern int        mostRecentEditNum;
  302.  
  303. #ifndef _selection_c_                            /* Is this being included by the selection.c file? */
  304. extern MAESelection*    GetSelection();                    /* No, it's okay to include variables for the Link Protocol. */
  305. extern IconData        *GetAppIcon();
  306. extern Sender*        sender;
  307. extern Receiver*    receiver;
  308. extern Port        senderPort;
  309. #endif
  310.  
  311.  
  312. /* Variables describing documents and edit lists. */
  313. extern char    absoluteDocumentName[];
  314. extern char    absoluteEditListName[];
  315. extern int    unsavedChangesExist;
  316. extern int    untitledEditListNum;                        /* So we can say untitled0  */
  317. extern EditList    editList;
  318.  
  319. extern Xv_font *listFont;
  320. extern Xv_font *displayFont;
  321. extern Xv_font *annotateFont;
  322.  
  323. /* Variables for interface components. */
  324. extern QuoteMaker_baseWindow_objects        *QuoteMaker_baseWindow;
  325. QuoteMaker_quotedTextBaseWindow_objects            *QuoteMaker_quotedTextBaseWindow;
  326. extern QuoteMaker_infoPopup_objects        *QuoteMaker_infoPopup;
  327. extern QuoteMaker_textWindowPopup_objects    *QuoteMaker_textWindowPopup;
  328. extern QuoteMaker_QuoteWindowSpecificationsPopup_objects    *QuoteMaker_QuoteWindowSpecificationsPopup;
  329.  
  330.  
  331. /* ----------------------------------------------------------------------------
  332.    Utilities: Textwindow stuff
  333. */
  334.  
  335. void UnHighlightSelection();
  336. void HighlightSelection ();
  337. void GetSelectionEndpoints ();
  338.  
  339. /********
  340. #define DEBUG
  341. ********/
  342.  
  343. /*
  344.  * Some debugging routines.
  345.  */
  346. #ifdef DEBUG
  347. #define EVENT(P)     printf("Event: %s\n", (P))
  348. #else
  349. #define EVENT(P)
  350. #endif
  351.  
  352.  
  353. /*
  354.  *  timer.c
  355.  */
  356. extern    void        SetTimer();
  357. extern    void        CancelTimer();
  358. extern    Notify_value    TimerHandler();
  359. extern    void        InitTimer();
  360. extern  Notify_value    UpdateGaugeHandler();
  361. extern    void        SetButtonGlowTimer();
  362. extern    void        CancelButtonGlowTimer();
  363. extern    Notify_value    ButtonGlowTimerHandler();
  364.  
  365.  
  366.  
  367. /*
  368.  *  QuoteMaker.c
  369.  */
  370. char                    Entry[MAX_EDITLIST_LENGTH];
  371. BOOL                    QTWLocationChangeEnabled;
  372. BOOL                    QTWSizeChangeEnabled;
  373. BOOL            HideQTWAfterPlayingEdit;
  374. int            OldSizeWidth;
  375. int            OldSizeHeight;
  376. int            OldLocX;
  377. int            OldLocY;
  378. int            textWindowStart;
  379. int            textWindowEnd;
  380.  
  381. extern    void        AddSelection();
  382. extern    void        Show();
  383. extern    void        GiveOneLastChanceToSave();
  384. extern    void        SetCurrentSelection();
  385. extern    char        *FormatEntry();
  386. extern    void        ResetCurrentSelection();
  387. extern    void        UpdateNumEditsMessage();
  388. extern    void        ReadEntry();
  389. extern    void        Alert();
  390. extern    char        *ShortName();
  391. extern    void        SetDocument();
  392. extern  void        InitMainPanel();
  393. extern    void        CheckOptions();
  394. extern    void        LocationChangeEnableSettingHandler();
  395. extern    void        SizeChangeEnableSettingHandler();
  396. extern    void        ShowTextWindowSelection();
  397. extern    void        AlertByNoticePrompt();
  398. extern    void        SetCurrentSizeHandler();
  399. extern    void        SetCurrentLocationHandler();
  400. extern    void        GetCurrentSizeHandler();
  401. extern    void        GetCurrentLocationHandler();
  402. extern    void        InitTextFields();
  403.  
  404.  
  405. /*
  406.  *  editList.c
  407.  */
  408. extern    void        SetEditList();
  409. extern    void        DeselectList();
  410. extern    void        DeleteItemFromEditList();
  411. extern    void        EmptyList();
  412. extern    void        OpenEditList();
  413. extern    int        ReadEditListFromFile();
  414. extern    void        SaveEditList();
  415. extern    int        WriteEditListToFile();
  416. extern    void        NewEditList();
  417. extern    void        Hide();
  418. extern    void        RedrawEditList();
  419. extern  void        ClearQuoteWindowSpecificationsPopup();
  420. extern    int        Selected();
  421. extern    void        CheckIfEditModified();
  422. extern    void        ClearEditModified();
  423.  
  424.  
  425. #define    SAVE        0
  426. #define    SAVE_AS        1
  427.  
  428.  
  429. /*
  430.  *  functions.c
  431.  */
  432. BOOL            PlayPaused;
  433. BOOL            Playing;
  434. char            msg[512];
  435. int            BlackColorIndex;
  436. int            GreenColorIndex;
  437.  
  438. extern    void        AlertStatus();
  439. extern    void        ClearStatusMessage();
  440. extern    void        ClearQuotedTextWindow();
  441. extern    void        PauseButtonHandler();
  442. extern    void        StopButtonHandler();
  443. extern    void        PutInDefaultDuration();
  444. extern    void        InitQuotedTextWindow();
  445. extern    void        EnableQTWLocationChange();
  446. extern    void        DisableQTWLocationChange();
  447. extern    void        EnableQTWSizeChange();
  448. extern    void        DisableQTWSizeChange();
  449. extern    void        EnableHideQTWAfterPlayingEdit();
  450. extern    void        DisableHideQTWAfterPlayingEdit();
  451. extern    void        SetCurrentLocation();
  452. extern    void        GetCurrentLocation();
  453. extern    void        SetCurrentSize();
  454. extern    void        GetCurrentSize();
  455. extern  void        DisplayTextOnQuoteWindow();
  456. extern  Notify_value    DestroyQuoteWindow();
  457. extern    Notify_value    DestroyBaseWindow();
  458. extern    void        UpdateButtonGlow();
  459. extern    void        CancelButtonGlow();
  460.  
  461. #define    GLOW_INTERVAL    0.5
  462.  
  463.  
  464. /*
  465.  *  font.c
  466.  */
  467. #define MAX_NUM_OF_FONT_FAMILIES  7
  468. #define MAX_NUM_OF_FONT_STYLES    5
  469. #define NONE_SELECTED          -1
  470.  
  471. extern    int        currentFontFamily;
  472. extern    int        currentFontStyle;
  473. extern    int        currentFontSize;
  474. extern    char        *GetFontFamilyFromList();
  475. extern    char        *GetFontStyleFromList();
  476. extern    void        InitFontPanel();
  477. extern  void            SetFontPanel();
  478. extern  char        *UpperCase();
  479. extern  char        *GetFontFamilyFromItemNum();
  480. extern    char        *GetFontStyleFromItemNum();
  481. extern    void        SetQuotedTextWindowLocation();
  482. extern    void        SetQuotedTextWindowSize();
  483. extern    void        SetQuotedTextWindowFont();
  484. extern    Notify_value    QuotedTextWindowInterposer();
  485. extern    void        PreloadFontsOntoQTW();
  486.  
  487. Rect            QuoteTextWindowRect;
  488. int                     EditTextFieldOrChoiceModified;
  489.  
  490. #define    FRAME_X_OFFSET    5
  491. #define FRAME_Y_OFFSET    26
  492.  
  493.  
  494. /*
  495.  *  openpanel.c
  496.  */
  497. extern    void        InitBrowse();
  498. extern    int        OpenHandler();
  499. extern    int        SaveHandler();
  500.  
  501. char     *documentFirstLine;
  502. char     *documentFileType;
  503.  
  504. #define    IS_TEXTFILE    1
  505. #define    IS_EDITLIST    2
  506. #define FILE_OK        0
  507. #define FILE_NOT_OK    -1
  508.