home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / cdity / yak / src / hotkey_window.c < prev    next >
C/C++ Source or Header  |  1994-10-13  |  15KB  |  477 lines

  1.  
  2. /*
  3.  *  Source machine generated by GadToolsBox V2.0b
  4.  *  which is (c) Copyright 1991-1993 Jaba Development
  5.  *
  6.  *  GUI Designed by : Martin W Scott and Gaël Marziou
  7.  */
  8.  
  9.  
  10.  
  11.  
  12. #include <exec/types.h>
  13. #include <intuition/intuition.h>
  14. #include <intuition/classes.h>
  15. #include <intuition/classusr.h>
  16. #include <intuition/imageclass.h>
  17. #include <intuition/gadgetclass.h>
  18. #include <intuition/intuitionbase.h>
  19. #include <libraries/gadtools.h>
  20. #include <graphics/displayinfo.h>
  21. #include <graphics/gfxbase.h>
  22. #include <proto/exec.h>
  23. #include <proto/intuition.h>
  24. #include <proto/gadtools.h>
  25. #include <proto/graphics.h>
  26. #include <proto/locale.h>
  27. #include <proto/utility.h>
  28. #include <string.h>
  29.  
  30.  
  31. #include "code.h"
  32. #include "version.h"
  33. #include "hotkey_types.h"
  34. #include "yak.h"
  35. #include "gui.h"
  36.  
  37. #define CATCOMP_NUMBERS
  38. #include "locale/yak_locale_strings.h"
  39.  
  40.  
  41. IMPORT struct Catalog    *Catalog;
  42.  
  43. extern LONG (*HandleIDCMP)(void);
  44.  
  45. struct Window   *HotKeyWnd = NULL;
  46. struct Gadget   *HotKeyGList = NULL;
  47. struct Gadget   *HotKeyGadgets[HotKey_CNT];
  48. UWORD            HotKeyLeft = 0;
  49. UWORD            HotKeyWidth = 530;
  50. UWORD            HotKeyHeight = 159;
  51. UBYTE           *HotKeyWdt = NULL;
  52.  
  53. WORD             HotkeysTop=0;
  54. WORD             ActionsTop=0;
  55.  
  56. UBYTE *Options1Labels[4];
  57.  
  58. VOID
  59. InitOptions1Label()
  60. {
  61.     Options1Labels[0] = getString(NO_SCREEN_CHANGE_STRING);
  62.     Options1Labels[1] = getString(WORKBENCH_TO_FRONT_STRING);
  63.     Options1Labels[2] = getString(DEFAULT_PUBSCR_TO_FRONT_STRING);
  64.     Options1Labels[3] = NULL;
  65. }
  66.  
  67.  
  68. IMPORT struct MinList Actions1List;
  69.  
  70. struct Node Actions1Nodes[] = 
  71. {
  72.     &Actions1Nodes[1] ,(struct Node *)&Actions1List.mlh_Head,0,0,NULL,
  73.     &Actions1Nodes[2] ,&Actions1Nodes[0] ,0,0,NULL,
  74.     &Actions1Nodes[3] ,&Actions1Nodes[1] ,0,0,NULL,
  75.     &Actions1Nodes[4] ,&Actions1Nodes[2] ,0,0,NULL,
  76.     &Actions1Nodes[5] ,&Actions1Nodes[3] ,0,0,NULL,
  77.     &Actions1Nodes[6] ,&Actions1Nodes[5] ,0,0,NULL,
  78.     &Actions1Nodes[7] ,&Actions1Nodes[6] ,0,0,NULL,
  79.     &Actions1Nodes[8] ,&Actions1Nodes[7] ,0,0,NULL,
  80.     &Actions1Nodes[9] ,&Actions1Nodes[8] ,0,0,NULL,
  81.     &Actions1Nodes[10],&Actions1Nodes[9] ,0,0,NULL,
  82.     &Actions1Nodes[11],&Actions1Nodes[10],0,0,NULL,
  83.     &Actions1Nodes[12],&Actions1Nodes[11],0,0,NULL,
  84.     &Actions1Nodes[13],&Actions1Nodes[12],0,0,NULL,
  85.     &Actions1Nodes[14],&Actions1Nodes[13],0,0,NULL,
  86.     &Actions1Nodes[15],&Actions1Nodes[14],0,0,NULL,
  87.     &Actions1Nodes[16],&Actions1Nodes[15],0,0,NULL,
  88.     &Actions1Nodes[17],&Actions1Nodes[16],0,0,NULL,
  89.     (struct Node *)&Actions1List.mlh_Tail,&Actions1Nodes[16],0,0,NULL 
  90. };
  91.  
  92. VOID
  93. InitActions1Nodes()
  94. {
  95.     Actions1Nodes[0].ln_Name  = getString(DOS_Command_ACT);
  96.     Actions1Nodes[1].ln_Name  = getString(Close_Window_ACT);
  97.     Actions1Nodes[2].ln_Name  = getString(Zip_Window_ACT);
  98.     Actions1Nodes[3].ln_Name  = getString(Shrink_Window_ACT);
  99.     Actions1Nodes[4].ln_Name  = getString(Expand_Window_ACT);
  100.     Actions1Nodes[5].ln_Name  = getString(Cycle_Windows_ACT);
  101.     Actions1Nodes[6].ln_Name  = getString(Open_Palette_ACT);
  102.     Actions1Nodes[7].ln_Name  = getString(Screen_to_Front_ACT);
  103.     Actions1Nodes[8].ln_Name  = getString(Screen_to_Back_ACT);
  104.     Actions1Nodes[9].ln_Name  = getString(Activate_Workbench_ACT);
  105.     Actions1Nodes[10].ln_Name = getString(Centre_Screen_ACT);
  106.     Actions1Nodes[11].ln_Name = getString(Blank_Display_ACT);
  107.     Actions1Nodes[12].ln_Name = getString(Insert_Text_ACT);
  108.     Actions1Nodes[13].ln_Name = getString(Insert_Date_ACT);
  109.     Actions1Nodes[14].ln_Name = getString(Show_Yak_Interface_ACT);
  110.     Actions1Nodes[15].ln_Name = getString(Back_Cycle_Windows_ACT);
  111.     Actions1Nodes[16].ln_Name = getString(SetDefaultPublicScreen);
  112.     Actions1Nodes[17].ln_Name = getString(MenuShortcut);
  113. }
  114.  
  115. struct MinList Actions1List = {
  116.     (struct MinNode *)&Actions1Nodes[0],
  117.     (struct MinNode *)NULL,
  118.     (struct MinNode *)&Actions1Nodes[15] };
  119.  
  120.  
  121. UWORD HotKeyGTypes[] = {
  122.         LISTVIEW_KIND,
  123.         LISTVIEW_KIND,
  124.         STRING_KIND,
  125.         CYCLE_KIND,
  126.         BUTTON_KIND,
  127.         BUTTON_KIND,
  128.         BUTTON_KIND
  129. };
  130.  
  131.  
  132. struct NewGadget HotKeyNGad[] = {
  133.         234,15,290,80,NULL,NULL,GD_Hotkeys  ,PLACETEXT_ABOVE|NG_HIGHLABEL,NULL,NULL,
  134.           6,15,224,96,NULL,NULL,GD_Actions  ,PLACETEXT_ABOVE|NG_HIGHLABEL,NULL,NULL,
  135.         234,109,290,14,NULL,NULL,GD_Argument,PLACETEXT_LEFT              ,NULL,NULL,
  136.         234,124,290,13,NULL,NULL,GD_Options ,PLACETEXT_LEFT              ,NULL,NULL,
  137.         234,93,110,13,NULL,NULL,GD_Add      ,PLACETEXT_IN                ,NULL,NULL,
  138.         414,93,110,13,NULL,NULL,GD_Delete   ,PLACETEXT_IN                ,NULL,NULL,
  139.         215,143,100,13,NULL,NULL,GD_Return  ,PLACETEXT_IN                ,NULL,NULL
  140. };
  141.  
  142. VOID InitHotKeyNGad (VOID)
  143. {
  144.     HotKeyNGad[GD_Hotkeys].ng_GadgetText  = getString(HOTKEYS_STRING);
  145.     HotKeyNGad[GD_Actions].ng_GadgetText  = getString(ACTIONS_STRING);
  146.     HotKeyNGad[GD_Argument].ng_GadgetText = getString(ARGUMENT_STRING);
  147.     HotKeyNGad[GD_Options].ng_GadgetText  = getString(OPTIONS_STRING);
  148.     HotKeyNGad[GD_Add].ng_GadgetText      = getString(ADD_STRING);
  149.     HotKeyNGad[GD_Delete].ng_GadgetText   = getString(DELETE_STRING);
  150.     HotKeyNGad[GD_Return].ng_GadgetText   = getString(OK_STRING);
  151. }
  152.  
  153.  
  154.  
  155. ULONG HotKeyGTags[] = {
  156.         (GTLV_ShowSelected),NULL,(TAG_DONE),
  157.         (GTLV_Labels),(ULONG)&Actions1List,(GTLV_ShowSelected),NULL,(TAG_DONE),
  158.         (GTST_MaxChars),512,(TAG_DONE),
  159.         (GTCY_Labels),(ULONG)&Options1Labels[ 0 ],(TAG_DONE),
  160.         (TAG_DONE),
  161.         (TAG_DONE),
  162.         (TAG_DONE)
  163. };
  164.  
  165.  
  166.  
  167.  
  168. VOID
  169. HotKeyRender()
  170. {
  171.     ComputeFont(HotKeyWidth,HotKeyHeight);
  172.  
  173.     DrawBevelBox(HotKeyWnd->RPort,OffX,
  174.                  OffY +ComputeY(140),
  175.                  ComputeX(530),
  176.                  ComputeY(HotKeyHeight) -ComputeY(140),
  177.                  GT_VisualInfo,VisualInfo,TAG_DONE);
  178.     DrawBevelBox(HotKeyWnd->RPort,OffX,
  179.                  OffY,
  180.                  ComputeX(530),
  181.                  ComputeY(140),
  182.                  GT_VisualInfo,VisualInfo,TAG_DONE);
  183. }
  184.  
  185.  
  186.  
  187.  
  188. int
  189. OpenHotKeyWindow()
  190. {
  191.     struct NewGadget        ng;
  192.     struct Gadget   *g;
  193.     UWORD           lc,tc;
  194.     UWORD           wleft = HotKeyLeft,wtop = WindowTop,ww,wh;
  195.  
  196.     ComputeFont(HotKeyWidth,HotKeyHeight);
  197.  
  198.     ww = ComputeX(HotKeyWidth);
  199.     wh = ComputeY(HotKeyHeight);
  200.  
  201.     if ((wleft +ww +OffX +Scr->WBorRight) > Scr->Width) wleft = Scr->Width -ww;
  202.     if ((wtop +wh +OffY +Scr->WBorBottom) > Scr->Height) wtop = Scr->Height -wh;
  203.  
  204.     if (! (g = CreateContext(&HotKeyGList)))
  205.         return(1L);
  206.  
  207.     for(lc = 0,tc = 0; lc < HotKey_CNT; lc++) {
  208.  
  209.         CopyMem((char *)&HotKeyNGad[ lc ],(char *)&ng,(long)sizeof(struct NewGadget));
  210.  
  211.         ng.ng_VisualInfo = VisualInfo;
  212.         ng.ng_TextAttr   = Font;
  213.         ng.ng_LeftEdge   = OffX +ComputeX(ng.ng_LeftEdge);
  214.         ng.ng_TopEdge    = OffY +ComputeY(ng.ng_TopEdge);
  215.         ng.ng_Width      = ComputeX(ng.ng_Width);
  216.         ng.ng_Height     = ComputeY(ng.ng_Height);
  217.  
  218.         HotKeyGadgets[ lc ] = g = CreateGadgetA((ULONG)HotKeyGTypes[ lc ],g,&ng,(struct TagItem *)&HotKeyGTags[ tc ]);
  219.  
  220.         while(HotKeyGTags[ tc ]) tc += 2;
  221.         tc++;
  222.  
  223.         if (NOT g)
  224.             return(2L);
  225.     }
  226.  
  227.     if (! (HotKeyWnd = OpenWindowTags(NULL,
  228.                                       WA_Left,        wleft,
  229.                                       WA_Top,         wtop,
  230.                                       WA_Width,       ww +OffX +Scr->WBorRight,
  231.                                       WA_Height,      wh +OffY +Scr->WBorBottom,
  232.                                       WA_IDCMP,       LISTVIEWIDCMP|STRINGIDCMP|CYCLEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  233.                                       WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
  234.                                       WA_Gadgets,     HotKeyGList,
  235.                                       WA_Title,       HotKeyWdt,
  236.                                       WA_ScreenTitle  ,getString(COPYRIGHT_STRING),
  237.                                       WA_PubScreenName,PubScreenName,
  238.                                       TAG_DONE)))
  239.         return(4L);
  240.  
  241.     GT_RefreshWindow(HotKeyWnd,NULL);
  242.  
  243.     HotKeyRender();
  244.  
  245.     return(0L);
  246. }
  247.  
  248.  
  249.  
  250.