DEFINITION MODULE useri; (* aprsmap user interface *)

FROM SYSTEM IMPORT CARD16, CARD8;
FROM maptool IMPORT pIMAGE;
FROM aprsstr IMPORT TIME, POSITION;
FROM aprsdecode IMPORT DAT, MONCALL, COLTYP, CLICKOBJECT;

CONST CURSDOWN=CHR(24);
      CURSLEFT=CHR(19);
      CURSUP=CHR(5);
      CURSRIGHT=CHR(4);
      CURSDEL=CHR(127);
      CURSBS=CHR(8);
      CURSENTER=CHR(13);
      CURSPAGEUP=CHR(18);
      CURSPAGEDOWN=CHR(3);
      CURSHOME=CHR(1);
      CURSEND=CHR(2);
      CURSINS=CHR(15);
      CURSPASTE=CHR(22);
      CURSCLRLINE=CHR(11);
(*    CURSF11=CHR(11);*)


      CMDRDLOG=216C;
      CMDFOLLOW="L";
      CMDDOWNLOAD=237C;
      CMDSTARTDOWNLOAD=242C;
      CMD1USER=".";
      CMD1USERRF="=";
      CMDANIMATE1="a";
      CMDANIMATEMENU="v";
      CMDDELWAYPOINT="q";
      CMDINTERNSTAT="I";
      CMDMH="h";
      CMDFIND=245C;
      CMDZOOMSQUARE=307C;
      CMDFZOOMIN=310C;
      CMDFZOOMOUT=311C;
      CMDVIDEO=312C;
      CMDCENTER=313C;
      CMDSETMARK1LOCK=314C;
      CMDSETMARK2LOCK=315C;
      CMDCENTERMOUSE="c";
      CMDLISTWINLINE="t";
      CMDRADIORANGE=22C;
      CMDCLICKWATCH=322C;
      CMDRESETIMGPARMS=14C;
      CMDZOOMTOMARKS="/"; 
      CONFPOISYMFIND=335C;
      CFGHEARD="H";
      CFGRAWDECODED="u";
      SCREENSHOT="S";
(*
      SCREENSHOT=020C;
*)
      DIRECTCONF="!";                      (* enter config line *)
      DEFAULTLUMOBJ="90";
      MULTILINEDEL=1;                                (* subknob *)   
      cMULTISYMBOL="*";                              (* if this ose symbol set *)   
      SP1=360C;                                      (* micospaces for menu text *)
      SP2=361C;
      SP3=362C;
      SP4=363C;
      SP5=364C;
      SP6=365C;
      SP7=366C;
      SP8=367C;
      SP9=370C;
      SPS=371C;

      TILEGAMMA=0.45;                                (* make gamma off *)

      MINMHZ=0.1;
      ALTINVAL=-1000000;
      DOCKX=-3;
      BRIMUL=10;                                     (* lums percent to 0..1000 *)
      MAXANTALT=50000000;                            (* max antenna higth m *)
TYPE

     MOUSEPOS=RECORD x, y:INTEGER END;
     CONFSET=(fFIND,fLOGWFN,fLOGDAYS,fLOGFN,fLOGDATE,fLOGFIND,fFOTOFN,fDIRECTCONF,fXYSIZE,
               fMYCALL,fMYPOS,fPOIFILTER,fPOISMBOLS,
               fNBTEXT,fMYSYM,fNETBTIME,fRFBTSHIFT,
               fRBTEXT,fRBTYP, fRBNAME, fRBSYMB, fRBPOS, fRBPOSTYP, fRBALT,
               fRBSPEED, fRBDIR, fRBCOMMENT, fRBTIME, fRBPORT, fRBPATH, fRBDEST, 
               fSERIALTASK, fSERIALTASK2, fSERVERURL, fSERVERFILT, fPW,
               fCONNECT,fALLOWNETTX,fALLOWGATE,
               fUDP1,fUDP2,fUDP3,fUDP4,
               fDIGI, fMENUXYDIGI, fDIGITIME, fDIGIRADIUS, fDIGIVIA, fDIGINN, fDIGIX, 
               fVIDEOCMD, fOSMDIR,fTFADE,fTFULL,fTPURGE, fTPURGEOBJ, fDELAYGETMAP,
               fTRANSP,fLWAY,fLTEXT,fLSYM,fLTRACK,fLOBJ,fLMAP,fLRF,fNOMOV,fCENTER,fGAMMA,
               fALLOWEXP,fZOOMMISS,fMOUSELOC,fMAPNAMES,
               fTRACKFILT,fDUPDEL,fARROW,fINVMOV,fKMH,fKMHTIME,fTEMP,fWINDSYM,fRULER,fOBJTRACK,
               fALTMIN,
               fONESYMB,
               fDEFZOOM,fANIMSPEED,fVIDEOFAST,
               fVIEW,fMAXZOOM,fDOWNLOADZOOM,fGETMAPS,fFONTSIZE,fMARKPOS,
               fMOVESTEP,fZOOMSTEP,fCLICKMAP,fCLICKSYM,fCLICKWXSYM,
               fCLICKTEXT,fCLICKTRACK, fHOVERSET,
               fMSGRFDEST,fMSGNETDEST,fMSGPATH,fPOPUPMSG,fMSGALLSSID,fPASSSELFMSG,
               fWRINCOM,fWRTICKER,
               fLOCALTIME,fQUERYS,
               fSTRFILT,fOBJSRCFILT,fIGATEFILT,fOPFILT,fDESTFILT,fRAWFILT,fFINGERPRINT,
               fMUSTBECALL,
               fGEOPROFIL, fGEOBRIGHTNESS, fGEOCONTRAST,
               fREFRACT, fFRESNELL, fANT1, fANT2, fANT3,
               fSRTMCACHE,
               fPANOSIZE, fPANOPOS,
               fBEEPPROX,fBEEPWATCH,fBEEPMSG,
               fMSGTO,fMSGTEXT,fMSGPORT,fAUTOSAVE,fWATCH,fAPPROXY,
               fMENUXYEDIT,fMENUXYMSG,fMENUXYBEACON,fMENUXYSTATUS,fMENUXYLIST,
               fMENUXYLISTMIN,fMENULISTICON,fMENUSIZELIST,fMENUMONICON,fMENUXYMON,
               fMENUSIZEMON,
               fCOLMAPTEXT, fCOLOBJTEXT, fCOLMENUTEXT, fCOLMENUBACK, fCOLMARK1, fCOLMARK2,
               fTIMESTAMP,
               fFOLLOW,
               fEDITLINE);



VAR newxsize, newysize:CARDINAL;
    xmouse:MOUSEPOS;
    listwin:CHAR;
    debugmem:RECORD menus, mon, screens, req, poi:CARDINAL END;  
    beaconediting,
    reloadmap,
    refresh,
    beaconed,
    maximized,
    isblown:BOOLEAN;
    nextmsg:INTEGER;
    panoimage:pIMAGE;

PROCEDURE mainpop;
PROCEDURE textautomenu(x0, y0:INTEGER; id:CARDINAL; time:TIME; color:CHAR; s, mtext, cmd:ARRAY OF CHAR);
PROCEDURE textautosize(x0, y0:INTEGER; id:CARDINAL; time:TIME; color:CHAR; s:ARRAY OF CHAR);
PROCEDURE say(s:ARRAY OF CHAR; time:TIME; color:CHAR);
PROCEDURE killallmenus;
PROCEDURE killmenuid(id:CARDINAL);
PROCEDURE loadconfig(verb:BOOLEAN);
PROCEDURE saveconfig;
PROCEDURE postoconfig(pos:POSITION);
PROCEDURE rdlums;
PROCEDURE xerrmsg(s:ARRAY OF CHAR);
PROCEDURE redraw(img:pIMAGE);
PROCEDURE mouseleftdown(mousx, mousy:INTEGER);
PROCEDURE mouserightdown(mousx, mousy:INTEGER);
PROCEDURE keychar(ch:CHAR; ispasted, movecmd:BOOLEAN);
PROCEDURE resizewin(newx, newy:INTEGER; f11:BOOLEAN);
PROCEDURE mousemove(x, y:INTEGER);
PROCEDURE initmenus;
PROCEDURE timerevent;
PROCEDURE refreshwin;
PROCEDURE mouserelease;
PROCEDURE mousemiddle(x, y:INTEGER);
PROCEDURE downloadprogress;
PROCEDURE wrheap;
PROCEDURE sayonoff(s:ARRAY OF CHAR; on:BOOLEAN);
PROCEDURE getview(v:CONFSET; n:CARDINAL; VAR zoom:REAL; VAR pos:POSITION);
PROCEDURE refrinfo;
PROCEDURE localtime():TIME;
PROCEDURE refrlog;
PROCEDURE conf2int(v:CONFSET; valnum:CARDINAL; min, max, default:INTEGER):INTEGER;
PROCEDURE conf2real(v:CONFSET; valnum:CARDINAL; min, max, default:REAL):REAL;
PROCEDURE confstr(v:CONFSET; VAR s:ARRAY OF CHAR);
PROCEDURE conf2str(v:CONFSET; linenum, valnum:CARDINAL; all:BOOLEAN; VAR s:ARRAY OF CHAR);
PROCEDURE confstrings(v:CONFSET; lineno:CARDINAL; all:BOOLEAN; VAR s:ARRAY OF CHAR);
PROCEDURE confflags(v:CONFSET; lineno:CARDINAL):CARD8;
PROCEDURE confappend(v:CONFSET; VAR s:ARRAY OF CHAR);
PROCEDURE configbool(v:CONFSET; on:BOOLEAN);
PROCEDURE configon(v:CONFSET):BOOLEAN;
PROCEDURE AddConfLine(v:CONFSET; act:CARD8; s:ARRAY OF CHAR);
PROCEDURE setcfg(v:CONFSET; n:INTEGER; s:ARRAY OF CHAR; act:CARD8);
PROCEDURE clrconfig;
PROCEDURE starthint(num:CARDINAL; center:BOOLEAN);
PROCEDURE Setmap(n:CARDINAL);
PROCEDURE helptext(line, sub, xclick, yclick:CARDINAL; idx:ARRAY OF CHAR); 
PROCEDURE pulloff;
PROCEDURE saveXYtocfg(c:CONFSET; x, y:INTEGER);
PROCEDURE clrmsgtext(to:ARRAY OF CHAR);
PROCEDURE getstartxysize(VAR newx, newy:INTEGER);
PROCEDURE wrstrlist(s:ARRAY OF CHAR; opcall:MONCALL; pos:POSITION; t:TIME);
PROCEDURE wrstrmon(s:ARRAY OF CHAR; pos:POSITION);
PROCEDURE clrcpmarks;
PROCEDURE copypaste(s:ARRAY OF CHAR);
PROCEDURE isupdated(v:CONFSET):BOOLEAN;
PROCEDURE guesssize(fn:ARRAY OF CHAR; VAR lenstr:ARRAY OF CHAR):INTEGER;     (* return filsize in kb not exact >2gb *)
PROCEDURE ColConfset(VAR c:COLTYP; v:CONFSET);
PROCEDURE gpsalt(a:CONFSET):BOOLEAN;
PROCEDURE textbubble(pos:POSITION; s:ARRAY OF CHAR; last:BOOLEAN);
PROCEDURE killbubble;
PROCEDURE popwatchcall(s:ARRAY OF CHAR);
PROCEDURE allocimage(VAR image:pIMAGE; x, y:INTEGER; save:BOOLEAN);
PROCEDURE mainys():CARDINAL;
PROCEDURE rdonesymb(on, say:BOOLEAN);
PROCEDURE hoverinfo(obj:CLICKOBJECT);
PROCEDURE int2cfg(cfg:CONFSET; v:INTEGER);
PROCEDURE resetimgparms;
PROCEDURE poligonmenu;
PROCEDURE Tilegamma(gamma:REAL);
PROCEDURE mapbritocfg;
PROCEDURE findopl(where:CARDINAL);
PROCEDURE anywatchfollow():BOOLEAN;
PROCEDURE DoDirectConf;

END useri.
