#include #include #include "internal.h" #include "dialog.h" #include "../diajava/proto.h" class FIELD_CHECK_MULTI_VAL_STR: public FIELD_CHECK_MULTI{ int &numvar; int backup; char cvar; const int *vals; struct { int input; // Current position in window */ int scroll; // Amount of horizontal scrolling so far */ }x; SSTRING &bufstr; SSTRING buf; int optlen; /*~PROTOBEG~ FIELD_CHECK_MULTI_VAL_STR */ public: FIELD_CHECK_MULTI_VAL_STR (const char * _prompt, int &_var, SSTRING&_bufstr, const int _vals[], const char *_options[]); MENU_STATUS dokey (WINDOW *dialog, int key, FIELD_MSG&, bool&); void drawtxt (WINDOW *dialog, int offset, int start_line, int end_line); void gui_draw (int nof, SSTRINGS&); MENU_STATUS gui_get (int nof, const char *, const char *); void html_draw (int nof); int html_validate (int nof); void reload (const char *dianame, int nof); void restore (void); void save (void); void setcursor (WINDOW *dialog, int offset); /*~PROTOEND~ FIELD_CHECK_MULTI_VAL_STR */ }; PUBLIC FIELD_CHECK_MULTI_VAL_STR::FIELD_CHECK_MULTI_VAL_STR( const char *_prompt, int &_var, SSTRING &_bufstr, const int _vals[], // Value corresponding to the titles const char *_options[]) : FIELD_CHECK_MULTI (_prompt,cvar,_options), numvar(_var) ,bufstr(_bufstr) { backup = numvar; vals = _vals; reload(NULL,0); box.width += 20; x.input = x.scroll = 0; buf.setfrom(bufstr.get(),511); optlen = 0; for (int i=0; _options[i] != NULL; i++){ optlen += strlen(_options[i])+4+1; } } PUBLIC void FIELD_CHECK_MULTI_VAL_STR::save( ) { if (val == options.getnb()){ bufstr.setfrom(buf); } numvar = vals[(unsigned)val]; } PUBLIC void FIELD_CHECK_MULTI_VAL_STR::restore( ) { numvar = backup; FIELD_CHECK_MULTI::restore(); } PUBLIC void FIELD_CHECK_MULTI_VAL_STR::reload(const char *dianame, int nof) { int nbopt = options.getnb(); for (int i=0; iget(); char tmp[1000]; diagui_sendcmd (P_Radio,"R%d %d %d %s\n",nof,i,i==val ,diagui_quote(str,tmp)); } diagui_sendcmd (P_Radio,"R%d %d %d %s\n",nof,n,n==val,""); char tmp[1000]; diagui_sendcmd (P_String,"S%d %d %s\n",nof,10,diagui_quote(buf.get(),tmp)); diagui_sendcmd (P_End,"\n"); } PUBLIC MENU_STATUS FIELD_CHECK_MULTI_VAL_STR::gui_get(int nof, const char *, const char *) { val = atoi(diagui_getval('R',nof)); buf.setfrom(diagui_getval('S',nof)); return MENU_NULL; } PUBLIC FIELD_CHECK_MULTI *DIALOG::newf_chkm_str( const char *prompt, int &var, SSTRING &bufstr, const int vals[], // Value corresponding to the options const char *options[]) { FIELD_CHECK_MULTI *s = new FIELD_CHECK_MULTI_VAL_STR(prompt,var,bufstr,vals,options); add (s); return s; }