home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 12 / MA_Cover_12.iso / internet / freedomc_112 / sourcecode / freeexplorer / freecheckgui.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-10  |  11.8 KB  |  460 lines

  1. #ifndef MAKE_ID
  2. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  3. #endif
  4.  
  5. /* Libraries */
  6. #include <libraries/mui.h>
  7. #include <libraries/gadtools.h> /* for Barlabel in MenuItem */
  8. #include <exec/memory.h>
  9.  
  10. /* Prototypes */
  11. #include <proto/muimaster.h>
  12. #include <proto/exec.h>
  13. #ifdef __SASC
  14. #include <clib/alib_protos.h>
  15. #else
  16. #include <proto/alib.h>
  17. #endif /* __SASC */
  18.  
  19. #include "FreeCheckGUI.h"
  20. #include "FreeCheckExtern.h"
  21. #include "Hook_utility.h"
  22. static char *GetMBString(APTR ref)
  23. {
  24.     char *aux;
  25.  
  26.     aux = Get_String(ref);
  27.     if (aux[1] == '\0') return(&aux[2]);
  28.     else                return(aux);
  29. }
  30.  
  31. struct ObjApp * CreateApp(void)
  32. {
  33.     struct ObjApp * ObjectApp;
  34.  
  35.     APTR    MNlabel1Project, MNlabel1About, MNlabel1AboutMUI, MNlabel1BarLabel0;
  36.     APTR    MNlabel1Iconified, MNlabel1Exit, MNlabel1Settings, MNlabel1LoadConfiguration;
  37.     APTR    GrupoPrincipal, GrupoSubPrincipal, GrupoConnect, GrupoStatisticas;
  38.     APTR    GrupoStatusCall, GrupoBotoes, GrupoDeMensagens, GrupoAbout, GrupoImagem;
  39.     APTR    FreedomImage, GrupoBotoesAbout, AboutBotaoOk;
  40.     static struct Hook CarregaUpdateHook;
  41.     static struct Hook CarregaConfigHook;
  42.     static struct Hook AcertaAboutHook;
  43.     static struct Hook AplicacaoHideHook;
  44.     static struct Hook AboutMUIHook;
  45.     static struct Hook CarregaTempoHook;
  46.  
  47.     if (!(ObjectApp = AllocVec(sizeof(struct ObjApp),MEMF_PUBLIC|MEMF_CLEAR)))
  48.         return(NULL);
  49.  
  50.     ObjectApp->STR_LabelPrincipal = GetMBString(MSG_LabelPrincipal);
  51.     ObjectApp->STR_LabelConnect = NULL;
  52.     ObjectApp->STR_LabelOnline = NULL;
  53.     ObjectApp->STR_LabelCost = NULL;
  54.     ObjectApp->STR_LabelStatusCall = GetMBString(MSG_LabelStatusCall);
  55.     ObjectApp->STR_Msg01 = GetMBString(MSG_Msg01);
  56.     ObjectApp->STR_Msg02 = GetMBString(MSG_Msg02);
  57.     ObjectApp->STR_Msg03 = GetMBString(MSG_Msg03);
  58.     ObjectApp->STR_Msg04 = GetMBString(MSG_Msg04);
  59.     ObjectApp->STR_Msg05 = GetMBString(MSG_Msg05);
  60.     ObjectApp->STR_Msg06 = GetMBString(MSG_Msg06);
  61.     ObjectApp->STR_Msg07 = GetMBString(MSG_Msg07);
  62.     ObjectApp->STR_TextAbout = NULL;
  63.  
  64.     InstallHook(&CarregaUpdateHook,CarregaUpdate,ObjectApp);
  65.     InstallHook(&CarregaConfigHook,CarregaConfig,ObjectApp);
  66.     InstallHook(&AcertaAboutHook,AcertaAbout,ObjectApp);
  67.     InstallHook(&AplicacaoHideHook,AplicacaoHide,ObjectApp);
  68.     InstallHook(&AboutMUIHook,AboutMUI,ObjectApp);
  69.     InstallHook(&CarregaTempoHook,CarregaTempo,ObjectApp);
  70.  
  71.     ObjectApp->LabelPrincipal = TextObject,
  72.         MUIA_Background, MUII_SHADOWFILL,
  73.         MUIA_Frame, MUIV_Frame_Text,
  74.         MUIA_Text_Contents, ObjectApp->STR_LabelPrincipal,
  75.         MUIA_Text_PreParse, "\0338\033c",
  76.         MUIA_Text_SetMin, TRUE,
  77.     End;
  78.  
  79.     ObjectApp->LabelConnect = TextObject,
  80.         MUIA_Background, MUII_TextBack,
  81.         MUIA_Frame, MUIV_Frame_Text,
  82.         MUIA_FrameTitle, GetMBString(MSG_LabelConnectTitle),
  83.         MUIA_Text_Contents, ObjectApp->STR_LabelConnect,
  84.         MUIA_Text_PreParse, "\033c",
  85.         MUIA_Text_SetMin, TRUE,
  86.     End;
  87.  
  88.     GrupoConnect = GroupObject,
  89.         Child, ObjectApp->LabelConnect,
  90.     End;
  91.  
  92.     ObjectApp->LabelOnline = TextObject,
  93.         MUIA_Background, MUII_TextBack,
  94.         MUIA_Frame, MUIV_Frame_Text,
  95.         MUIA_FrameTitle, GetMBString(MSG_LabelOnlineTitle),
  96.         MUIA_Text_Contents, ObjectApp->STR_LabelOnline,
  97.         MUIA_Text_PreParse, "\033c",
  98.         MUIA_Text_SetMin, TRUE,
  99.     End;
  100.  
  101.     ObjectApp->LabelCost = TextObject,
  102.         MUIA_Background, MUII_TextBack,
  103.         MUIA_Frame, MUIV_Frame_Text,
  104.         MUIA_FrameTitle, GetMBString(MSG_LabelCostTitle),
  105.         MUIA_Text_Contents, ObjectApp->STR_LabelCost,
  106.         MUIA_Text_PreParse, "\033c",
  107.         MUIA_Text_SetMin, TRUE,
  108.     End;
  109.  
  110.     GrupoStatisticas = GroupObject,
  111.         MUIA_Group_Columns, 2,
  112.         Child, ObjectApp->LabelOnline,
  113.         Child, ObjectApp->LabelCost,
  114.     End;
  115.  
  116.     ObjectApp->LabelStatusCall = TextObject,
  117.         MUIA_Background, MUII_TextBack,
  118.         MUIA_Frame, MUIV_Frame_Text,
  119.         MUIA_FrameTitle, GetMBString(MSG_LabelStatusCallTitle),
  120.         MUIA_Text_Contents, ObjectApp->STR_LabelStatusCall,
  121.         MUIA_Text_PreParse, "\033c",
  122.         MUIA_Text_SetMin, TRUE,
  123.     End;
  124.  
  125.     GrupoStatusCall = GroupObject,
  126.         Child, ObjectApp->LabelStatusCall,
  127.     End;
  128.  
  129.     GrupoSubPrincipal = GroupObject,
  130.         MUIA_Background, MUII_RequesterBack,
  131.         MUIA_Frame, MUIV_Frame_Group,
  132.         Child, ObjectApp->LabelPrincipal,
  133.         Child, GrupoConnect,
  134.         Child, GrupoStatisticas,
  135.         Child, GrupoStatusCall,
  136.     End;
  137.  
  138.     ObjectApp->BotaoExit = SimpleButton(GetMBString(MSG_BotaoExit));
  139.  
  140.     ObjectApp->BotaoIconified = SimpleButton(GetMBString(MSG_BotaoIconified));
  141.  
  142.     ObjectApp->BotaoUpdate = SimpleButton(GetMBString(MSG_BotaoUpdate));
  143.  
  144.     GrupoBotoes = GroupObject,
  145.         MUIA_Group_Horiz, TRUE,
  146.         Child, ObjectApp->BotaoExit,
  147.         Child, ObjectApp->BotaoIconified,
  148.         Child, ObjectApp->BotaoUpdate,
  149.     End;
  150.  
  151.     GrupoPrincipal = GroupObject,
  152.         Child, GrupoSubPrincipal,
  153.         Child, GrupoBotoes,
  154.     End;
  155.  
  156.     MNlabel1About = MenuitemObject,
  157.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1About),
  158.         MUIA_Menuitem_Shortcut, GetMBString(MSG_MNlabel1AboutChar),
  159.     End;
  160.  
  161.     MNlabel1AboutMUI = MenuitemObject,
  162.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1AboutMUI),
  163.         MUIA_Menuitem_Shortcut, GetMBString(MSG_MNlabel1AboutMUIChar),
  164.     End;
  165.  
  166.     MNlabel1BarLabel0 = MUI_MakeObject(MUIO_Menuitem, NM_BARLABEL, 0, 0, 0);
  167.  
  168.     MNlabel1Iconified = MenuitemObject,
  169.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1Iconified),
  170.         MUIA_Menuitem_Shortcut, GetMBString(MSG_MNlabel1IconifiedChar),
  171.     End;
  172.  
  173.     MNlabel1Exit = MenuitemObject,
  174.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1Exit),
  175.         MUIA_Menuitem_Shortcut, GetMBString(MSG_MNlabel1ExitChar),
  176.     End;
  177.  
  178.     MNlabel1Project = MenuitemObject,
  179.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1Project),
  180.         MUIA_Family_Child, MNlabel1About,
  181.         MUIA_Family_Child, MNlabel1AboutMUI,
  182.         MUIA_Family_Child, MNlabel1BarLabel0,
  183.         MUIA_Family_Child, MNlabel1Iconified,
  184.         MUIA_Family_Child, MNlabel1Exit,
  185.     End;
  186.  
  187.     MNlabel1LoadConfiguration = MenuitemObject,
  188.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1LoadConfiguration),
  189.         MUIA_Menuitem_Shortcut, GetMBString(MSG_MNlabel1LoadConfigurationChar),
  190.     End;
  191.  
  192.     MNlabel1Settings = MenuitemObject,
  193.         MUIA_Menuitem_Title, GetMBString(MSG_MNlabel1Settings),
  194.         MUIA_Family_Child, MNlabel1LoadConfiguration,
  195.     End;
  196.  
  197.     ObjectApp->MN_label_1 = MenustripObject,
  198.         MUIA_Family_Child, MNlabel1Project,
  199.         MUIA_Family_Child, MNlabel1Settings,
  200.     End;
  201.  
  202.     ObjectApp->JanelaPrincipal = WindowObject,
  203.         MUIA_Window_Title, GetMBString(MSG_JanelaPrincipal),
  204.         MUIA_Window_Menustrip, ObjectApp->MN_label_1,
  205.         MUIA_Window_ID, MAKE_ID('0', 'W', 'I', 'N'),
  206.         WindowContents, GrupoPrincipal,
  207.     End;
  208.  
  209.     ObjectApp->Msg01 = TextObject,
  210.         MUIA_Background, MUII_TextBack,
  211.         MUIA_Frame, MUIV_Frame_Text,
  212.         MUIA_Text_Contents, ObjectApp->STR_Msg01,
  213.         MUIA_Text_SetMin, TRUE,
  214.     End;
  215.  
  216.     ObjectApp->Msg02 = TextObject,
  217.         MUIA_Background, MUII_TextBack,
  218.         MUIA_Frame, MUIV_Frame_Text,
  219.         MUIA_Text_Contents, ObjectApp->STR_Msg02,
  220.         MUIA_Text_SetMin, TRUE,
  221.     End;
  222.  
  223.     ObjectApp->Msg03 = TextObject,
  224.         MUIA_Background, MUII_TextBack,
  225.         MUIA_Frame, MUIV_Frame_Text,
  226.         MUIA_Text_Contents, ObjectApp->STR_Msg03,
  227.         MUIA_Text_SetMin, TRUE,
  228.     End;
  229.  
  230.     ObjectApp->Msg04 = TextObject,
  231.         MUIA_Background, MUII_TextBack,
  232.         MUIA_Frame, MUIV_Frame_Text,
  233.         MUIA_Text_Contents, ObjectApp->STR_Msg04,
  234.         MUIA_Text_SetMin, TRUE,
  235.     End;
  236.  
  237.     ObjectApp->Msg05 = TextObject,
  238.         MUIA_Background, MUII_TextBack,
  239.         MUIA_Frame, MUIV_Frame_Text,
  240.         MUIA_Text_Contents, ObjectApp->STR_Msg05,
  241.         MUIA_Text_SetMin, TRUE,
  242.     End;
  243.  
  244.     ObjectApp->Msg06 = TextObject,
  245.         MUIA_Background, MUII_TextBack,
  246.         MUIA_Frame, MUIV_Frame_Text,
  247.         MUIA_Text_Contents, ObjectApp->STR_Msg06,
  248.         MUIA_Text_SetMin, TRUE,
  249.     End;
  250.  
  251.     ObjectApp->Msg07 = TextObject,
  252.         MUIA_Background, MUII_TextBack,
  253.         MUIA_Frame, MUIV_Frame_Text,
  254.         MUIA_Text_Contents, ObjectApp->STR_Msg07,
  255.         MUIA_Text_SetMin, TRUE,
  256.     End;
  257.  
  258.     GrupoDeMensagens = GroupObject,
  259.         Child, ObjectApp->Msg01,
  260.         Child, ObjectApp->Msg02,
  261.         Child, ObjectApp->Msg03,
  262.         Child, ObjectApp->Msg04,
  263.         Child, ObjectApp->Msg05,
  264.         Child, ObjectApp->Msg06,
  265.         Child, ObjectApp->Msg07,
  266.     End;
  267.  
  268.     ObjectApp->JanelaMsg = WindowObject,
  269.         MUIA_Window_Title, GetMBString(MSG_JanelaMsg),
  270.         MUIA_Window_ID, MAKE_ID('1', 'W', 'I', 'N'),
  271.         WindowContents, GrupoDeMensagens,
  272.     End;
  273.  
  274.     FreedomImage = ImageObject,
  275.         MUIA_Image_Spec, "5:Freedom:Images/ExplorerLogo.iff",
  276.         MUIA_Frame, MUIV_Frame_ImageButton,
  277.         MUIA_Image_FreeVert, TRUE,
  278.         MUIA_Image_FreeHoriz, TRUE,
  279.         MUIA_FixHeight, 117,
  280.         MUIA_FixWidth, 186,
  281.     End;
  282.  
  283.     ObjectApp->TextAbout = TextObject,
  284.         MUIA_Background, MUII_SHADOWFILL,
  285.         MUIA_Frame, MUIV_Frame_Text,
  286.         MUIA_Text_Contents, ObjectApp->STR_TextAbout,
  287.         MUIA_Text_SetMin, TRUE,
  288.     End;
  289.  
  290.     GrupoImagem = GroupObject,
  291.         MUIA_Group_Horiz, TRUE,
  292.         Child, FreedomImage,
  293.         Child, ObjectApp->TextAbout,
  294.     End;
  295.  
  296.     AboutBotaoOk = SimpleButton(GetMBString(MSG_AboutBotaoOk));
  297.  
  298.     GrupoBotoesAbout = GroupObject,
  299.         MUIA_Group_Horiz, TRUE,
  300.         Child, AboutBotaoOk,
  301.     End;
  302.  
  303.     GrupoAbout = GroupObject,
  304.         Child, GrupoImagem,
  305.         Child, GrupoBotoesAbout,
  306.     End;
  307.  
  308.     ObjectApp->JanelaAbout = WindowObject,
  309.         MUIA_Window_Title, GetMBString(MSG_JanelaAbout),
  310.         MUIA_Window_ID, MAKE_ID('2', 'W', 'I', 'N'),
  311.         WindowContents, GrupoAbout,
  312.     End;
  313.  
  314.     ObjectApp->App = ApplicationObject,
  315.         MUIA_Application_Author, "Cristian Robert Gallas",
  316.         MUIA_Application_Base, "Freedom Explore Call",
  317.         MUIA_Application_Title, "ExploreCall",
  318.         MUIA_Application_Version, "$VER: Module Explore Call 1.01 (07.02.1998)",
  319.         MUIA_Application_Copyright, GetMBString(MSG_AppCopyright),
  320.         MUIA_Application_Description, GetMBString(MSG_AppDescription),
  321.         MUIA_Application_HelpFile, "Freedom.guide",
  322.         SubWindow, ObjectApp->JanelaPrincipal,
  323.         SubWindow, ObjectApp->JanelaMsg,
  324.         SubWindow, ObjectApp->JanelaAbout,
  325.     End;
  326.  
  327.  
  328.     if (!ObjectApp->App)
  329.     {
  330.         FreeVec(ObjectApp);
  331.         return(NULL);
  332.     }
  333.  
  334.     DoMethod(ObjectApp->App,
  335.         MUIM_Notify, MUIA_Application_Iconified, FALSE,
  336.         ObjectApp->App,
  337.         2,
  338.         MUIM_CallHook, &CarregaUpdateHook
  339.         );
  340.  
  341.     DoMethod(ObjectApp->App,
  342.         MUIM_Notify, MUIA_Application_Iconified, TRUE,
  343.         ObjectApp->App,
  344.         2,
  345.         MUIM_CallHook, &CarregaTempoHook
  346.         );
  347.  
  348.     DoMethod(MNlabel1About,
  349.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  350.         ObjectApp->App,
  351.         2,
  352.         MUIM_CallHook, &AcertaAboutHook
  353.         );
  354.  
  355.     DoMethod(MNlabel1About,
  356.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  357.         ObjectApp->JanelaAbout,
  358.         3,
  359.         MUIM_Set, MUIA_Window_Open, TRUE
  360.         );
  361.  
  362.     DoMethod(MNlabel1AboutMUI,
  363.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  364.         ObjectApp->App,
  365.         2,
  366.         MUIM_CallHook, &AboutMUIHook
  367.         );
  368.  
  369.     DoMethod(MNlabel1Iconified,
  370.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  371.         ObjectApp->App,
  372.         2,
  373.         MUIM_CallHook, &AplicacaoHideHook
  374.         );
  375.  
  376.     DoMethod(MNlabel1Exit,
  377.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  378.         ObjectApp->App,
  379.         2,
  380.         MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
  381.         );
  382.  
  383.     DoMethod(MNlabel1LoadConfiguration,
  384.         MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
  385.         ObjectApp->App,
  386.         2,
  387.         MUIM_CallHook, &CarregaConfigHook
  388.         );
  389.  
  390.     DoMethod(ObjectApp->JanelaPrincipal,
  391.         MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  392.         ObjectApp->App,
  393.         2,
  394.         MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
  395.         );
  396.  
  397.     DoMethod(ObjectApp->BotaoExit,
  398.         MUIM_Notify, MUIA_Pressed, FALSE,
  399.         ObjectApp->App,
  400.         2,
  401.         MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
  402.         );
  403.  
  404.     DoMethod(ObjectApp->BotaoIconified,
  405.         MUIM_Notify, MUIA_Pressed, FALSE,
  406.         ObjectApp->App,
  407.         2,
  408.         MUIM_CallHook, &AplicacaoHideHook
  409.         );
  410.  
  411.     DoMethod(ObjectApp->BotaoUpdate,
  412.         MUIM_Notify, MUIA_Pressed, FALSE,
  413.         ObjectApp->App,
  414.         2,
  415.         MUIM_CallHook, &CarregaUpdateHook
  416.         );
  417.  
  418.     DoMethod(ObjectApp->JanelaPrincipal,
  419.         MUIM_Window_SetCycleChain, ObjectApp->BotaoExit,
  420.         ObjectApp->BotaoIconified,
  421.         ObjectApp->BotaoUpdate,
  422.         0
  423.         );
  424.  
  425.     DoMethod(ObjectApp->JanelaMsg,
  426.         MUIM_Window_SetCycleChain, 0
  427.         );
  428.  
  429.     DoMethod(ObjectApp->JanelaAbout,
  430.         MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  431.         ObjectApp->JanelaAbout,
  432.         3,
  433.         MUIM_Set, MUIA_Window_Open, FALSE
  434.         );
  435.  
  436.     DoMethod(AboutBotaoOk,
  437.         MUIM_Notify, MUIA_Pressed, FALSE,
  438.         ObjectApp->JanelaAbout,
  439.         3,
  440.         MUIM_Set, MUIA_Window_Open, FALSE
  441.         );
  442.  
  443.     DoMethod(ObjectApp->JanelaAbout,
  444.         MUIM_Window_SetCycleChain, 0
  445.         );
  446.  
  447.     set(ObjectApp->JanelaPrincipal,
  448.         MUIA_Window_Open, TRUE
  449.         );
  450.  
  451.  
  452.     return(ObjectApp);
  453. }
  454.  
  455. void DisposeApp(struct ObjApp * ObjectApp)
  456. {
  457.     MUI_DisposeObject(ObjectApp->App);
  458.     FreeVec(ObjectApp);
  459. }
  460.