home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / rsys-1.3.lha / RSys-1.3 / src / RSysGfxIntuiLists.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-07  |  15.4 KB  |  648 lines

  1. /*
  2. ***************************************************************************
  3. *
  4. * Datei:
  5. *    RSysGfxIntuiLists.c
  6. *
  7. * Inhalt:
  8. *    void MakeFontList(void);
  9. *    void MakeWindowList(void);
  10. *    void MakeScreenList(void);
  11. *    void SysPubScreenList(void);
  12. *    void RSysGetDisplayModes(void);
  13. *    void SysTOFWaitList(void);
  14. *    void SysBlitterWaitList(void);
  15. *
  16. * Bemerkungen:
  17. *    Listen der Graphics- und Intuition-Library.
  18. *    (Teilweise ausgelagert aus RSysSpecialLists.c)
  19. *
  20. * Erstellungsdatum:
  21. *    07-Jul-93    Rolf Böhme
  22. *
  23. * Änderungen:
  24. *    07-Jul-93    Rolf Böhme    Erstellung
  25. *
  26. ***************************************************************************
  27. */
  28.  
  29. #include "RSysFunc.h"
  30. #include "RSysDebug.h"
  31.  
  32.    /*
  33.     * MakeFontList() erzeugt eine Liste aller im System in der
  34.     * GfxBase definierten Fonts
  35.     */
  36. void
  37. MakeFontList(void)
  38. {
  39.    struct Node *node;
  40.    struct TextFont *font;
  41.    int   i = 0;
  42.  
  43.    DPOS;
  44.  
  45.    countentries = CountNodes(&GfxBase->TextFonts);
  46.  
  47.    if (NoEntries())
  48.       return;
  49.  
  50.    Entries = AllocScrollEntries(countentries);
  51.  
  52.    Forbid();
  53.  
  54.    for (node = GfxBase->TextFonts.lh_Head;
  55.         node->ln_Succ && (i < countentries); node = node->ln_Succ)
  56.    {
  57.       font = (struct TextFont *) node;
  58.  
  59.       Entries[i].se_obj_id.address = font;
  60.       savestrcpy(Entries[i].se_obj_id.fullname, node,
  61.                  MAXFULLNAME - 1, NT_FONT);
  62.  
  63.       sprintf(Entries[i].se_Entry, EntryAttr[FONTS].ea_dataformat,
  64.               Entries[i].se_obj_id.fullname,
  65.               ((font->tf_Flags & FPF_DISKFONT) ? "Disk" : "ROM"),
  66.               font->tf_YSize,
  67.               font->tf_XSize,
  68.               font->tf_LoChar,
  69.               font->tf_HiChar);
  70.  
  71.       i++;
  72.    }
  73.  
  74.    countentries = i;
  75.  
  76.    Permit();
  77.  
  78.    CreateEntryList(SORT);
  79.  
  80.    return;
  81. }
  82.  
  83.    /*
  84.     * MakeWindowList() erzeugt eine Liste der offenen Windows im
  85.     * System. Dazu werden alle geöffneten Screens durchsucht
  86.     */
  87. void
  88. MakeWindowList(void)
  89. {
  90.    ULONG lock;
  91.    struct Window *win;
  92.    struct Screen *scr;
  93.    char scrtitle[11];
  94.    int   i = 0;
  95.  
  96.    DPOS;
  97.  
  98.    countentries = CountIntuiObjects((int)GD_WindowsGad);
  99.  
  100.    if (NoEntries())
  101.       return;
  102.  
  103.    Entries = AllocScrollEntries(countentries);
  104.  
  105.    lock = LockIBase(NULL);
  106.  
  107.    for (scr = IntuitionBase->FirstScreen; scr && (i < countentries);
  108.         scr = scr->NextScreen)
  109.       for (win = scr->FirstWindow; win && (i < countentries);
  110.            win = win->NextWindow)
  111.       {
  112.          Entries[i].se_obj_id.address = win;
  113.  
  114.          if ((char *)win->Title)
  115.             strncpy(Entries[i].se_obj_id.fullname,
  116.                     (char *)win->Title, MAXFULLNAME - 1);
  117.          else
  118.             strcpy(Entries[i].se_obj_id.fullname, field[NO_TITLE]);
  119.  
  120.          if ((char *)scr->DefaultTitle)
  121.             strncpy(scrtitle, (char *)scr->DefaultTitle, 10);
  122.          else
  123.             strcpy(scrtitle, field[NO_TITLE]);
  124.  
  125.          sprintf(Entries[i].se_Entry, EntryAttr[WINDOWS].ea_dataformat,
  126.                  Entries[i].se_obj_id.fullname,
  127.                  win->Height,
  128.                  win->Width,
  129.                  win->LeftEdge,
  130.                  win->TopEdge,
  131.                  scrtitle);
  132.  
  133.          i++;
  134.       }
  135.  
  136.    countentries = i;
  137.  
  138.    UnlockIBase(lock);
  139.  
  140.    CreateEntryList(SORT);
  141.  
  142.    return;
  143. }
  144.  
  145.    /*
  146.     * MakeScreenList() erzeugt eine Liste aller geöffneten Screens
  147.     */
  148. void
  149. MakeScreenList(void)
  150. {
  151.    ULONG lock;
  152.    struct Screen *scr;
  153.    int   i = 0;
  154.    char pub[5];
  155.  
  156.    DPOS;
  157.  
  158.    countentries = CountIntuiObjects((int)GD_ScreensGad);
  159.  
  160.    if (NoEntries())
  161.       return;
  162.  
  163.    Entries = AllocScrollEntries(countentries);
  164.  
  165.    lock = LockIBase(NULL);
  166.  
  167.    for (scr = IntuitionBase->FirstScreen; scr && (i < countentries);
  168.         scr = scr->NextScreen)
  169.    {
  170.       Entries[i].se_obj_id.address = scr;
  171.  
  172.       if (scr->Title)
  173.          strncpy(Entries[i].se_obj_id.fullname, (char *)scr->Title, MAXFULLNAME - 1);
  174.       else
  175.          strcpy(Entries[i].se_obj_id.fullname, field[NO_TITLE]);
  176.  
  177.       strcpy(pub, "   ");
  178.  
  179.       if ((scr->Flags & WBENCHSCREEN) == WBENCHSCREEN)
  180.          pub[0] = 'W';
  181.  
  182.       if ((scr->Flags & PUBLICSCREEN) == PUBLICSCREEN)
  183.          pub[1] = 'P';
  184.  
  185.       if ((scr->Flags & CUSTOMSCREEN) == CUSTOMSCREEN)
  186.          pub[2] = 'C';
  187.  
  188.       sprintf(Entries[i].se_Entry, EntryAttr[SCREENS].ea_dataformat,
  189.               Entries[i].se_obj_id.fullname,
  190.               scr->Height, scr->Width, scr->LeftEdge, scr->TopEdge,
  191.               pub);
  192.  
  193.       i++;
  194.    }
  195.  
  196.    countentries = i;
  197.  
  198.    UnlockIBase(lock);
  199.  
  200.    CreateEntryList(SORT);
  201.  
  202.    return;
  203. }
  204.  
  205.    /*
  206.     * SysPubScreenList() zeigt alle im System angemeldeten
  207.     * Public Screens an
  208.     */
  209. void
  210. SysPubScreenList(void)
  211. {
  212.    struct Node *node;
  213.    struct Screen *scr;
  214.    struct PubScreenNode *PSNodes;
  215.    struct List *PSList = NULL;
  216.    char name[20],taskname[16];
  217.    int   i = 0;
  218.  
  219.    DPOS;
  220.  
  221.    PrintHeader(SYSPUBSCR, NULL);
  222.  
  223.    EmptyListView();
  224.  
  225.    PSList = LockPubScreenList();
  226.    countentries = CountNodes(PSList);
  227.    UnlockPubScreenList();
  228.  
  229.    if (NoEntries())
  230.       return;
  231.  
  232.    PSNodes = (struct PubScreenNode *) MyAllocVec(countentries*sizeof(struct PubScreenNode),
  233.                                                MEMF_ANY | MEMF_CLEAR, NO_KILL);
  234.  
  235.    if(!PSNodes)
  236.       return;
  237.  
  238.    PSList = LockPubScreenList();
  239.  
  240.    for (node = PSList->lh_Head;
  241.         node->ln_Succ && (i < countentries); node = node->ln_Succ)
  242.       CopyMem(node,&PSNodes[i++],sizeof(struct PubScreenNode));
  243.  
  244.    UnlockPubScreenList();
  245.  
  246.    Entries = AllocScrollEntries(countentries);
  247.  
  248.    for (i = 0; i < countentries; i++)
  249.    {
  250.       scr = PSNodes[i].psn_Screen;
  251.  
  252.       savestrcpy(name,&(PSNodes[i].psn_Node),19, NT_UNKNOWN);
  253.  
  254.       Forbid();
  255.  
  256.       if(PSNodes[i].psn_SigTask)
  257.          savestrcpy(taskname,&PSNodes[i].psn_SigTask->tc_Node, 15, NT_TASK);
  258.       else
  259.          strcpy(taskname,field[NO_TASK]);
  260.  
  261.       Permit();
  262.  
  263.       sprintf(Entries[i].se_Entry, EntryAttr[24].ea_dataformat,
  264.               PSNodes[i].psn_Screen,
  265.               name,
  266.               PSNodes[i].psn_VisitorCount,
  267.               taskname);
  268.    }
  269.  
  270.    MyFreeVec(PSNodes);
  271.  
  272.    CreateEntryList(SORT);
  273.  
  274.    PrintStatistics();
  275.  
  276.    return;
  277. }
  278.  
  279. void
  280. RSysGetDisplayModes(void)
  281. {
  282.    struct DisplayInfo dinfo;
  283.    struct NameInfo    ninfo;
  284.    struct DisplayNode {
  285.       struct Node          dn_Node;
  286.       struct DisplayInfo   dn_dinfo;
  287.       struct NameInfo      dn_ninfo;
  288.       struct DimensionInfo dn_diminfo;
  289.    }
  290.    *dnode,*copydnode;
  291.    struct Node *dispnode;
  292.    struct List *DispList;
  293.    ULONG modeID = INVALID_ID;
  294.    struct Remember *DispKey = NULL;
  295.    int i;
  296.  
  297.    DPOS;
  298.  
  299.    PrintHeader(DISPLAYMODES, NULL);
  300.  
  301.    EmptyListView();
  302.  
  303.    DispList = AllocRemember(&DispKey,sizeof(struct List),MEMF_CLEAR);
  304.    if(DispList)
  305.    {
  306.       NewList(DispList);
  307.  
  308.       while ((modeID = NextDisplayInfo (modeID)) != INVALID_ID)
  309.       {
  310.          if (GetDisplayInfoData (NULL, (UBYTE *) &dinfo, sizeof(dinfo),
  311.                                  DTAG_DISP,modeID))
  312.          {
  313.             if ((dinfo.NotAvailable == 0) && (modeID & MONITOR_ID_MASK))
  314.             {
  315.                   /*
  316.                    * Hier gelangt das Programm nur dann hin, wenn
  317.                    * der Modus verfügbar ist und nicht der
  318.                    * Default-Monitor benötigt wird, sondern ein
  319.                    * PAL-, NTSC- oder andere Monitore
  320.                    */
  321.                if (GetDisplayInfoData (NULL,(UBYTE *) &ninfo, sizeof(ninfo),
  322.                                        DTAG_NAME,modeID))
  323.                {
  324.                   if(dnode = AllocRemember(&DispKey,sizeof(struct DisplayNode),
  325.                                            MEMF_CLEAR|MEMF_PUBLIC))
  326.                   {
  327.                      if(dnode->dn_Node.ln_Name = AllocRemember(&DispKey,
  328.                                                                strlen((char *)ninfo.Name) +1,
  329.                                                                MEMF_CLEAR|MEMF_PUBLIC))
  330.                      {
  331.                         strcpy (dnode->dn_Node.ln_Name, (char *)ninfo.Name);
  332.  
  333.                         GetDisplayInfoData (NULL,(UBYTE *) &(dnode->dn_diminfo),
  334.                                             sizeof(struct DimensionInfo),
  335.                                             DTAG_DIMS, modeID);
  336.  
  337.                         GetDisplayInfoData (NULL, (UBYTE *) &(dnode->dn_dinfo),
  338.                                             sizeof(struct DisplayInfo),
  339.                                             DTAG_DISP, modeID);
  340.  
  341.                         AddTail(DispList, (struct Node *) dnode);
  342.                      }
  343.                   }
  344.                }
  345.             }
  346.          }
  347.       }
  348.  
  349.       countentries = CountNodes(DispList);
  350.  
  351.       if(!NoEntries())
  352.       {
  353.          Entries = AllocScrollEntries(countentries);
  354.  
  355.          for(dispnode = (struct Node *)DispList->lh_Head, i = 0;
  356.              dispnode->ln_Succ && (i < countentries);
  357.              dispnode = dispnode->ln_Succ)
  358.          {
  359.             copydnode = (struct DisplayNode *)dispnode;
  360.             sprintf(Entries[i].se_Entry, EntryAttr[30].ea_dataformat,
  361.                     copydnode->dn_Node.ln_Name,
  362.                     copydnode->dn_diminfo.MaxDepth,
  363.                     copydnode->dn_diminfo.MinRasterWidth,
  364.                     copydnode->dn_diminfo.MinRasterHeight,
  365.                     copydnode->dn_diminfo.MaxRasterWidth,
  366.                     copydnode->dn_diminfo.MaxRasterHeight);
  367.  
  368.             i++;
  369.          }
  370.  
  371.          CreateEntryList(SORT);
  372.       }
  373.  
  374.       FreeRemember(&DispKey,TRUE);
  375.  
  376.       PrintStatistics();
  377.    }
  378.    else
  379.       ErrorHandle(MEMORY_ERR, ALLOC_FAIL, KILL);
  380.  
  381.    return;
  382. }
  383.  
  384. void
  385. SysTOFWaitList(void)
  386. {
  387.    struct Node *node;
  388.    struct Node *TWQNodes;
  389.    char name[20];
  390.    int   i = 0;
  391.  
  392.    DPOS;
  393.  
  394.    PrintHeader(TOFWAIT, NULL);
  395.  
  396.    EmptyListView();
  397.  
  398.    countentries = CountNodes(&GfxBase->TOF_WaitQ);
  399.  
  400.    if (NoEntries())
  401.       return;
  402.  
  403.    TWQNodes = (struct Node *)MyAllocVec(countentries*sizeof(struct Node),
  404.                                         MEMF_ANY | MEMF_CLEAR, NO_KILL);
  405.  
  406.    if(!TWQNodes)
  407.       return;
  408.  
  409.    Disable();
  410.  
  411.    for (node = GfxBase->TOF_WaitQ.lh_Head;
  412.         node->ln_Succ && (i < countentries); node = node->ln_Succ)
  413.       CopyMem(node,&TWQNodes[i++],sizeof(struct Node));
  414.  
  415.    Enable();
  416.  
  417.    Entries = AllocScrollEntries(countentries);
  418.  
  419.    for (i = 0; i < countentries; i++)
  420.    {
  421.       savestrcpy(name,&TWQNodes[i],19, NT_TASK);
  422.  
  423.       sprintf(Entries[i].se_Entry, EntryAttr[24].ea_dataformat,
  424.               name,
  425.               TWQNodes[i].ln_Pri );
  426.    }
  427.  
  428.    MyFreeVec(TWQNodes);
  429.  
  430.    CreateEntryList(SORT);
  431.  
  432.    PrintStatistics();
  433.  
  434.    return;
  435. }
  436.  
  437.    /*
  438.     * SysBlitterWaitList() erzeugt eine Liste aller Tasks,
  439.     * die auf den Blitter warten. Diese Liste ist in der
  440.     * GfxBase (graphics.library) zu finden
  441.     */
  442. void
  443. SysBlitterWaitList(void)
  444. {
  445.    struct Node *node;
  446.    struct Node *BWQNodes;
  447.    char name[20];
  448.    int   i = 0;
  449.  
  450.    DPOS;
  451.  
  452.    PrintHeader(BLITTERWAIT, NULL);
  453.  
  454.    EmptyListView();
  455.  
  456.    countentries = CountNodes(&GfxBase->BlitWaitQ);
  457.  
  458.    if (NoEntries())
  459.       return;
  460.  
  461.    BWQNodes = (struct Node *) MyAllocVec(countentries*sizeof(struct Node),
  462.                                          MEMF_ANY | MEMF_CLEAR, NO_KILL);
  463.  
  464.    if(!BWQNodes)
  465.       return;
  466.  
  467.    Disable();
  468.  
  469.    for (node = GfxBase->BlitWaitQ.lh_Head;
  470.         node->ln_Succ && (i < countentries); node = node->ln_Succ)
  471.       CopyMem(node,&BWQNodes[i++],sizeof(struct Node));
  472.  
  473.    Enable();
  474.  
  475.    Entries = AllocScrollEntries(countentries);
  476.  
  477.    for (i = 0; i < countentries; i++)
  478.    {
  479.       savestrcpy(name,&BWQNodes[i],19, NT_TASK);
  480.  
  481.       sprintf(Entries[i].se_Entry, EntryAttr[24].ea_dataformat,
  482.               name,
  483.               BWQNodes[i].ln_Pri );
  484.    }
  485.  
  486.    MyFreeVec(BWQNodes);
  487.  
  488.    CreateEntryList(SORT);
  489.  
  490.    PrintStatistics();
  491.  
  492.    return;
  493. }
  494.  
  495. #define SETFLAG(gad,flag) ((((gad)->GadgetType)&(flag))==(flag))
  496.  
  497. static void
  498. gadgetinfo(struct Gadget *gad, int i)
  499. {
  500.    char title[15], typ[7];
  501.  
  502.    if(gad->GadgetText && gad->GadgetText->IText)
  503.       strncpy(title, (char *)(gad->GadgetText->IText), 15);
  504.    else if(gad->GadgetRender || gad->SelectRender)
  505.       strcpy(title, "<has image>");
  506.    else
  507.       strcpy(title, field[NO_FIELD]);
  508.  
  509.    if(SETFLAG(gad,GTYP_SYSGADGET))
  510.       strcpy(typ,"SYS");
  511.    else if(SETFLAG(gad,GTYP_SCRGADGET))
  512.       strcpy(typ,"SCR");
  513.    else if(SETFLAG(gad,GTYP_GZZGADGET))
  514.       strcpy(typ,"GZZ");
  515.    else if(SETFLAG(gad,GTYP_REQGADGET))
  516.       strcpy(typ,"REQ");
  517.    else
  518.       strcpy(typ,"CUS");
  519.  
  520.    if(SETFLAG(gad, GTYP_WDRAGGING))
  521.       strcat(typ,"WDR");
  522.    else if(SETFLAG(gad, GTYP_SDRAGGING))
  523.       strcat(typ,"SDR");
  524.    else if(SETFLAG(gad, GTYP_WUPFRONT))
  525.       strcat(typ,"WUP");
  526.    else if(SETFLAG(gad, GTYP_SUPFRONT))
  527.       strcat(typ,"SUP");
  528.    else if(SETFLAG(gad, GTYP_WDOWNBACK))
  529.       strcat(typ,"WDO");
  530.    else if(SETFLAG(gad, GTYP_SDOWNBACK))
  531.       strcat(typ,"SDO");
  532.    else if(SETFLAG(gad, GTYP_CLOSE))
  533.       strcat(typ,"CLO");
  534.    else if(SETFLAG(gad, GTYP_BOOLGADGET))
  535.       strcat(typ,"BOO");
  536.    else if(SETFLAG(gad, GTYP_GADGET0002))
  537.       strcat(typ,"G02");
  538.    else if(SETFLAG(gad, GTYP_PROPGADGET))
  539.       strcat(typ,"PRO");
  540.    else if(SETFLAG(gad, GTYP_STRGADGET))
  541.       strcat(typ,"STR");
  542.    else if(SETFLAG(gad, GTYP_CUSTOMGADGET))
  543.       strcat(typ,"CUS");
  544.    else if(SETFLAG(gad, GTYP_SIZING))
  545.       strcat(typ,"SIZ");
  546.    else
  547.       strcat(typ,"UNK");
  548.  
  549.    sprintf(Entries[i].se_Entry, EntryAttr[ALLGADGETS].ea_dataformat,
  550.            title, typ, gad->LeftEdge, gad->TopEdge, gad->Width,
  551.            gad->Height);
  552.  
  553.    return;
  554. }
  555.    /*
  556.     * MakeWindowList() erzeugt eine Liste der offenen Windows im
  557.     * System. Dazu werden alle geöffneten Screens durchsucht
  558.     */
  559. void
  560. RSysGadgetList(void)
  561. {
  562.    ULONG lock;
  563.    struct Window *win;
  564.    struct Screen *scr;
  565.    struct Gadget *gad;
  566.    int   i = 0;
  567.  
  568.    DPOS;
  569.  
  570.    PrintHeader(ALLGADGETS, NULL);
  571.  
  572.    EmptyListView();
  573.  
  574.    countentries = 0;
  575.  
  576.    PrintInfo("Please wait! Lock Intuition...", NO_SPEAK, 0);
  577.  
  578.    lock = LockIBase(NULL);
  579.  
  580.    for (scr = IntuitionBase->FirstScreen; scr; scr = scr->NextScreen)
  581.    {
  582.       countentries++;
  583.  
  584.       for(gad = scr->FirstGadget; gad; gad = gad->NextGadget)
  585.           countentries++;
  586.  
  587.       for (win = scr->FirstWindow; win; win = win->NextWindow)
  588.       {
  589.          countentries++;
  590.  
  591.          if(win->FirstRequest)
  592.             for(gad = win->FirstRequest->ReqGadget; gad; gad = gad->NextGadget)
  593.                countentries++;
  594.  
  595.          for(gad = win->FirstGadget; gad; gad = gad->NextGadget)
  596.             countentries++;
  597.       }
  598.    }
  599.  
  600.    UnlockIBase(lock);
  601.  
  602.    if (NoEntries())
  603.       return;
  604.  
  605.    Entries = AllocScrollEntries(countentries);
  606.  
  607.    PrintInfo("Please wait! Lock Intuition again...", NO_SPEAK, 0);
  608.  
  609.    lock = LockIBase(NULL);
  610.  
  611.    for (scr = IntuitionBase->FirstScreen; scr && (i < countentries); scr = scr->NextScreen)
  612.    {
  613.       if (scr->Title)
  614.          sprintf(Entries[i++].se_Entry,"* SCR: %-20.20s", (char *)scr->Title);
  615.       else
  616.          sprintf(Entries[i++].se_Entry,"* SCR: %s", field[NO_TITLE]);
  617.  
  618.       for(gad = scr->FirstGadget; gad && (i < countentries); gad = gad->NextGadget)
  619.          gadgetinfo(gad, i++);
  620.  
  621.       for (win = scr->FirstWindow; win && (i < countentries); win = win->NextWindow)
  622.       {
  623.          if ((char *)win->Title)
  624.             sprintf(Entries[i++].se_Entry,"** WIN: %-20.20s", (char *)win->Title);
  625.          else
  626.             sprintf(Entries[i++].se_Entry,"** WIN: %-20.20s", field[NO_TITLE]);
  627.  
  628.          if(win->FirstRequest)
  629.             for(gad = win->FirstRequest->ReqGadget; gad && (i < countentries);
  630.                 gad = gad->NextGadget)
  631.                gadgetinfo(gad, i++);
  632.  
  633.          for(gad = win->FirstGadget; gad && (i < countentries); gad = gad->NextGadget)
  634.             gadgetinfo(gad, i++);
  635.       }
  636.    }
  637.  
  638.    countentries = i;
  639.  
  640.    UnlockIBase(lock);
  641.  
  642.    CreateEntryList(NO_SORT);
  643.  
  644.    PrintStatistics();
  645.  
  646.    return;
  647. }
  648.