#include #include "curse.h" #include "displayud.h" #include "global.h" displayud flags; cccwindows wintype; window menu, title, display, io, status1, status2, status3, err, help, menuopt, win; int selecteditem=0, startitem=0, finishitem=0; /********************************************************************** * * Function: SetColors * Input: window& win - the window to modify * colorwins wintype - the type of window to modify * * Returns: void * * Description: * Sets the window colors * * Variables: none * * Called by: SetupWin * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void SetColors(window& win, colorwins wintype) { // ** Set the colors of a window to Gray on Blue switch(wintype) { case MENUBAR: wattrset(win, menufront|menuback); break; case DISPLAY: wattrset(win, dispfront|dispback); break; case STATUS: wattrset(win, statfront|statback); break; } } // end setcolors /********************************************************************** * * Function: SetupWin * Input: window& win - the window to modify * cccwindows wintype - the type of window to modify * * Returns: void * * Description: * Sets up the window * * Variables: none * * Called by: CreateWin * * Calls: SetColors * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void SetupWin(window& win, cccwindows wintype) { // ** set colors and erase to clear window switch (wintype) { case MENUWIN: case IOWIN: case STATUS2WIN: case MENUOPTWIN: case ERRWIN: case HELPWIN: SetColors(win, MENUBAR); break; case TITLEWIN: case DISPLAYWIN: SetColors(win, DISPLAY); break; case STATUS1WIN: case STATUS3WIN: SetColors(win, STATUS); break; } werase(win); } // end SetupWin /********************************************************************** * * Function: CreateWin * Input: cccwindows winnum - the window to modify * int numlines - the number of lines to make * int numcols - the width to make the window * int starty - the starting y offset * int startx - the starting x offset * * Returns: void * * Description: * Makes a window with the given parameters * * Variables: none * * Called by: InitCurses * DisplayMessage * DrawMenu * * Calls: SetupWin * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void CreateWin (cccwindows winnum, int numlines, int numcols, int starty, int startx) { // ** turn attrs off and reset window colors switch(winnum) { case MENUWIN: menu = newwin (numlines,numcols,starty,startx); SetupWin(menu,winnum) ; //set colors & clear break; case TITLEWIN: title = newwin (numlines,numcols,starty,startx); SetupWin(title,winnum) ; //set colors & clear break; case DISPLAYWIN: display = newwin (numlines,numcols,starty,startx); SetupWin(display,winnum) ; //set colors & clear break; case IOWIN: io = newwin (numlines,numcols,starty,startx); SetupWin(io,winnum) ; //set colors & clear keypad(io,TRUE); // *** turn on cursor key input break; case STATUS1WIN: status1 = newwin (numlines,numcols,starty,startx); SetupWin(status1,winnum) ; //set colors & clear break; case STATUS2WIN: status2 = newwin (numlines,numcols,starty,startx); SetupWin(status2,winnum) ; //set colors & clear break; case STATUS3WIN: status3 = newwin (numlines,numcols,starty,startx); SetupWin(status3,winnum) ; //set colors & clear break; case ERRWIN: err = newwin (numlines,numcols,starty,startx); SetupWin(err,winnum) ; //set colors & clear box ( err, C_V, C_H ) ; break; case HELPWIN: help = newwin (numlines,numcols,starty,startx); SetupWin(help,winnum) ; //set colors & clear box ( help, C_V, C_H ) ; break; case MENUOPTWIN: menuopt = newwin (numlines,numcols,starty,startx); SetupWin(menuopt,winnum) ; //set colors & clear box ( menuopt, C_V, C_H ) ; keypad(menuopt,TRUE); // *** turn on cursor key input break; } } // end CreateWin /********************************************************************** * * Function: InitCurses * Input: void * * Returns: void * * Description: * Sets up Curses stuff * * Variables: none * * Called by: Main * * Calls: CreateWin * Add2Win * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void InitCurses() { initscr(); SetWindowTitle("Cinema Critic Comments"); // Set MS Window Title werase(stdscr); nonl(); // do not let curses translate newline - return & linefeed noecho(); // *** do not echo input *** cursoff(); //turn off cursor raw() ; // *** turn curses unbuffered input on *** erase() ; // clear screen refresh() ;// display stANdARDscrEEN CreateWin(MENUWIN, 1, 80, 0, 0); CreateWin(TITLEWIN, 1, 80, 1, 0); CreateWin(DISPLAYWIN, 21, 80, 2, 0); CreateWin(IOWIN, 1, 80, 23, 0); CreateWin(STATUS1WIN, 1, 25, 24, 0); CreateWin(STATUS2WIN, 1, 30, 24, 25); CreateWin(STATUS3WIN, 1, 25, 24, 55); CreateWin(ERRWIN, 15, 70, 5, 10); CreateWin(HELPWIN, 15, 70, 5, 10); CreateWin(MENUOPTWIN, 8, 21, 1, 0); Add2Win(MENUWIN,0,0,"Program File Edit CCC View Search"); Add2Win(STATUS2WIN,0,4,"Cinema Critic Comments"); } /********************************************************************** * * Function: ShutDownCurses * Input: void * * Returns: void * * Description: * kills the curses stuff * * Variables: none * * Called by: Main * * Calls: none * * Author: Glenn Rioux * Revisions: none * Version: 1.0 * * **********************************************************************/ void ShutDownCurses(void) { move(25,0); refresh(); noraw(); endwin(); exit(0); } /********************************************************************** * * Function: SUDS * Input: integers for windows * * Returns: void * * Description: * sets a flag to update windows with positive integers * * Variables: none * * Called by: ReadVRS * ReadMRS * MainHandler * Main * ViewFile * SaveAs * ShowEnd * MsgWinKeyOpts * CommandLineInterface * WaitMessage * Response * List * ListMovie * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void SUDS(int m,int t,int d, int i, int s1, int s2, int s3, int menu, int er, int hlp) { if(m>flags.m) flags.m=m; if(t>flags.t) flags.t=t; if(d>flags.d) flags.d=d; if(i>flags.i) flags.i=i; if(s1>flags.s1) flags.s1=s1; if(s2>flags.s2) flags.s2=s2; if(s3>flags.s3) flags.s3=s3; if(menu>flags.menu) flags.menu=menu; if(er>flags.er) flags.er=er; if(hlp>flags.hlp) flags.hlp=hlp; } /********************************************************************** * * Function: SUDS * Input: void * * Returns: void * * Description: * resets the window flags * * Variables: none * * Called by: UpdateDisplay * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void SUDS() { flags.m=0; flags.t=0; flags.d=0; flags.i=0; flags.s1=0; flags.s2=0; flags.s3=0; flags.menu=0; flags.er=0; flags.hlp=0; } /********************************************************************** * * Function: GUDS * Input: void * * Returns: displayud - a structure with all of the update flags * * Description: * gets the window flags * * Variables: none * * Called by: UpdateDisplay * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ displayud GUDS() { return flags; } /********************************************************************** * * Function: GetWindow * Input: cccwindows windownum - the window const to return * * Returns: window - a pointer to the window requested * * Description: * returns a pointer to the window for direct manipulation * * Variables: none * * Called by: ReadVRS * ReadMRS * ViewFile * Close * SaveAs * MainHandler * Add2Win * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ window GetWindow(cccwindows windownum) { switch (windownum) { case MENUWIN: return menu; case TITLEWIN: return title; case DISPLAYWIN: return display; case IOWIN: return io; case STATUS1WIN: return status1; case STATUS2WIN: return status2; case STATUS3WIN: return status3; case ERRWIN: return err; case HELPWIN: return help; case MENUOPTWIN: return menuopt; } return NULL; } /********************************************************************** * * Function: Add2Win * Input: cccwindows winnum - the window to use * int ystart - the starting y offset for the text * int xstart - the starting x offset for the text * char* text - the text to insert * * Returns: void * * Description: * Inserts a line into a window at the given positions. Does not require a direct * manipulation of the window to use. * * Variables: none * * Called by: ReadVRS * ViewFile * Response * InitCurses * DisplayMessage * DrawMenu * MsgWinKeyOpts * List * ListMovie * * Calls: GetWindow * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void Add2Win(cccwindows winnum, int ystart, int xstart, char* text) { win = GetWindow(winnum); mvwaddstr(win,ystart,xstart,text); } /********************************************************************** * * Function: UpdateDisplay * Input: cccmenuopts menuCode - the menu to use * int selection - the selection number * int* xstart - the length of the menu * * Returns: void * * Description: * Redraws the display windows that have been set. * * Variables: displayud update - update structure * * Called by: MainHandler * * Calls: SUDS * GUDS * UpdateDisplay * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void UpdateDisplay(cccmenuopts menuCode, int selection, int * length) { displayud update; update=GUDS(); if (update.m>0) { touchwin(menu); wrefresh(menu); } if (update.t>0) { touchwin(title); wrefresh(title); } if (update.d>0) { touchwin(display); wrefresh(display); } if (update.i>0) { touchwin(io); wrefresh(io); } if (update.s1>0) { touchwin(status1); wrefresh(status1); } if (update.s2>0) { touchwin(status2); wrefresh(status2); } if (update.s3>0) { touchwin(status3); wrefresh(status3); } if(menuCode != NONE) { DrawMenu(menuCode, length); } if (update.menu>0) { touchwin(menuopt); wrefresh(menuopt); } if (update.er>0) { touchwin(err); wrefresh(err); } if (update.hlp>0) { touchwin(help); wrefresh(help); } SUDS(); } /********************************************************************** * * Function: GetDispParams * Input: int& selected - the selected item * int& start - the starting position * int& finish - the finishing position * * Returns: void * * Description: * returns the parameters * * Variables: none * * Called by: List * ListMovie * ViewFile * Movie * Category * MainHandler * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void GetDispParams(int &selected, int &start, int &finish) { selected=selecteditem; start=startitem; finish=finishitem; } /********************************************************************** * * Function: SetDispParams * Input: int selected - the selected item * int start - the starting position * int finish - the finishing position * * Returns: void * * Description: * sets the flags for the parameters * * Variables: none * * Called by: List * ListMovie * MainHandler * * Calls: none * * Author: Tim McGaughey * Revisions: none * Version: 1.0 * * **********************************************************************/ void SetDispParams(int selected, int start, int finish) { selecteditem=selected; startitem=start; finishitem=finish; }