/* Purpose: Program allows entry of trip information, saving, loading and editing of the information Author: Donald W Millican Start Date : 18/06/99 Finish Date: 29/06/99 Section: Future Program: Simple cycle trip database */ /* *** Pre-Program History *** 20/06/99 : Version 0.1 : Main Window created and basic GUI structures ready 22/06/99 : Version 0.2 : Record Structure established & Destination detected 23/06/99 : Version 0.3 : All fields down to train working 23/06/99 : Version 0.4 : All fields working 24/06/99 : Version 0.5 : Menu item 'New' works 25/06/99 : Version 0.6 : Vanilla keys are working 28/06/99 : Version 0.7 : Save routines created and working 28/06/99 : Version 0.8 : Load routines created and working 29/06/99 : Version 0.9 : ASL filerequester integrated into load & save 29/06/99 : Version 0.95 : Bugfixing and streamlining of code *** Program History 29/06/99 : Version 1.0 : Initial Release 30/06/99 : Version 1.1 : Tidy up existing requesters & include error requesters 30/06/99 : Version 1.2 : Create record counter gadget 01/07/99 : Version 1.3 : Warning requesters for 'New', 'Load' & 'Save' 02/07/99 : Version 1.4 : CycleDBase file recognition 07/07/99 : Version 1.5 : New Search menu & function 'Exact Match' 01/08/99 : Version 1.6 : Fix corruption when menu item 'new' is selected 05/08/99 : Version 1.65 : Add recognition of existing records & improve requesters 06/08/99 : Version 1.7 : Reduce save file sizes using record recognition 21/09/99 : Version 1.8 : Create seperate 'Advanced Search' program 26/09/99 : Version 1.9 : Advanced Search program works properly 26/09/99 : Version 1.95 : Use records.recs (actual records) for normal searches 11/10/99 : Version 1.98 : Disable Gadgets which are not in use 20/10/99 : Version 2.0 : Incorporate new search program into CycleDBase --/--/99 : Version 2.1 : New Search function 'Containing' - use at later date --/--/99 : Version 2.2 : 'Containing' added to AdvSearch program --/--/99 : Version 2.3 : AdvSearch incorporated into CycleDBase again */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "CycleDBase.h" /* ** Prepare for using GadTools, set up gadgets and open window. ** Clean up and when done or on error. */ void gadtoolsWindow() { struct TextFont *font; struct Screen *mysc; struct Window *mywin; struct Gadget *glist, *my_gads[NUM_GADS]; struct StringInfo *gad_ptr[PTRS]; void *vi; APTR visualinfo; UWORD topborder; struct Menu *mainmenustrip; /****************************/ /* THE MENU STRUCTURE: */ /****************************/ struct NewMenu main_menu[] = { {NM_TITLE,"Main",0,0,0,0,}, {NM_ITEM,"New","N",0,0,0,}, {NM_ITEM,"Load...","L",0,0,0,}, {NM_ITEM,"Save...","S",0,0,0,}, {NM_ITEM,"About","?",0,0,0,}, {NM_ITEM,"Quit","Q",0,0,0,}, {NM_TITLE,"Search",0,0,0,0,}, {NM_ITEM,"Exact Match...","E",0,0,0,}, {NM_ITEM,"Containing...","C",0,0,0,}, {NM_ITEM,NM_BARLABEL,0,0,0,0,}, {NM_ITEM,"Advanced Search","A",0,0,0,}, {NM_END,NULL,0,0,0,0,}, }; // Set number of actual records to zero records.recs[0] = 0; /* Open topaz 8 font, so we can be sure it's openable ** when we later set ng_TextAttr to &Topaz80: */ if (NULL == (font = OpenFont(&Topaz80))) { EasyRequest(NULL, &nofont, NULL); } else { if (NULL == (mysc = LockPubScreen(NULL))) { EasyRequest(NULL, &noscreen, NULL); } else { if (NULL == (vi = GetVisualInfo(mysc, TAG_END))) { EasyRequest(NULL, &novisinfo, NULL); } else { /* Here is how we can figure out ahead of time how tall the */ /* window's title bar will be: */ topborder = mysc->WBorTop + (mysc->Font->ta_YSize + 1); if (NULL == createAllGadgets(&glist, vi, topborder, my_gads, gad_ptr)) { EasyRequest(NULL, &nogadgets, NULL); } else { if (NULL == (mywin = OpenWindowTags(NULL, WA_Title, "Cycle Database", WA_Gadgets, glist, WA_AutoAdjust, TRUE, WA_Width, 450, WA_MinWidth, 450, WA_InnerHeight, 200, WA_MinHeight, 200, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_CloseGadget, TRUE, WA_SimpleRefresh, TRUE, WA_NewLookMenus, TRUE, WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY | IDCMP_MENUPICK | STRINGIDCMP | BUTTONIDCMP, WA_PubScreen, mysc, TAG_END))) { EasyRequest(NULL, &nowindow, NULL); } else { /* After window is open, gadgets must be refreshed with a ** call to the GadTools refresh window function. */ GT_RefreshWindow(mywin, NULL); visualinfo=GetVisualInfo(mysc, TAG_END); mainmenustrip=CreateMenus(main_menu, TAG_END); LayoutMenus(mainmenustrip, visualinfo, GTMN_NewLookMenus, TRUE, TAG_END); SetMenuStrip(mywin, mainmenustrip); process_window_events(mysc, mywin, my_gads, mainmenustrip, gad_ptr); ClearMenuStrip( mywin ); FreeMenus(mainmenustrip); CloseWindow(mywin); } } /* FreeGadgets() even if createAllGadgets() fails, as some ** of the gadgets may have been created...If glist is NULL ** then FreeGadgets() will do nothing. */ FreeGadgets(glist); FreeVisualInfo(vi); FreeVisualInfo(visualinfo); } UnlockPubScreen(NULL, mysc); } CloseFont(font); } } /* ** Open all libraries and run. Clean up when finished or on error.. */ void main() { if (NULL == (IntuitionBase = OpenLibrary("intuition.library", 37))) { EasyRequest(NULL, &nointuition, NULL); } else { if (NULL == (GfxBase = OpenLibrary("graphics.library", 37))) { EasyRequest(NULL, &nographics, NULL); } else { if (NULL == (GadToolsBase = OpenLibrary("gadtools.library", 37))) { EasyRequest(NULL, &nogadtools, NULL); } else { if (NULL == (AslBase = OpenLibrary("asl.library", 37L))) { EasyRequest(NULL, &noasl, NULL); } else { gadtoolsWindow(); CloseLibrary(AslBase); } CloseLibrary(GadToolsBase); } CloseLibrary(GfxBase); } CloseLibrary(IntuitionBase); } }