/* MNU.ULH (STD) -- User Language Menu Utilities */ /* MNU.ULH (STD) -- User Language Menue-Utilities */ /* // Copyright (c) 1995-2013 Bartels System GmbH, Muenchen // Author: Manfred Baumeister // Changes History: // rl (131029) RELEASED FOR BAE V8.0. // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091020) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (020207) ENHANCEMENT: // Introduced environment variable BAE_PARLIB for // database file name. // rl (011107) ENHANCEMENT: // Introduced output to standalone window in mnu_poptext. // rl (010626) RELEASED FOR BAE V5.0. // rl (000821) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // mb (980423) BUGFIX: // Changed call(UL_HLPPROD) to runulprog(UL_HLP_PROD). // rl (970929) RELEASED FOR BAE V4.0. // mb (970929) CHANGE: // Replaced hlp_prodinfo function by HLPPROD ULP call. // mb (970616) ENHANCEMENT: // Applied CAM View User Language support. // mb (970430) CHANGE: // Static function splitstring renamed to mnu_splitstring // in order to avoid conflicts when including mnu.ulh to // source code where a more general splitstring function // is defined. // mb (970326) BUGFIX/CHANGE: // bae_twsize calls replaced by new function bae_mtpsize. // mb (970121) CHANGE: // Applied new function err_intern from pop.ulh. // mb (960917) RELEASED FOR BAE V3.4. // mb (951103) ORIGINAL CODING. // // DESCRIPTION // // The definitions and declarations from include file mnu.ulh are // compatible with all User Language interpreter environments of // the Bartels AutoEngineer (i.e. Schematic Editor, Layout Editor, // Autoplacement, Neural Autorouter, CAM Processor, CAM View, and // Chip Editor, respectively). mnu.ulh provides advanced popup and // menu utilities such as text display menu, string query edit mask, // color setup menu, BAE product info popup, menu and/or user // interaction, etc. // // FUNCTIONS // // Menu system setup: // mnu_init -- Initialyze the menu module and get/set the menu colors // // Text popup features: // mnu_poptext -- Activate text display/edit popup menu // // Color setup management: // popcolorsetup -- Perform general color setup */ // Avoid multiple inclusion #ifndef INCLUDE_MNU #define INCLUDE_MNU // Includes #include "pop.ulh" // User Language popup utilities // Global data type definitions typedef struct { // Color item descriptor string name; // Color item name int curcol; // Current color int defcol; // Default color } CIL[]; // Color item list type //__________________________________________________________________ // Start library-specific source code #ifndef USELIB #ifndef LIBMNU // Compiler directives #define VARTABLEN // Activate variable tab length #undef VARTABLEN // Deactivate variable tab length // Data type definitions struct SBDES { // Scrollbar descriptor int orient; // Scrollbar orientation : // zero = horizontal // else = vertical int fpos, spos, epos; // Scrollbar position int barwidth; // Active scrollbar width int bn; // Scrollbar entry count struct { // Scrollbar entry descriptor int felem; // First element int lelem; // Last element string retstr; // Return string } bl[]; // Scrollbar entry list }; typedef struct { // Bookmark descriptor int line; // Line number int column; // Column number int talign; // Text alignment flag } BML[]; // Bookmark list type typedef struct { // Escape text descriptor int line; // Escape text line int spos; // Escape text start column string retstr; // Return string } ESCL[]; // Escape list element type // Globals static int MNU_INIT = 0; // Menu module initialyzed flag static string winstr; // Window display string static string winstrbuf; // Window display string buffer // Menu window size definitions #define MNU_MINROW 24 // Menu minimum row count #define MNU_MAXROW 40 // Menu maximum row count #define MNU_MINCOL 50 // Menu minimum column count #define MNU_MAXCOL 80 // Menu maximum column count static int MNU_STDROW = MNU_MINROW; // Menu standard row count static int MNU_STDCOL = MNU_MINCOL; // Menu standard column count #define SMW 22 // Submenu width #define SBW 3 // Scrollbar width #define COLBARWIDTH 3 // Popup color bar width #define COLBARHEIGHT 3 // Popup color bar height // Display item ids string DSPITM_SBON = M("Scrollbar aktiv" ,"Scrollbar On" ); string DSPITM_SBOFF = M("Scrollbar inaktiv" ,"Scrollbar Off" ); string DSPITM_PDBCK = M("Pulldown Untergrund","Pulldown Back" ); string DSPITM_PDSHD = M("Pulldown Schatten" ,"Pulldown Shade" ); string DSPITM_CMBCK = M("Farbmenu Untergrund","Color Setup Back" ); string DSPITM_CMSHD = M("Farbmenu Schatten" ,"Color Setup Shade"); string DSPITM_EMBCK = M("Maske Untergrund" ,"Edit Mask Back" ); string DSPITM_EMSHD = M("Maske Schatten" ,"Edit Mask Shade" ); string DSPITM_EMCRS = M("Maske Kursor" ,"Edit Mask Cursor" ); string DSPITM_BMON = M("Lesezeichen aktiv" ,"Bookmark On" ); string DSPITM_BMOFF = M("Lesezeichen inaktiv","Bookmark Off" ); // Color definitions #define COLBLACK 0 // Black color value #define COLWHITE 15 // White color value #define COLOR_BMON 4 // Active/deletable bookm. color #define COLOR_BMOFF 2 // Inactive/selectable bookm. color #define COLOR_MASKB 1 // Edit mask background color #define COLOR_MASKS 0 // Edit mask shade color #define COLOR_CURSOR 15 // Text edit cursor color #define COLOR_COLSETB 9 // Color setup background #define COLOR_COLSETS 1 // Color setup shade static int COLSBOFF = COLOR_SBOFF; // Cur. deact. scrollbar color static int COLSBON = COLOR_SBON; // Cur. activated scrollbar color static int COLPDBCK = COLOR_PDBACK; // Cur. pulldown background color static int COLPDSHD = COLOR_PDSHADE;// Cur. pulldown shade color static int COLBMOFF = COLOR_BMOFF; // Cur. bookmark colors static int COLBMON = COLOR_BMON; // Cur. bookmark colors static int COLEDTBCK = COLOR_MASKB; // Cur. edit mask backgr. color static int COLEDTSHD = COLOR_MASKS; // Cur. edit mask shade color static int COLCURSOR = COLOR_CURSOR; // Cur. cursor color static int COLCSETBCK = COLOR_COLSETB;// Cur. color setup backgr. color static int COLCSETSHD = COLOR_COLSETS;// Cur. color setup shade color static int curcolor; // Current color value // Key code definitions #define KEYBS 0x08 // Backspace key #define KEYLF 0x0a // Line feed key #define KEYCR 0x0d // Carriage return key #define KEYESC 0x1b // Escape key #define KEYDEL 0x7f // Delete key // Character definitions #define CHRESC '\003' // Escape character #define CHRNL '\n' // Newline character #define CHRTAB '\t' // Tabulator character // Format definitions #ifdef VARTABLEN #define DEFTABLEN 8 // Default tabulator length static int TABLEN = DEFTABLEN; // Current tabulator length #else #define TABLEN 8 // Default tabulator length #endif // Messages static string UPRPOPBOOKM = M("Lesezeichen setzen","Set Bookmark"); //__________________________________________________________________ // Menu system setup void mnu_init() /* // Initialyze the menu module and get/set the menu colors */ { // Set file access error handling mode fseterrmode(0); // Get the menu standard row/column count bae_mtpsize(MNU_STDCOL,MNU_STDROW); // Recalculate standard row count MNU_STDROW=((MNU_STDROW-1)/8)*8; // Ensure valid standard row count if (MNU_STDROWMNU_MAXROW) MNU_STDROW=MNU_MAXROW; // Recalculate standard column count MNU_STDCOL=((MNU_STDCOL-1)/8)*8; // Ensure valid standard column count if (MNU_STDCOLMNU_MAXCOL) MNU_STDCOL=MNU_MAXCOL; // Get/set the menu colors COLSBOFF=mnu_colorload(DSPITM_SBOFF,COLOR_SBOFF); COLSBON=mnu_colorload(DSPITM_SBON,COLOR_SBON); COLPDBCK=mnu_colorload(DSPITM_PDBCK,COLOR_PDBACK); COLPDSHD=mnu_colorload(DSPITM_PDSHD,COLOR_PDSHADE); COLBMOFF=mnu_colorload(DSPITM_BMOFF,COLOR_BMOFF); COLBMON=mnu_colorload(DSPITM_BMON,COLOR_BMON); COLEDTBCK=mnu_colorload(DSPITM_EMBCK,COLOR_MASKB); COLEDTSHD=mnu_colorload(DSPITM_EMSHD,COLOR_MASKS); COLCURSOR=mnu_colorload(DSPITM_EMCRS,COLOR_CURSOR); COLCSETBCK=mnu_colorload(DSPITM_CMBCK,COLOR_COLSETB); COLCSETSHD=mnu_colorload(DSPITM_CMSHD,COLOR_COLSETS); #ifdef VARTABLEN // Init the tabulator length TABLEN=DEFTABLEN; #endif // Set the menu module initialyzed flag MNU_INIT=1; } //__________________________________________________________________ // Text popup features string mnu_poptext(STRINGS el, int hadapt,int wadapt,int textalign,int selmode,int sboptional) /* // Activate text display/edit popup menu // Return value : // selected entry string or empty string on abort // Parameters : // STRINGS el : Text entry list // int hadapt : Popup height adaption flag // int wadapt : Popup width adaption flag // int textalign : Text alignment mode : // (<0) = left alignment // ( 0) = center alignment // (>0) = right alignment // int selmode : Text entry selection mode : // ( 0) = no text entry is selectable // else = ESC enclosed text is selectable // int sboptional : Scrollbar optional display flag */ { #define UL_HLPPROD "hlpprod" // ULP : Product Info string REPPOPPOS = M("Zeile %d Spalte %d","Line %d Column %d"); string REPSRCHITEM = M("Suchbegriff:","Search Item:"); string REPSRCHERR = M("Suchbegriff '%s' nicht gefunden.", "Search item '%s' not found."); string UPRPOPSMFCT = M("[Funktionen]","[Functions]"); string UPRPOPTOP = M("Zum Anfang","Go to top"); string UPRPOPBOT = M("Zum Ende","Go to bottom"); string UPRPOPSRCHF = M("Suchen vorwaerts...","Search forward..."); string UPRPOPSRCHB = M("Suchen rueckwaerts...","Search backward..."); string UPRPOPDUMPF = M("Ausgabe...","Output..."); string UPRPOPCLOSE = M("Schliessen","Close"); string UPRPOPSMOPT = M("[Optionen]","[Options]"); string UPRPOPTALFT = M("Text linksbuendig","Left align text"); string UPRPOPTACEN = M("Text zentriert","Center align text"); string UPRPOPTARGT = M("Text rechtsbuendig","Right align text"); string UPRPOPFADE = M("Menue ausblenden","Menu Fade Out"); string UPRPOPCOLOR = M("Farbeinstellungen","Color Setup"); string UPRPOPSMHLP = M("[Hilfe]","[Help]"); string UPRPOPHLPPI = M("Produktinformation","Product Information"); string ERRMENUDUMP = M("Menue-Dump fehlgeschlagen!", "Menu dump failure!"); int talign = textalign; // Text alignment mode double height; // Popup percentage height double width; // Popup percentage width double mlx,mly; // Popup window lower percentage double mux,muy; // Popup window upper percentage int CLMFCT; // Functions submenu start column int CLMOPT; // Options submenu start column int CLMHLP; // Help submenu start column int poprows; // Popup rows count int popcols; // Popup columns count int en = arylength(el);// Help text entry count STRINGS hl; // Dummy header list STRINGS iel; // Initial entry list int ien = 0; // Initial entry count ESCL escl; // Escape list int escn = 0; // Escape count struct SBDES vsb; // Vertical scrollbar struct SBDES hsb; // Horizontal scrollbar BML bml; // Bookmark list int bmn = 0; // Bookmark count int MAXBM; // Maximum bookmark count int currow; // Current text row int reqcols; // Requested columns count int curline = 0; // Current line number int curecol = 0; // Current entry start column string srchstr = ""; // Search string buffer string strbuf = ""; // String buffer int scol; // Start column buffer int reqsbv; // Vert. scrollbar request flag int reqsbh; // Horiz. scrollbar request flag int fh; // File handle (for popup dump) int abort = 0; // Abort flag int i; // Loop control variable // Check if "real" window display if (selmode==0 && textalign<0 && bae_dialclr()==0) { // Clear output string winstr=winstrbuf=""; for (i=0;i=0;i--) reqcols=maxint(reqcols,strlen(iel[i])); // Get the required popup rows count on request if (hadapt) poprows=maxint(MNU_MINROW,ien+3); // Get the required popup columns count on request if (wadapt) popcols=maxint(MNU_MINCOL,reqcols+SBW+1); // Calculate the popup height height=calcpopheight(poprows); // Calculate the popup width width=calcpopwidth(popcols); // Set the lower popup menu boundaries for center alignment mlx=(1.0-width)/2.0; mly=(1.0-height)/2.0; // Set the upper popup menu boundaries mux=mlx+width; muy=mly+height; // Display the popup menu // (for getting modified popup row/column counts) bae_popshow(poprows,popcols,mlx,mly,mux,muy); // Set the maximum bookmark count MAXBM=popcols-SBW; // Get the line count if (poprows-3<=0) // This is an internal error! err_intern("mnu_poptext"); // Init the required vertical/horizontal scrollbar space reqsbv=SBW; reqsbh=1; // Check if scrollbar optional display is required if (sboptional) { // Check if vertical scrollbar is required if (ien0) // Right align current entry list sprintf(strbuf,"%*s",reqcols,iel[i]); else // Assume left aligned entry strbuf=iel[i]; // Update the current entry start column if (curecol>0) strbuf=strextract( strbuf,curecol,curecol+popcols-reqsbv); // Display the current menu entry bae_poptext(currow,reqsbv,strbuf); // Increment the menu entry index i++; } // Display the selectable menu entries for (i=0;i=2+poprows-2-reqsbh) // Outta vertical display range continue; // Get the escape string start column scol=escl[i].spos; if (talign==0) scol+=(reqcols-strlen(iel[escl[i].line]))/2; else if (talign>0) scol+=reqcols-strlen(iel[escl[i].line]); // Ignore if outta horizontal display range if (scol-curecol>popcols || scol-curecol+strlen(escl[i].retstr)<0) continue; // Display selectable escape string strbuf=escl[i].retstr; if (curecol<=scol) popbutton( currow,reqsbv+scol-curecol,strbuf,1); else { bae_poptextchoice(currow,reqsbv, strextract(strbuf,curecol-scol, strlen(strbuf)),strbuf); } } // Display the submenu buttons popbutton(0,CLMFCT,UPRPOPSMFCT,1); popbutton(0,CLMOPT,UPRPOPSMOPT,1); popbutton(0,CLMHLP,UPRPOPSMHLP,1); // Display the current line and column number sprintf(strbuf,REPPOPPOS,curline+1,curecol+1); popbutton(0,popcols-strlen(strbuf),strbuf,0); // Display the bookmarks popbookmarks(1,popcols-bmn,bml,bmn,curline,curecol,talign); // Display the vertical scrollbar popscrollbar(vsb,curline,sboptional); // Display the horizontal scrollbar popscrollbar(hsb,curecol,sboptional); // Get and test the answer switch ((strbuf=bae_readtext("",MAXTEXTLEN))) { // Functions submenu activation request case UPRPOPSMFCT : // Display the functions pulldown submenu bae_popcolbar(1,CLMFCT+1,9,SMW+1+CLMFCT,COLPDSHD); bae_popcolbar(0,CLMFCT,8,SMW+CLMFCT,COLPDBCK); popbutton(0,CLMFCT,UPRPOPSMFCT,1); popbutton(2,CLMFCT+1,UPRPOPTOP,curline>0); popbutton(3,CLMFCT+1,UPRPOPBOT, curline!=vsb.bl[vsb.bn-1].felem); popbutton(4,CLMFCT+1,UPRPOPSRCHF,curline0); popbutton(6,CLMFCT+1,UPRPOPDUMPF,1); popbutton(7,CLMFCT+1,UPRPOPCLOSE,1); switch (bae_readtext("",MAXTEXTLEN)) { // Go to top request case UPRPOPTOP : curline=0; break; // Go to bottom request case UPRPOPBOT : curline=vsb.bl[vsb.bn-1].felem; break; // Search forward request case UPRPOPSRCHF : // Prompt for search item if ((strbuf=mnu_askstr(REPSRCHITEM, 5,CLMFCT+2,MAXTEXTLEN,srchstr))==UINPOPABORT || (srchstr=strbuf)=="") break; // Set search string pattern strbuf="*"+srchstr+"*"; // Search forward i=curline; while ((++i)=0 && !strmatch(iel[i],strbuf)) ; if (i>=0) curline=i; else if (!strmatch(iel[curline],strbuf)) { sprintf(strbuf,REPSRCHERR,srchstr); popupmessage( 1,6,CLMFCT+2,strbuf,"",""); } break; // Output/dump request case UPRPOPDUMPF : // Abort dump if BAE Demo if (BAE_Demo_check(1)) break; // Prompt for output file name // (exclude files with BAE system ext.) strbuf=""; if (bae_askfilename(strbuf,"-", M(DE_UPRPOPFILE,EN_UPRPOPFILE)) || strbuf=="") // Abort dump break; // Open the output file if ((fh=fopen(strbuf,1))==(-1)) { // Error dumping popup menu popupmessage(1,-1,-1, ERRMENUDUMP,strbuf,""); break; } // Check on center align request if (talign==0) // Center align entry list for (i=0;i0) // Right align entry list for (i=0;iien-1) curline=0; break; // Scroll up request case UPRPOPPGUP : if ((--curline)<0) curline=ien-1; break; // Scroll left request case UPRPOPLFT : if (curecol>hsb.bl[0].felem) curecol--; break; // Scroll right request case UPRPOPRGT : if (curecol=curline+poprows-3) break; if (currow>=curline && (strbuf==escl[i].retstr || strlen(strbuf)==MAXTEXTLEN && strmatch(escl[i].retstr,strbuf+"*"))) return(escl[i].retstr); } // Selection done break; } // Loop until abort } while (!abort); // Restore the popup area bae_poprestore(); // Return abort answer return(""); } // String routines static int mnu_splitstring(string s,STRINGS ssl,int ssn,ESCL escl,int escn) /* // Split string // Return value : // number of substrings // Parameters : // string s : Input string // STRINGS ssl : Substring list (to be updated) // int ssn : Substring count (to be updated) // ESCL escl : Escape list (to be updated) // int escn : Escape count (to be updated) */ { char c; // Character buffer int inesc = 0; // In escape sequence flag int i,j; // Loop control variables // Precheck the string if ((i=strlen(s))==0 || strscannext(s,"\t\n\003",0,1)>=i) { ssl[ssn++]=s; return(ssn); } // Get the substring list from string for (i=0,j=0; c=s[i++]; ) { // Test if newline if (c==CHRNL) { // End escape sequence if (inesc) { escl[escn-1].retstr=strextract( ssl[ssn-1],escl[escn-1].spos,j-1); inesc=0; } // Reset the current word if (j>0) j=0; // Ignore this character continue; } // Increment substring count if new substring if (j==0 && !inesc) ssl[ssn++]=""; // Test if escape if (c==CHRESC) { // Check if in escape sequence if (inesc) { // End escape sequence escl[escn-1].retstr=strextract( ssl[ssn-1],escl[escn-1].spos,j-1); inesc=0; } else { // Start escape sequence escl[escn].line=ssn-1; escl[escn].retstr=""; escl[escn++].spos=j; inesc=1; } // Do not display escape characters continue; } // Test if tabulator if (c==CHRTAB) { // Display tabulator while ((j+2) % TABLEN) ssl[ssn-1][j++]=' '; ssl[ssn-1][j++]=CHRTAB; continue; } // Store default character ssl[ssn-1][j++]=c; } // End escape sequence if (inesc) escl[escn-1].retstr=strextract( ssl[ssn-1],escl[escn-1].spos,strlen(ssl[ssn-1])-1); // Return the substring count return(ssn); } //__________________________________________________________________ // Popup primitive routines // Button routines static void popbutton(int row,int col,string str,int selmode) /* // Display popup text button // int row : Button row // int col : Button column // string str : Button display string // int selmode : Button select mode (0=not selectable) */ { // Evaluate the select mode if (selmode) // Display selectable text button bae_poptextchoice(row,col,str,str); else // Display non-selectable text button bae_poptext(row,col,str); } // Scrollbar routines static int buildscrollbar(struct SBDES sb,int orient, int fpos,int spos,int epos,int dispspace,int entrycnt) /* // Build some popup scrollbar // Return value : // zero if done or nonzero on error // Parameters : // struct SBDES sb : Scrollbar (to be created) // int orient : Scrollbar orientation // int fpos : Scrollbar first position // int spos : Scrollbar start position // int epos : Scrollbar end position // int dispspace : Available display space // int entrycnt : Display entries count */ { int sbsize; // Scrollbar size int ipers; // Items per scrollbar entry int bn; // Scrollbar entry count int i; // Loop control variable // Abort if no display space if (dispspace<1) return(-1); // Set scrollbar position sb.fpos=fpos; sb.spos=spos; sb.epos=epos; // Set and check the orientation if (sb.orient=orient) { // Vertical sbsize=epos-spos-1; } else { // Horizontal sbsize=epos-spos+1-2*SBW; } // Abort if no scrollbar space if (sbsize<=0) return(-1); // Check if only one scrollbar entry required if (sbsize==1 || entrycnt<=dispspace) { // Store only one scrollbar entry sb.barwidth=sbsize; sb.bn=1; sb.bl[0].retstr=(orient ? "[^|V] 0" : "[<|>] 0"); sb.bl[0].felem=0; sb.bl[0].lelem=entrycnt-1; // Done return(0); } // Init the items per scrollbar entry count ipers=1; // Get the undisplayed entry count i=entrycnt-dispspace; // Validate the items per scrollbar entry count while ((i+ipers-1)/ipers>sbsize-1) // Increment the items per scrollbar entry count ipers++; // Get the scrollbar entry count bn=1+(ipers+i)/ipers; // Get the bar width sb.barwidth=sbsize-bn+1; // Get the scrollbar entry list for (i=0;i] ")+itoa(i); sb.bl[i].felem=i*ipers; sb.bl[i].lelem=i*ipers+ipers-1; } // Ensure valid last scrollbar entry element sb.bl[bn-1].lelem=entrycnt-1; sb.bn=bn; // Done return(0); } static void popscrollbar(struct SBDES sb,int curidx,int sboptional) /* // Display popup scrollbar // Parameters : // struct SBDES sb : Scrollbar // int curidx : Current entry/index // int sboptional : Scrollbar optional display flag */ { int cr,cc; // Current row/column int rbw,cbw; // Selected row/column bar width int i; // Loop control variable // Evaluate orientation if (sb.orient) { // Display the page up button popbutton(sb.spos,sb.fpos-1, UPRPOPPGUP,curidx>sb.bl[0].felem); // Done if no scrollbar display required if (sboptional && sb.bn<=1) return; // Display the page down button popbutton(sb.epos,sb.fpos-1, UPRPOPPGDW,curidx1 && curidx>sb.bl[0].felem); // Display the scroll right button popbutton(sb.fpos,sb.epos-SBW+1, UPRPOPRGT,sb.bn>1 && curidx=sb.bl[i].felem && curidx<=sb.bl[i].lelem) { // Display activated scrollbar entry if (sb.bl[i].felem==sb.bl[i].lelem) bae_popcolbar(cr,cc,cr+rbw,cc+cbw,COLSBON); else bae_popcolchoice(cr,cc,cr+rbw,cc+cbw, COLSBON,sb.bl[i].retstr); // Update the current row/column cr=cr+rbw; cc=cc+cbw; } else // Display deactivated selectable scrollbar entry bae_popcolchoice(cr,cc,cr,cc, COLSBOFF,sb.bl[i].retstr); } } static int chkscrollbar(string chkstr,struct SBDES sb,int curidx) /* // Check if scrollbar activated // Return value : // nonzero if scrollbar activated or zero else // Parameters : // string chkstr : Check string // struct SBDES sb : Scrollbar // int curidx : Current entry/index */ { int i; // Loop control variable // Check on horizontal scroll request for (i=0;i=sb.bl[i].lelem) curidx=sb.bl[i].felem; else if (curidx>1; // Compare bookmarks if ((compres=line-bml[sidx].line)==0 && (compres=line-bml[sidx].line)==0 && (compres=talign-bml[sidx].talign)==0) // Ignore multiple entries return; // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Insert new bookmark to sorted bookmark list for (sidx=bmn;sidx>slb;sidx--) bml[sidx]=bml[sidx-1]; bml[slb].line=line; bml[slb].column=column; bml[slb].talign=talign; bmn++; } static void popbookmarks(int row,int col, BML bml,int bmn,int line,int column,int talign) /* // Display popup bookmarks // Parameters : // int row : Bookmark display start row // int col : Bookmark display start column // BML bml : Bookmark list // int bmn : Bookmark count // int line : Current line // int column : Current column // int talign : Current text alignment flag */ { int i; // Loop control variable // Display the bookmarks for (i=0;i. Beenden . Korrektur /", "Abort . Accept . Correct /"); string fieldstr = ""; // Edit field buffer int editmax = sc+1+maxlen; // Edit field max. column int editcol; // Current edit column char keycode; // Key code buffer int abort = 0; // Abort flag int i; // Loop control variable // Get popup columns count i=maxint(maxlen+2,strlen(prompt)+2); // Initalize string cursor position editcol=sc+1+strlen(initstr); // Build full edit field length contents string sprintf(fieldstr,"%-*s",maxlen,initstr); // Init the mask popup menu bae_popcolbar(sr+1,sc+1,sr+4+1,sc+i+1,COLEDTSHD); bae_popcolbar(sr,sc,sr+4,sc+i,COLEDTBCK); bae_poptext(sr+1,sc+1,prompt); bae_poptext(sr+3,sc+1,fieldstr); bae_prtdialog(REPMASKHELP); // Do the key processing loop do { // Display cursor bae_popcolbar(sr+3,editcol,sr+3,editcol,COLCURSOR); // Get code of next pressed key switch (keycode=getchr()) { // Escape/abort case KEYESC : fieldstr=UINPOPABORT; abort=1; break; // Return/accept case KEYLF : case KEYCR : if (editcol-sc-2>=0) fieldstr=strextract(fieldstr,0,editcol-sc-2); else fieldstr=""; abort=1; break; // Backspace/delete case KEYBS : case KEYDEL : // Check if not already at string start if (editcol>sc+1) { // Move cursor editcol--; // Clear current and last string position fieldstr[editcol-sc-1]=' '; fieldstr[maxlen-1]=' '; } break; default : // Process printing characters if (isprint(keycode)) { // Store key code to field string fieldstr[editcol-sc-1]=keycode; // Adjust cursor position if (editcol<(editmax-1)) editcol++; } break; } // Display substring bae_poptext(sr+3,sc+1,fieldstr); // Loop until aborted } while (!abort); // Return field string return(fieldstr); } //__________________________________________________________________ // Color setup functions static void mnu_colorsetup(int sr,int sc,int maxr,int maxc) /* // Perform menu color setup // Parameters : // int sr : Popup start row // int sc : Popup start column // if sr or sc negative, init centered // popup and restore popup area afterwards // int maxr : Maximum available popup rows // int maxc : Maximum available popup columns */ { CIL cil = { // Color item list {DSPITM_SBON ,COLSBON ,COLOR_SBON }, {DSPITM_SBOFF,COLSBOFF ,COLOR_SBOFF }, {DSPITM_PDBCK,COLPDBCK ,COLOR_PDBACK }, {DSPITM_PDSHD,COLPDSHD ,COLOR_PDSHADE}, {DSPITM_CMBCK,COLCSETBCK,COLOR_COLSETB}, {DSPITM_CMSHD,COLCSETSHD,COLOR_COLSETS}, {DSPITM_EMBCK,COLEDTBCK ,COLOR_MASKB }, {DSPITM_EMSHD,COLEDTSHD ,COLOR_MASKS }, {DSPITM_EMCRS,COLCURSOR ,COLOR_CURSOR }, {DSPITM_BMON ,COLBMON ,COLOR_BMON }, {DSPITM_BMOFF,COLBMOFF ,COLOR_BMOFF } }; // Run the color setup menu popcolorsetup(1,sr,sc,maxr,maxc,cil); // Update the current menu colors COLSBON=cil[0].curcol; COLSBOFF=cil[1].curcol; COLPDBCK=cil[2].curcol; COLPDSHD=cil[3].curcol; COLCSETBCK=cil[4].curcol; COLCSETSHD=cil[5].curcol; COLEDTBCK=cil[6].curcol; COLEDTSHD=cil[7].curcol; COLCURSOR=cil[8].curcol; COLBMON=cil[9].curcol; COLBMOFF=cil[10].curcol; } void popcolorsetup(int saveallowed, int sr,int sc,int maxr,int maxc,CIL colitems) /* // Perform general color setup // WARNING : // Color item name lengths should NOT exceed 19/20 chars ! // Parameters : // int saveallowed : Activate color save to SQL DB feature // int sr : Popup start row // int sc : Popup start column // if sr or sc negative, init centered // popup and restore popup area afterwards // int maxr : Maximum available popup rows // int maxc : Maximum available popup columns // CIL colitems : Color item list */ { #define DBDEL "drop table MNUCOLTAB;" #define DBCRE "create table MNUCOLTAB (DSPITM string,COLVAL integer);" #define DBINS "insert into MNUCOLTAB values('%s',%d);" string REPCOLHD = M("Farbauswahl %s : " , "Color Selection %s : "); string UPRSELDISP = M("Anzeigeelement/Farbe waehlen!", "Select Display Item/Color!"); string UPRPOPEXIT = M("[Ende]" ,"[Exit]"); string UPRPOPREST = M("[Wiederherstellen]","[Restore]"); string UPRPOPSAVE = M("[Speichern]" ,"[Save]"); string UPRPOPDEFLT = M("[Default]" ,"[Default]"); int row = sr; // Popup start row int col = sc; // Popup start column double height; // Popup percentage height double width; // Popup percentage width double mlx,mly; // Popup window lower percentage double mux,muy; // Popup window upper percentage int poprows; // Popup row count int popcols; // Popup column count int currow; // Current popup row int curcol; // Current popup column int newcols[]; // New color list int cicnt; // Color item count int itemidx = 0; // Cur. selected display item int DISPITEMHALF; // Half display items count string blankstr = " "; // Blank string buffer string strbuf = ""; // String buffer int abort = 0; // Abort flag int i; // Loop control variable string DB = strgetconffilename(PARAMVNAME,PARAMFNAME,1); // SQL database file // Get color item count cicnt=arylength(colitems); // Get half diplay items count DISPITEMHALF=(cicnt+1)/2; // Init new color count for (i=cicnt-1;i>=0;i--) newcols[i]=colitems[i].curcol; // Set the popup rows and column counts poprows=10+DISPITEMHALF; popcols=(COLWHITE+1)*COLBARWIDTH+2; // Check if hierarchical positioning is required if (row>=0 && col>=0) { // Check if enough space if (poprows+1>maxr || popcols+1>maxc) // Not enough space row=col=(-1); else { // Center align vertically on request if (row+poprows+1>maxr) row=(maxr-poprows)/2; // Center align horizontally on request if (col+popcols+1>maxc) col=(maxc-popcols)/2; } } // Show the popup menu if (row<0 || col<0) { // Init the start row/column row=col=0; // Calculate popup height and width height=calcpopheight(poprows); width=calcpopwidth(popcols); // Set the popup boundaries mlx=(1.0-width)/2.0; mly=POPMIN; mux=mlx+width; muy=mly+height; // Show the popup menu bae_popshow(poprows,popcols,mlx,mly,mux,muy); } else { // Show the popup menu bae_popcolbar( row+1,col+1,row+poprows+1,col+popcols+1,COLCSETSHD); bae_popcolbar(row,col,row+poprows,col+popcols,COLCSETBCK); row++; } // Build the blank string sprintf(blankstr,"%*s",popcols-2,blankstr); // Run the color selection menu do { // Display blank string to clear previous header contents bae_poptext(row,col+1,blankstr); // Display the color menu header sprintf(strbuf,REPCOLHD,colitems[itemidx].name); bae_poptext(row,col+1,strbuf); curcol=strlen(strbuf); bae_popcolbar( row,col+curcol+1,row,col+curcol+2+1,newcols[itemidx]); // Build the color selection menu for (i=COLBLACK;i<=COLWHITE;i++) { curcol=i*COLBARWIDTH+1; bae_popcolchoice(row+2,col+curcol,2+COLBARWIDTH+row, COLBARWIDTH-1+col+curcol,i,itoa(i)); } // Display item texts and color buttons for (i=0;i=DISPITEMHALF) { currow-=DISPITEMHALF; curcol=col+25; } bae_popcolchoice(currow,curcol,currow,curcol+2, newcols[i],colitems[i].name); popbutton(currow,curcol+4,colitems[i].name,1); } // Init current row currow=row+8+DISPITEMHALF; curcol=col+1; // Display the exit button popbutton(currow,curcol,UPRPOPEXIT,1); curcol+=strlen(UPRPOPEXIT)+1; // Display the restore button popbutton(currow,curcol,UPRPOPREST,1); curcol+=strlen(UPRPOPREST)+1; // Display the default button popbutton(currow,curcol,UPRPOPDEFLT,1); curcol+=strlen(UPRPOPDEFLT)+1; // Display the save button if (saveallowed) popbutton(currow,curcol,UPRPOPSAVE,1); // Get the menu selection switch (strbuf=bae_readtext(UPRSELDISP,MAXTEXTLEN)) { // Abort request case UINPOPABORT : // Restore popup area on request if (row<0 || col<0) bae_poprestore(); error_abort(); // Exit request case UPRPOPEXIT : case "" : abort=1; break; // Restore colors request case UPRPOPREST : for (i=0;i=COLBLACK && atoi(strbuf)<=COLWHITE) // Assign color to current item newcols[itemidx]=atoi(strbuf); } break; } // Loop until abort } while (!abort); // Restore popup area on request if (row<0 || col<0) bae_poprestore(); // Store the new colors for (i=0;i=COLBLACK && curcolor<=COLWHITE) ? curcolor : defcolor); } static int sqlcolfunc(string dstr,int dint,double ddbl, int dval,int dtype,string dtable,string dfield,int didx) /* // SQL color table callback function // Return value : // zero if done or (-1) on data error // Parameters : // string dstr : String/Date data // int dint : Integer/Boolean data // double ddbl : Float data // int dval : Data valid flag // int dtype : Data type // string dtable : Data table name // string dfield : Data field name // int didx : Data output field index */ { // Check data field if (dfield=="COLVAL") // Set current color value curcolor=dint; // Return without errors return(0); } //__________________________________________________________________ // End library-specific source code #endif // LIBMNU #endif // USELIB // Conditional file inclusion end #endif // INCLUDE_MNU // User Language include file end