home *** CD-ROM | disk | FTP | other *** search
- /* seltempPanel.c
- *
- * defines the GUIFront characteristics of the seltemp panel
- */
-
- #include <stdio.h>
- #include <intuition/gadgetclass.h>
- #include <clib/intuition_protos.h>
- #include "amiCheck.h"
- #include "seltempPanel.h"
- #include "dataBase.h"
- #include "regGadget.h"
-
- /* prototypes */
- void SelHandleGadget(struct IntuiMessage *);
- void SelBuildList(void);
- UWORD SelTrueTemplate(UWORD index);
-
- struct Window *selWin = NULL;
- GUIFront *seltempGUI;
- ExtErrorData selExtData;
- static BOOL done;
- WORD usrSel;
- static UWORD ordinal;
- BOOL selAttach = FALSE;
- UWORD filterSel;
- struct List usrTemplates;
-
- enum {
- SELALL,
- SELCHECK,
- SELWITH,
- SELDEP,
- };
-
- /* quick configure of some gadgets */
- STRPTR templatelabels[] =
- {
- "All",
- "Checks",
- "Withdrawals",
- "Deposits",
- NULL,
- };
-
- struct TagItem templateCycleTags[] =
- {
- {GTCY_Labels, templatelabels},
- {TAG_DONE},
- };
-
- /* define gadgetspec */
- GadgetSpec SPgadgetspecs[] =
- {
- {LISTVIEW_KIND,20,10, {0,0,0,0,NULL,NULL,GID_SPTEMPLIST,
- PLACETEXT_ABOVE},ListView,GS_DefaultTags},
-
- {BUTTON_KIND,0,0,{0,0,0,0,"_OK", NULL, GID_SPOK,
- PLACETEXT_IN}, NULL, GS_DefaultTags},
-
- {BUTTON_KIND,0,0,{0,0,0,0,"_Cancel", NULL, GID_SPCANCEL,
- PLACETEXT_IN}, NULL, GS_DefaultTags},
-
- {CYCLE_KIND,0,0, {0,0,0,0,"_Filter",NULL,GID_SPFILTER,
- PLACETEXT_LEFT},templateCycleTags,GS_DefaultTags},
- };
-
- /* set up array of pointers to our specs */
- GadgetSpec *SP_SelTempSpecs[] =
- {
- &SPgadgetspecs[0],
- &SPgadgetspecs[1],
- &SPgadgetspecs[2],
- &SPgadgetspecs[3],
- NULL,
- };
-
-
- /* define the layout of this panel */
- ULONG SP_SelTempPanel[] =
- {
- GUIL_Flags, GUILF_PropShare | GUILF_EqualWidth,
-
- GUIL_VertGroup,0,
- GUIL_GadgetSpecID, GID_SPFILTER,
- GUIL_GadgetSpecID, GID_SPTEMPLIST,
- TAG_DONE,
-
- TAG_DONE,
- };
-
- /****************************************************
- * SelTempGUI
- *
- * create gui for this panel
- *****************************************************/
- void SelTempGUI(void)
- {
-
- done = FALSE;
- usrSel = amntState.currTemplate;
- /*AmiLock();*/
-
- if (selWin == NULL) {
- GF_SetGUIAttr(seltempGUI, GUI_OpenGUI, TRUE, TAG_DONE);
- SelTempStrip();
-
- GF_GetGUIAttr(seltempGUI, GUI_Window, &selWin, TAG_DONE);
- ResetMenuStrip(selWin,menuStrip);
- usrSel = amntState.currTemplate;
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPTEMPLIST].gs_Gadget,
- GTLV_Labels, &templates,
- GTLV_MakeVisible, amntState.currTemplate,
- GTLV_Selected,amntState.currTemplate,
- TAG_DONE);
-
- selAttach = TRUE;
- filterSel = SELALL;
- NewList(&usrTemplates);
-
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPFILTER].gs_Gadget,
- GTCY_Active, filterSel,
- TAG_DONE);
- }
- else {
- WindowToFront(selWin);
- ActivateWindow(selWin);
- }
-
- #if 0
- /* Process input events */
- while (!done)
- {
- struct IntuiMessage *imsg;
- /* Wait for an event to occur */
-
- GF_Wait(guiapp,0);
-
- /* We only bother to listen for CLOSEWINDOW events.
- * Of course, in a real application, you would be
- * examining the Class field for IDCMP_GADGETUP
- * messages and act accordingly.
- */
-
- while (imsg = GF_GetIMsg(guiapp))
- {
- if (imsg->IDCMPWindow->UserData == gui)
- AmiLocalMsg(imsg);
- else SelTempMsg(imsg);
- GF_ReplyIMsg(imsg);
- }
- }
-
- GF_SetGUIAttr(seltempGUI, GUI_OpenGUI, FALSE, TAG_DONE);
- selWin = NULL;
- SelTempStrip();
-
- /* AmiUnlock();*/
- #endif
- }
-
- /********************************************************
- * SelTempMsg()
- *
- * Handles messages from afar
- **********************************************************/
- BOOL SelTempMsg(struct IntuiMessage *imsg)
- {
- BOOL done = FALSE;
-
- switch (imsg->Class) {
- case IDCMP_CLOSEWINDOW:
- done = TRUE;
- break;
-
- case IDCMP_RAWKEY:
- if (imsg->Code == 0x44) {
- amntState.currTemplate = SelTrueTemplate(usrSel);
- AmiEnterData();
- }
- else if (imsg->Code == 0x40) {
- done = TRUE;
- }
- else if (GF_ProcessListView(seltempGUI,SP_SelTempSpecs[GID_SPTEMPLIST],
- imsg,&ordinal)) {
- usrSel = ordinal;
- if (filterSel == SELALL)
- amntState.currTemplate = ordinal;
- else amntState.currTemplate = SelTrueTemplate(usrSel);
- AmiNewTemp();
- }
- else AmiHelpKey(imsg,SELTEMP_PANEL);
- break;
-
- case IDCMP_REFRESHWINDOW:
- RegRefresh(TRUE);
- break;
-
- case IDCMP_MENUPICK:
- amidone = done = AmiHandleMenu(imsg);
- if (seldone == TRUE)
- done = seldone;
- break;
-
- case IDCMP_GADGETUP:
- SelHandleGadget(imsg);
- break;
- }
-
- if (done) {
- SelTempStrip();
- selWin = NULL;
- }
-
- return (done);
- }
-
- /***************************************************
- * SelHandleGadget....
- *
- * double clicks and OK will change ord val.
- ****************************************************/
- void SelHandleGadget(struct IntuiMessage *imsg)
- {
- struct List *list;
- struct Gadget *gad = (struct Gadget *)(imsg->IAddress);
- UWORD code = imsg->Code;
-
- switch (gad->GadgetID) {
- case GID_SPTEMPLIST:
- /* find curr template based on which list? */
- amntState.currTemplate = usrSel = code;
-
- if (filterSel != SELALL)
- amntState.currTemplate = SelTrueTemplate(code);
-
- AmiNewTemp();
- AmiEnterData();
- break;
-
- case GID_SPFILTER:
- amntState.currTemplate = SelTrueTemplate(usrSel);
-
- /* detach and free list */
- SelTempStrip();
- if (filterSel != SELALL) {
- DataFreeList(&usrTemplates);
- }
-
- filterSel = code;
- if (filterSel != SELALL) {
- SelBuildList();
- amntState.currTemplate = usrSel = 0;
- list = &usrTemplates;
- }
- else {
- usrSel = amntState.currTemplate;
- list = &templates;
- }
-
-
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPTEMPLIST].gs_Gadget,
- GTLV_Labels, list,
- GTLV_Selected, usrSel,
- GTLV_MakeVisible, usrSel,
- TAG_DONE);
-
- selAttach = TRUE;
- break;
- }
- }
-
-
- /***********************************************************
- * SelTempStrip()
- *
- *
- ************************************************************/
- void SelTempStrip(void)
- {
- if (selAttach == TRUE) {
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPTEMPLIST].gs_Gadget,
- GTLV_Labels, ~0,
- TAG_DONE);
- selAttach = FALSE;
- }
- }
-
- /***********************************************************
- * SelTempInstall()
- *
- *
- ************************************************************/
- void SelTempInstall(void)
- {
- amntState.currTemplate = 0;
- SelTempStrip();
-
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPTEMPLIST].gs_Gadget,
- GTLV_Labels, &templates,
- GTLV_Selected, amntState.currTemplate,
- GTLV_MakeVisible, amntState.currTemplate,
- TAG_DONE);
-
- selAttach = TRUE;
- filterSel = SELALL;
- NewList(&usrTemplates);
-
- GF_SetGadgetAttrs(seltempGUI,SPgadgetspecs[GID_SPFILTER].gs_Gadget,
- GTCY_Active, filterSel,
- TAG_DONE);
-
- AmiNewTemp();
- }
-
- /************************************************************
- * SelBuildList(void)
- *
- * Build a temporary list
- *************************************************************/
- void SelBuildList(void)
- {
- templateNode *node = NULL;
-
- while ( (node = (templateNode *)DataGetNext(&templates,(struct Node *)node)) != NULL) {
- if (node->template.type == filterSel-1 || filterSel == SELALL)
- DataAddTemp(&usrTemplates, node);
- }
- }
-
- /*****************************************************************
- * SelTrueTemplate(int,int)
- *
- * Find actual template from sublist
- ******************************************************************/
- UWORD SelTrueTemplate(UWORD index)
- {
- templateNode *node;
-
- if (filterSel != SELALL) {
- node = (templateNode *)DataOrd2Node(&usrTemplates,index);
- return ((UWORD)DataNode2Ord(&templates,node->node.ln_Name));
- }
- else return (amntState.currTemplate);
- }
-