home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / biz / misc / banker / src / list.c < prev    next >
C/C++ Source or Header  |  1993-12-17  |  3KB  |  107 lines

  1. /*
  2.  * list.c
  3.  */
  4.  
  5. /*  $Id: list.c,v 1.7 1993/09/03 00:17:28 beust Exp beust $  */
  6.  
  7. #include "common.h"
  8.  
  9.  
  10. void
  11. openListWindow(Gui_t gui, Entries entries)
  12. {
  13.    set(gui -> listWindowObject, MUIA_Window_Open, TRUE);
  14.    fullDisplayList(gui, entries);
  15. }
  16.  
  17. void
  18. simpleDisplayList(Gui_t gui, Entries entries)
  19. {
  20.    DoMethod(gui -> liListObject, MUIM_List_Redraw, MUIV_List_Redraw_All);
  21.    set(gui -> liListObject, MUIA_List_Active, MUIV_List_Active_Top);
  22. }
  23.  
  24. void
  25. fullDisplayList(Gui_t gui, Entries entries)
  26. {
  27.    char validatedString[40], totalString[40];
  28.    int windowOpen;
  29.  
  30.   get(gui -> listWindowObject, MUIA_Window_Open, & windowOpen);
  31.   if (windowOpen) {
  32.   /* Create the new list */
  33.      buildList(gui, entries, TRUE, TRUE, & gui -> entrySA);
  34.  
  35.   /* calculate the new totals */
  36.      sprintf(validatedString, getString(MSG_VALIDATED),
  37.              computeValidatedTotal(entries));
  38.      set(gui -> liValidatedObject, MUIA_FrameTitle, validatedString);
  39.  
  40.      sprintf(totalString, getString(MSG_TOTAL), computeTotal(entries));
  41.      set(gui -> liTotalObject, MUIA_FrameTitle, validatedString);
  42.  
  43.   /* Redraw the list */
  44.      simpleDisplayList(gui, entries);
  45.   }
  46. }
  47.  
  48. void
  49. handleValidate(Gui_t gui, Entries entries, Entry entry)
  50. {
  51. /* don't edit it if it was automatically generated */
  52.    if (! entry -> fake) {
  53.  
  54.       entry -> validated = (entry -> validated == TRUE ? FALSE : TRUE);
  55.       set(gui -> liListObject, MUIA_List_Quiet,FALSE);
  56.       DoMethod(gui -> liListObject, MUIM_List_Redraw,MUIV_List_Redraw_Active);
  57.       FileModified = 1;
  58.    }
  59. }
  60.  
  61. void
  62. handleEdit(Gui_t gui, Entries entries, Entry entry)
  63. {
  64.    char validatedString[40], totalString[40];
  65.  
  66. /* edit it as an entry if it is a real one, or an automatic if it is fake */
  67.    if (entry -> fake)
  68.       editAutomatic(gui, entry -> generatedBy);
  69.    else
  70.       editEntry(gui, entry);
  71. }
  72.  
  73. void
  74. handleDelete(Gui_t gui, Entries entries, Entry entry)
  75. {
  76.    char validatedString[40], totalString[40];
  77.    DataBase db = (DataBase) entries -> list;
  78.  
  79.    if (entry -> fake) {   /* warn about deleting an auto entry */
  80.       if (showRequester(gui, getString(MSG_TITLE_DELETION),
  81.                                   getString(MSG_BODY_DELETION_AUTO),
  82.                                   getString(MSG_YES_OR_NO)) == 0) return;
  83.  
  84.       /* find the corresponding auto and delete it */
  85.       db = (DataBase) entries -> automatic;
  86.       deleteAutomatic(gui, entries, entry -> generatedBy);
  87.    }
  88.    else {
  89.       if (showRequester(gui, getString(MSG_TITLE_DELETION),
  90.                                   getString(MSG_BODY_DELETION_ENTRY),
  91.                                   getString(MSG_YES_OR_NO)) == 0) return;
  92.  
  93.       /* Remove the selected entry */
  94.       DoMethod(gui -> liListObject, MUIM_List_Remove, MUIV_List_Remove_Active);
  95.  
  96.       /* delete this entry */
  97.       DB_RemoveEntry(db, entry);
  98.       
  99.    }
  100.  
  101. /* re-display the list */
  102.    fullDisplayList(gui, entries);
  103.  
  104. /* Remember the file was modified */
  105.    FileModified = 1;
  106. }
  107.