// Part of the Scriptura program // pane.h -- header file for pane class #ifndef PANE #define PANE #include #include #include #include #include "free.h" // pane - defines a window complex to display data retrieved from sword class pane { WINDOW *win; // the window drawing the bounding box char titlebar[40]; // window titlebar bool hasFocus; // holds window focus status WINDOW *pad; /* typically a pad holding buffer text, but may * instead be a window holding a menu or form */ int padx, pady; // the pad bounding box upper left corner int padrows, padcols; // the pad bounding box dimensions // if pad is an ncurses pad, then: int buflocx, buflocy; // the pad buffer location (ie. where we are) int bufsizex, bufsizey; // the pad buffer size (height & width) modkey mod; // module key associated with this pane char* rawtext; // copy of unprocessed text the pane is showing /* retitle * refresh the title of the window */ void retitle(); /* renderText * take a text to display and format it for display, also creating the pad * to hold it */ void renderText(); /* printInstructions * for floating panes, print out instruction lines that fit in the window * bounds - returns the next available row in the window to print on */ int printInstructions(int y, const char* inst); public: int x, y; // starting X & Y locations on screen int height, width; // size of pane (the outer window) /* constructor * Takes as input the upper left (Y,X) coord for the window, its number of * lines & columns, and the text for the titlebar */ pane(int starty, int startx, int lines, int cols, const char* title); /* resize * resize the window & pad, in the case of terminal resizing */ void resize(int starty, int startx, int lines, int cols); /* setTitle * sets the title of the window & truncates if too long */ void setTitle(const char* newtitle); /* loadText * Loads text into the panel. */ void loadText(const char* stext); /* redraw * Update the window whenever there is a change to make. Optionally takes a * boolean that will refresh the outer window border */ void redraw(bool borders = false); /* pagination functions - move up or down a line or a page in the window */ void nextPage(); void scrollDown(); void scrollUp(); void prevPage(); /* toggleFocus * Toggles whether the pane has focus. Will refresh the window titlebar. */ void toggleFocus(); /* loadMenu * given an option list, create a menu and return the selected list index */ int loadMenu(starray opts); /* loadForm * given an array of strings, and an instruction line, create a form and * return the entered text - will return with starray.length = 0 if user * backs out */ starray loadForm(starray inputs, const char* secondinst); /* menuclean * given a menu, list of items, and number of items, unpost & free up * allocated memory */ void menuClean(MENU* menu, ITEM** items, int numitems); /* formClean * given a form, fields, and number of fields, free up allocated memory */ void formClean(FORM* form, FIELD** fields, int numfields); /* setModule * change the module associated with this pane - stores the module index * and switches the pane title to be something else */ void setModule(const char* newtitle, const char* newmod, int keytype); /* setKey * change the searchkey associated with this pane */ void setKey(const char* newkey); /* setSearch * set the search parameters stored in the modkey for this pane */ void setSearch(int type, const char* scope); /* getModkey * gets the modkey associated with this pane */ modkey getModkey(); }; #endif