/* Main window support */ #include "common.h" #include "datalib.h" #include "archive.h" #include "function.h" #include "curve.h" #include "visual.h" #include "diagram.h" #include "point.h" #include "param.h" #include "help.h" #include "userfunc.h" extern Global(CharPtr PNTR) MainwndTxt; /* defined in text.c */ enum { /* see setup.c, init[], /mainwnd */ MAIN_C, /* Ready */ INIT_C, /* Initializing... */ MAINOPT_C, /* Waiting for options setting */ CURSYS, /* 30 */ #if DEB DEBUG_M, /* Debug{ */ #if DEB_VIS VIEWVIS_I, /* Visual List */ WIN_I, /* Windows */ #endif #if DEB_DL VIEWCAT_I, /* View Archives */ VIEWDGM_I, /* View Diagrams */ VIEWSYS_I, /* View Special */ UPDATE_I, /* Enable update? */ #endif #if DEB_MEM MEMTRACE_I, /* Memory trace */ #endif #if DEB_CT CURVETYPES_I, /* Curve Types */ #endif PARAMCLEAN_I, /* FuncParamCleanup */ #endif DUMMYEND_I, /* } */ SEPARATOR_I, /* - */ SYSTEMS_M, /* Select{ */ CLASS_M, /* Object class{ */ ARCHIVES_I, /* Archive... */ FUNCTIONS_I, /* System... */ DIAGRAM_I, /* Diagram... */ CURVE_I, /* Curve... */ IPOINT_I, /* Inital point... */ USERTEST_I, /* User functions... */ EXIT_I, /* Exit */ WINDOWS_M, /* Window{ */ CREATEG_I, /* Open graphics */ CREATET_I, /* Open text */ CREATEC_I, /* Open values */ REDRAW_I, /* Redraw diagram */ REDRAWC_I, /* Redraw curve */ CLEARALL_I, /* Clear all */ SHOWHIDDEN_I, /* Show hidden... */ TYPE_M, /* Type{ */ COMPUTE_M, /* Compute{ */ FORWARD_I, /* Forward */ BACKWARD_I, /* Backward */ CONTINUE_I, /* Continue */ OPTIONS_M, /* Options{ */ SYSFONT_I, /* System font... */ PRGFONT_I, /* Text font... */ MAINWIN_I, /* Main window... */ ARCH_I, /* Archive filter... */ PAUSE_I, /* Pause mode... */ POINT_I, /* Special points... */ CLASS_T, /* Object class */ ARCHNAME_T, /* Archive */ CURSYS_T, /* System */ DIAGRAM_T, /* Diagram */ CURVE_T, /* Curve */ INITTYPE_T, /* Point type */ CURVETYPE_T, /* Curve type */ DERIVATIVES_T, /* Derivatives */ STATUS_T, /* Status */ DURATION_T, /* Duration */ MESSAGE_T, /* Message */ OPTWIN_W, /* Main window */ OPTWIN_T, /* Show in Main Window */ HELP_M, THISWIN_I, INDEX_I, SEARCH_I, HELPPT_I, HELPCT_I, HELPST_I, HELPGE_I, HELPAB_I, /* About */ CREATE_M, /* Open */ INENTRYX /* dummy */ } MainwndTxtIndex; Local(void) MainWinOptProc(Int2 index); Local(void) SetSystemFont(Int2 index); Local(void) SetProgramFont(Int2 index); Global(FonT) SystemFont=NULL, ProgramFont=NULL; Global(Int2) sysLineHeight,sysCharWidth,sysDescent,sysAscent, sysFontHeight,sysLeading; Global(Int2) sysLineHeight2,sysCharWidth2,sysLineHeight4,sysCharWidth4; Local(void) WriteFontSpec(FontSpecPtr fs, CharPtr key); Local(Boolean) ReadFontSpec(FontSpecPtr fs, CharPtr key); Local(void) InstallSystemFont(FontSpecPtr fs); Local(void) InstallProgramFont(FontSpecPtr fs); Local(void) HelpWindowProc(Int2 index); /***Local(void) HelpIndexProc(Int2 index);***/ Local(void) HelpSearchProc(Int2 index); Local(void) HelpCurProc(Int2 index); Local(void) HelpAboutProc(Int2 index); #if _WIN #pragma argsused #endif Local(void) ExitProc(Int2 index) { FreeHelpFile(TRUE); DestroyMainWindow(); TermFlag=TRUE; /* Let DoMenuAction() to know */ QuitProgram(); /* exit ProcessEvents() loop */ } #if _WIN #pragma argsused #endif Local(Boolean) Always_Status(Int2 index) {return TRUE;} #if DEB #if _WIN #pragma argsused #endif Local(void) Debug_ParamFuncCleanup(Int2 index) { ParamFuncCleanup(&DiagramLib); } #endif /* DEB */ Local(MenuItem) Menu[]={ #if DEB {DEBUG_M, NULL, NULL}, #if DEB_DL { VIEWCAT_I, Debug_DataLibShow, Always_Status,1}, { VIEWDGM_I, Debug_DataLibShow, Always_Status,2}, { VIEWSYS_I, Debug_DataLibShow, Always_Status,3}, { UPDATE_I, Debug_DataLibShowU, Debug_DataLibShowU_Status}, #endif #if DEB_MEM { MEMTRACE_I, Debug_MemTrace, Debug_MemTrace_Status}, #endif #if DEB_VIS { VIEWVIS_I, Debug_VisualList, Always_Status}, #endif #if DEB_CT { CURVETYPES_I, Debug_CurveTypes, Always_Status}, #endif { PARAMCLEAN_I, Debug_ParamFuncCleanup, Always_Status}, { DUMMYEND_I, NULL, NULL}, #endif /* DEB */ {SYSTEMS_M, NULL, NULL}, { CLASS_M, NULL, NULL}, { DUMMYEND_I, NULL, NULL}, { SEPARATOR_I, NULL, NULL}, /****************** { ARCHIVES_I, SelectArchives, SelectArchives_Status}, { SEPARATOR_I, NULL, NULL}, ******************/ { FUNCTIONS_I, SelectFunction, SelectFunction_Status}, { SEPARATOR_I, NULL, NULL}, { DIAGRAM_I, SelectDiagram, SelectDiagram_Status}, { SEPARATOR_I, NULL, NULL}, { CURVE_I, SelectCurve, SelectCurve_Status}, { SEPARATOR_I, NULL, NULL}, { IPOINT_I, SelectPointProc, SelectPointProc_Status}, { SEPARATOR_I, NULL, NULL}, { USERTEST_I, UserFuncProc, UserFuncProc_Status}, { SEPARATOR_I, NULL, NULL}, { EXIT_I, ExitProc, Always_Status}, { DUMMYEND_I, NULL, NULL}, {WINDOWS_M, NULL, NULL}, { CREATE_M, NULL, NULL}, { DUMMYEND_I, NULL, NULL}, { SEPARATOR_I, NULL, NULL}, { REDRAW_I, RedrawDiagram, SelectCurve_Status,0,MNFL_ACTIVEINPAUSE}, { REDRAWC_I, RedrawCurveProc, ContinueProc_Status,0,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { CLEARALL_I, ClearAllWindows, CreateWindow_Status,0,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { SHOWHIDDEN_I, ShowHiddenWindows, ShowHiddenWindow_Status}, { DUMMYEND_I, NULL, NULL}, {TYPE_M, NULL, NULL}, { DUMMYEND_I, NULL, NULL}, {COMPUTE_M, NULL, NULL}, { FORWARD_I, ForwardProc, FBProc_Status}, { BACKWARD_I, BackwardProc, FBProc_Status}, { SEPARATOR_I, NULL, NULL}, { CONTINUE_I, ContinueProc, ContinueProc_Status}, { DUMMYEND_I, NULL, NULL}, {OPTIONS_M, NULL, NULL}, { ARCH_I, FilterOptProc, FilterOptProc_Status}, { PAUSE_I, PauseOptProc, PauseOptProc_Status,0,MNFL_ACTIVEINPAUSE}, { POINT_I, PointOptProc, PointOptProc_Status,0,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { SYSFONT_I, SetSystemFont, Always_Status}, { PRGFONT_I, SetProgramFont, Always_Status}, { MAINWIN_I, MainWinOptProc, Always_Status}, { DUMMYEND_I, NULL, NULL}, {HELP_M, NULL, NULL}, { THISWIN_I, HelpWindowProc, Always_Status,0,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, /*** { INDEX_I, HelpIndexProc, Always_Status,0,MNFL_ACTIVEINPAUSE},***/ { SEARCH_I, HelpSearchProc, Always_Status,0,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { HELPPT_I, HelpCurProc, TypesSet_Status,TH_INITPOINT,MNFL_ACTIVEINPAUSE}, { HELPCT_I, HelpCurProc, TypesSet_Status,TH_CURVE,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { HELPST_I, HelpCurProc, TypesSet_Status,TH_STARTER,MNFL_ACTIVEINPAUSE}, { HELPGE_I, HelpCurProc, TypesSet_Status,TH_GENERATOR,MNFL_ACTIVEINPAUSE}, { SEPARATOR_I, NULL, NULL}, { HELPAB_I, HelpAboutProc, Always_Status,0,MNFL_ACTIVEINPAUSE}, { DUMMYEND_I, NULL, NULL} }; /* Descriptor of Main menu */ Global(MenuDesc) MainMenu={Menu,DIM(Menu)}; Local(void) MainWindowCloseProc(WindoW); Local(void) MainMenuCallback(IteM i); Local(void) MainMenuKey(Char key); /* process Main menu keystrokes */ Local(WindoW) wMain=0; typedef struct { Int2 Title; Boolean eol; PrompT pInfo; ButtoN bOpt; } InfoDesc; Local(InfoDesc) Info[]={ /* info about current: */ {{CLASS_T},FALSE}, /* Object class (ODEs, Maps, etc.) */ {{ARCHNAME_T},FALSE}, /* archives (full path and name) */ {{CURSYS_T},TRUE}, /* system */ {{DIAGRAM_T},FALSE}, /* diagram */ {{CURVE_T},TRUE}, /* curve */ {{INITTYPE_T},FALSE}, /* init point type */ {{CURVETYPE_T},FALSE}, /* curve type */ {{DERIVATIVES_T},TRUE}, /* derivatives */ {{STATUS_T},FALSE}, /* status info */ {{DURATION_T},FALSE}, /* duration of last action */ {{MESSAGE_T},FALSE} /* message */ }; Local(Char) VisibleMask[DIM(Info)+1]; Local(Int2) TypeSubmenuIndex; Local(void) BuildClassGraph(Int2 classindex); Local(void) DestroyClassGraph(void); Local(void) DefColors(PaneL pa) { Select(pa); defForeground=GetColor(); InvertColors(); defBackground=GetColor(); InvertColors(); Hide(pa); } Global(Int2) CreateMainWindow(void) { GrouP g; int width; Int2 i; Int2 l,t; FontSpec fs; /* Fonts */ if (ReadFontSpec(&fs,"SYSFONT")) InstallSystemFont(&fs); if (!SystemFont) SystemFont=systemFont; /******** if (!SystemFont) SystemFont=systemFont; ********/ SelectFont(SystemFont); sysLineHeight=LineHeight(); sysCharWidth=MaxCharWidth(); sysDescent=Descent(); sysAscent=Ascent(); sysFontHeight=FontHeight(); sysLeading=Leading(); sysLineHeight2=sysLineHeight>>1; sysCharWidth2=sysCharWidth>>1; sysLineHeight4=sysLineHeight>>2; sysCharWidth4=sysCharWidth>>2; if (ReadFontSpec(&fs,"PRGFONT")) InstallProgramFont(&fs); if (!ProgramFont) ProgramFont=programFont; /* Create the Main window */ ReadWindowPos("W_MAIN",&l,&t); StrCpy(ParBuf,"Content "); StrCat(ParBuf,VERSION); wMain=FixedWindow(l,t,-5,-5,ParBuf,MainWindowCloseProc); /* Create main menu */ CreateMenu(wMain,MainwndTxt,&MainMenu,MainMenuCallback); /* Build type curves graph */ for (i=0; iname,(int)fs->size,(int)fs->style, (int)fs->charset,(int)fs->pitch,(int)fs->family); SetParam(SFS_CURRENTS,key,ParBuf); } Local(Boolean) ReadFontSpec(FontSpecPtr fs, CharPtr key) { int size,style,charset,pitch,family; GetParam(SFS_CURRENTS,key); if (*ParBuf=='*') return FALSE; else { sscanf(ParBuf,"%[^|]| %i %i %i %i %i", fs->name,&size,&style,&charset,&pitch,&family); fs->size=(Int2)size; fs->style=(Uint1)style; fs->charset=(Uint1)charset; fs->pitch=(Uint1)pitch; fs->family=(Uint1)family; return TRUE; } } Local(void) InstallSystemFont(FontSpecPtr fs) { FonT ps; ps=CreateFont(fs); if (ps) { SystemFont=ps; } } Local(void) InstallProgramFont(FontSpecPtr fs) { FonT ps; ps=CreateFont(fs); if (ps) { ProgramFont=ps; } } #if _WIN #pragma argsused #endif Local(void) SetSystemFont(Int2 index) { FontSpec fs; GetFontSpec(SystemFont ? SystemFont : systemFont,&fs); if (ChooseFont(&fs,CFF_READ_FSP,NULL)) { WriteFontSpec(&fs,"SYSFONT"); InstallSystemFont(&fs); DestroyMainWindow(); CreateMainWindow(); } else Select(wMain); } #if _WIN #pragma argsused #endif Local(void) SetProgramFont(Int2 index) { FontSpec fs; GetFontSpec(ProgramFont ? ProgramFont : programFont,&fs); if (ChooseFont(&fs,CFF_READ_FSP,NULL)) { WriteFontSpec(&fs,"PRGFONT"); InstallProgramFont(&fs); DestroyMainWindow(); CreateMainWindow(); } else Select(wMain); } /*******************************/ /* Object class graph and menu */ typedef struct { CharPtr ShortName; /* label */ CharPtr FullName; /* used in menus */ CharPtr ClassName; /* used in class field in main win */ CharPtr DescFile; CharPtr HelpInfo; /* help key for the class */ int Code; int Parent; } ClassNode, PNTR ClassNodePtr; Local(Int2) ClassNodeNum; Local(ClassNodePtr) Classes=NULL; Local(int) CurClass; Global(MenuDesc) ClassMenuDesc; Local(Int2) ShortToFull(CharPtr shortname) { Int2 k; for (k=0; kTitle=i; cp=StrPBrk(b,"{}-"); if (cp) { if (*cp=='{') { *cp='\0'; j=ShortToFull(b); if (j>=0) { StrCpy(b,Classes[j].FullName); StrCat(b,"{"); Classes[j].Parent=parent[pi]; parent[++pi]=j; } else *cp='{'; } if (*cp=='}') pi--; pItem->UserIndex=-1; /* submenu does not correspond to any graph node */ } else { cp=StrChr(b,' '); *cp++='\0'; /* .con file */ StrTrim(cp); cq=StrChr(cp,' '); *cq++='\0'; /* help info */ StrTrim(cq); j=ShortToFull(b); if (j>=0) { Classes[j].DescFile=_StringSave(cp); Classes[j].HelpInfo=_StringSave(cq); Classes[j].Parent=parent[pi]; StrCpy(b,Classes[j].FullName); } else { } pItem->UserIndex=j; /* 'menu item' -> 'node index' map */ pItem->Action=ClassAction; pItem->EnableDisable=ClassStatus; } texts[i]=_StringSave(b); } /* create class menu */ CreateMenu((WindoW)Menu[classindex].ItemId,texts,&ClassMenuDesc,ClassCallback); /* clean up */ for (i=0; i