/* POP.ULH (STD) -- User Language Popup Utilities */ /* POP.ULH (STD) -- User Language Popup-Utilities */ /* // Copyright (c) 1994-2013 Bartels System GmbH, Muenchen // Author: Manfred Baumeister // Changes History: // rl (131125) ENHANCEMENT: // Added function dial_promptlabel. // rl (131029) RELEASED FOR BAE V8.0. // rl (120427) RELEASED FOR BAE V7.8. // rl (111130) ENHANCEMENT: // Added functions dial_lbddbentry/dial_lbddbclass. // rl (111114) ENHANCEMENT: // Added functions dial_getboxsize/dial_getboxsizemin. // rl (110110) ENHANCEMENT: // Added popup menu contents edit function. // 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 (070125) ENHANCEMENT: // Added permanent dialog box management definitions. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (050420) ENHANCEMENT: // Introduced dialog box creation support functions. // rl (040811) RELEASED FOR BAE V6.4. // rl (040729) ENHANCEMENT: // Introduced dialog box support for popupmulmenu. // rl (030929) BUGFIX: // Fixed problem with blanks in file names. // rl (030904) RELEASED FOR BAE V6.2. // rl (030210) BUGFIX: // Fixed problem with upper case project file name. // rl (021209) RELEASED FOR BAE V6.0. // rl (021119) CHANGE: // Changed ddbclassname function to support new DDB classes. // rl (020618) RELEASED FOR BAE V5.4. // rl (020507) ENHANCEMENT: // Introduced dialog box support for popupmenu. // rl (010709) RELEASED FOR BAE V5.0. // rl (010625) CHANGE: // Added UINPOPABORT return in popupmenu to avoid flickering // on abortion of cascaded popup selections. // rl (010625) RELEASED FOR BAE V5.0. // rl (010613) BUGFIX: // Fixed default element name display problem in loadddbelem. // rl (010206) ENHANCEMENT: // Improved pattern recognition in popupmulmenu function. // rl (010118) ENHANCEMENT: // Added file name list wildcard case insensivity. // rl (000814) RELEASED FOR BAE V4.6. // rl (000814) ENHANCEMENT: // Added empty line compression in popupmenu for small windows. // mb (000723) CHANGE: // Added selected entry count parameter to popupmulmenu function. // rl (000504) ENHANCEMENT: // Introduced dialog box definitions. // rl (000221) ENHANCEMENT: // Introduced popupmulmenu function. // rl (991126) RELEASED FOR BAE V4.4. // rl (990817) CHANGE: // Output file selection dialogs to display "Save" // confirmation button. // rl (990506) ENHANCEMENT: // Introduced class DDBCLRULL in ddbclassname. // rl (990119) CHANGE: // Introduced abort on escape in popupelem. // mb (981002) RELEASED FOR BAE V4.2. // mb (980917) CHANGE: // New popup message function M_REPDMPDONE. // New messaging functions M_REPPOPDIR, M_REPPOPDIRHD. // New messaging functions M_REPSCANDDB, M_REPSCANDIR. // Obsolete definitions skipped. // rl (980901) ENHANCEMENT: // Introduced class DDBCLLDRC in ddbclassname. // mb (980822) CHANGE: // BAE_Demo_check message modified. // mb (980822) ENHANCEMENT: // popupmessage and verify to apply new bae_msgbox* functions. // rl (980821) ENHANCEMENT: // Introduced class DDBCLCCHG in ddbclassname. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (970703) IMPROVEMENT: // popupmessage to continue on mouse-click. // mb (970615) CHANGE: // Applied new UL system function filetype for directory check. // mb (970611) CHANGE: // Applied new UL system function ddbcheck, ddbclassid // wherever appropriate. // mb (970326) BUGFIX/CHANGE: // bae_twsize calls replaced by new function bae_mtpsize. // mb (970117) CHANGE: // Function selectfile renamed to askfile. // New function err_intern implemented. // mb (970113) BUGFIX/CHANGE: // Local variable fname in function isdirectory initialyzed. // mb (961026) IMPROVEMENT: // Element load done message with DDB type, element name, // and file name display introduced to loadddbelem // function on successful load. // mb (960927) RELEASED FOR BAE V3.4. // mb (960927) IMPROVEMENT: // Function popupelem to return read string length for // proper popup item query with bae_readtext; popupmenu // to use read text length returned from popupelem for // subsequent bae_readtext queries. // mb (960731) ENHANCEMENT: // Introduced DDB class 402 (Parameter Setup Data). // mb (960614) ENHANCEMENT: // Value other than 0 or 1 for sortmode parameter in // filelist function to cause standard name sort // (instead of numeric sort as with 1). // mb (951012) ENHANCEMENT: // Introduced function BAE_Demo_check, optionally issuing // BAE Demo output disabled message and/or aborting program. // Applied BAE_Demo_check in popupdump. // mb (951012) ENHANCEMENT: // Utilized popupmessage in popupdump for issuing // popup dump done message. // mb (951011) ENHANCEMENT: // Introduced function popupmessage for message // popup display. // mb (950922) ENHANCEMENT: // Expanded dirprec parameter of filelist function in // order to support blank-separated dir name append for // sort by file name (negative dirprec value) instead of // dir name precede for sort by dir name (positive dirprec // value) or dir name fade-out (zero dirprec value). // mb (950913) ENHANCEMENT: // Introduced new extexclude parameter to selectfile. // Introduced new dumpfname parameter to functions // popupmenu and popupelem. Introduced (Dump) button // to popup menu functions. Introduced function popupdump. // mb (950911) ENHANCEMENT: // New select mode option 4 for select enable/single column // introduced to popupelem/popupmenu functions. // Introduced (Back) button to popup menu functions. // mb (95) RELEASED FOR BAE V3.2. // mb (941202) ENHANCEMENT: // Introduced verify (with quit) option to // popupmenu, popupelem. // mb (950208) NEW: // Introduced isdirectory function for path name check. // Introduced filelist function for multi-purpose // directory scan. // mb (950208) ENHANCEMENT: // Introduced advanced dir/file/element selection features // utilizing new bae_ask*name UL system functions. // mb (950222) IMPROVEMENT: // Utilized bae_askdirname and new scandirfnames // directory scan features in order to provide most // powerful directory scan and select features with // selectfile. // mb (94) RELEASED FOR BAE V3.0. // mb (94) ORIGINAL CODING. // // DESCRIPTION // // The definitions and declarations from include file pop.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). pop.ulh provides advanced popup // utilities and definitions for BAE software configuration query, // menu-driven file and element selection, directory list generation, // popup message handling, menu and/or user interaction, etc. // // FUNCTIONS // // Messaging functions: // M_REPDMPDONE -- Display dump done message // M_REPPOPDIR -- Directory popup header generator // M_REPPOPDIRHD -- Directory/type popup header generator /// M_REPSCANDDB -- DDB file scan in progress message generator // M_REPSCANDIR -- Directory scan in progress message generator // // Popup menu management: // calcpopheight -- Calc. popup height percentage for popup rows count // calcpopwidth -- Calc. popup width percentage for popup columns count // oldstylepopupmenu -- Perform an old style popup menu activation // popupmenu -- Perform a popup menu activation // popupmessage -- Display a message popup with up to three messages // popupmulmenu -- Perform a popup menu activation with multi el. selection // verify -- Prompt user for verification with yes or no // // Dialog box creation: // dial_dist -- Create right aligned positive dist. input box, adjust row // dial_distpar -- Right aligned labeled pos. dist. input box, adjust row // dial_double -- Create right aligned pos. double input box, adjust row // dial_doublepar -- Right aligned labeled pos. double input box, adj. row // dial_hsep -- Create full width horizontal seperator, adjust row // dial_label -- Create label // dial_paramlabel -- Create parameter prompt label // dial_cliplabel -- Create label with clipboard copy functionality // dial_namestring -- Create right aligned name string input box, adj. row // dial_namestringpar -- Right aligned lab. name string input box, adj. row // dial_npatstring -- Create right aligned name pattern input box, adj. row // dial_npatstringpar -- Right aligned lab. name pat. input box, adj. row // dial_okabort -- Create left aligned OK and abort buttons, adjust row // dial_okabortini -- Create OK, abort and INI save buttons, adjust row // dial_action -- Create action button adjust column // dial_lbddbclass -- Add all DDB elements of given class to list box // dial_lbddbentry -- Add commented DDB element list box entry // dial_sbentry -- Add standard selection box entry // dial_selbox -- Create right aligned selection box start, adjust row // dial_selboxpar -- Right aligned labeled selection box start, adjust row // dial_string -- Create right aligned string input box, adjust row // dial_stringpar -- Right aligned labeled string input box, adjust row // dial_tabend -- Store a tab control terminator // dial_tabgroup -- Store a tab control group seperator // dial_toggle -- Create toggle box // dial_getboxsize -- Get dialog box size // dial_getboxsizemin -- Get dialog box size with min. size check // dial_getdouble -- Get dialog box double parameter value // dial_getint -- Get dialog box integer parameter value // dial_getstr -- Get dialog box string parameter value // // General file access: // filelist -- Scan dir and store dir. and/or file names to name list // askfile -- Menu-driven select a file name among those with extensions // // DDB file access: // askddbfile -- Perform DDB file selection with popup menu // loadddbelem -- Load DDB element with extended error handling // verifysave -- Save currently loaded unsaved element with verify // // Message and error handling: // BAE_Demo_check -- Check if currently running in BAE Demo software // err_intern -- Issue internal error message and exit from program */ // Avoid multiple inclusions #ifndef INCLUDE_POP #define INCLUDE_POP // Includes #include "std.ulh" // User Language standard include // Messages #define UINNO "n" #define DE_UPRPOPFILE "!Popup-Dump Ausgabedatei Name ? " #define EN_UPRPOPFILE "!Popup Dump Output File Name ? " #define DE_UPRPOPBACK "(Zurueck)" #define EN_UPRPOPBACK "(Back)" #define DE_UPRPOPABORT "(Abbruch)" #define EN_UPRPOPABORT "(Abort)" #define DE_UPRBAEINISAV "Defaults Speichern" #define EN_UPRBAEINISAV "Save Defaults" #define DE_UPRBAEINITIP "Diese Einstellungen als Default in bae.ini eintragen" #define EN_UPRBAEINITIP "Save settings of this dialog box as default to bae.ini" // INI file parameter name definitions #define PAR_DIALXMAX "DIALOGXMAX_STD"// Dialog box max. width #define PAR_DIALYMAX "DIALOGYMAX_STD"// Dialog box max. height #define PAR_CLASSCHK "CLASSCHECK_STD"// Class check #define PAR_MODALBOX "MODALBOX_STD" // Modal dialog tool boxes flag #define PAR_METYPSCAN "METYPSCAN_STD" // Menu element type scan flag // Color values #define COLOR_SBON 7 // Active scrollbar entry color #define COLOR_SBOFF 8 // Inactive scrollbar entry color #define COLOR_PDBACK 1 // Pulldown menu background color #define COLOR_PDSHADE 0 // Pulldown menu shade color // BAE popup menu definitions #define POPBUTSPC 10 // Popup button spacing width #define POPMIN 0.1 // Popup lower range minimum #define POPMAX 1.0-POPMIN // Popup upper range maximum // Popup button definitions #define REPPOPBUTHD "> " #define BUTHDLEN 2 #define UPRQUITLEN 12 #define UPRPOPPGUP "[^]" #define UPRPOPPGDW "[V]" #define UPRPOPLFT "[<]" #define UPRPOPRGT "[>]" #define UINPOPCONT "?" #define UINPOPQUIT "q" #define UINPOPOK "\004" #define UINPOPABORT "\003" #define UINPOPDIR "\002" // Dialog box parameter type codes #define PA_STR 0x00000000 // String parameter #define PA_BOOL 0x00000001 // Switch parameter #define PA_INT 0x00000002 // Integer parameter #define PA_DBL 0x00000003 // Float parameter #define PA_LAB 0x00000004 // Label parameter #define PA_HSEP 0x00000005 // Horizontal seperator parameter #define PA_VSEP 0x00000006 // Vertical seperator parameter #define PA_RBF 0x00000007 // Radio box first parameter #define PA_RBN 0x00000008 // Radio box next parameter #define PA_SB 0x00000009 // Selection box base parameter #define PA_SBE 0x0000000A // Selection box entry parameter #define PA_ACT 0x0000000B // Action button #define PA_OK 0x0000000C // OK button #define PA_ABORT 0x0000000D // Abort button #define PA_NIL 0x0000000E // Dummy element #define PA_LB 0x00010000 // List box base parameter #define PA_LBE 0x00010001 // List box entry parameter #define PA_BMLAB 0x00010002 // Bitmap label parameter #define PA_BMACT 0x00010003 // Bitmap action button parameter #define PA_TOGGLE 0x00010004 // Toggle button parameter #define PA_MULLB 0x00010005 // Multiple sel. list box base param. #define PA_LV 0x00010006 // List view base parameter #define PA_TABCTRL 0x00010007 // Tab control base parameter #define PA_TABGRP 0x00010008 // Tab control group marker #define PA_SIGN 0x00000010 // Signed parameter #define PA_DIST 0x00000020 // Distance parameter #define PA_ANGLE 0x00000040 // Angle parameter #define PA_CHKNAME 0x00000080 // Check name characters #define PA_CHKNPAT 0x00000100 // Check name pattern characters #define PA_TAB 0x00000200 // Tab char. allowed parameter #define PA_CHKLL 0x00000080 // Check lower param. bound. #define PA_CHKUL 0x00000100 // Check upper param. bound. #define PA_CHKLI 0x00000200 // Check lower param. immediately #define PA_CHKUI 0x00000400 // Check upper param. immediately #define PA_NILSTR 0x00000800 // NIL string display field #define PA_FNTBOLD 0x00001000 // Bold typeface font #define PA_FNTFIX 0x00002000 // Fixed width font #define PA_OKSEL 0x00004000 // Double click selects OK flag #define PA_NOEDIT 0x00008000 // Edit disabled flag #define PA_IMDSEL 0x00100000 // Single click selects OK flag #define PA_MULCOL 0x00200000 // Multi column list box flag #define PA_HSCROLL 0x00400000 // Horizontal scroll bar flag #define PA_VSCROLL 0x00800000 // Vertical scroll bar flag #define PA_HBRDREL 0x01000000 // Dimension hor. border rel. flag #define PA_VBRDREL 0x02000000 // Dimension vertical border rel. flag #define PA_TYPMASK 0x000F000F // Parameter type mask #define PA_MCALLBACK 0x04000000 // Mark callback function flag #define PA_SCALLBACK 0x08000000 // Selection callback function flag #define PA_GRAYED 0x10000000 // Grayed/disabled flag #define PA_FOCUS 0x20000000 // Initial focus flag #define PA_INVISIBLE 0x40000000 // Invisible flag #define PA_MODALBOX 0x00010000 // Modal dialog box ID offset #define PA_NILVAL "\001" // NIL string value // Dialog box definitions #define DIAL_BASE 0x01 // Base dialog box items support #define DIAL_LIST 0x02 // List view dialog box item support #define DIAL_PROGRESS 0x04 // Progress dialog box support #define DIAL_BUTTON 0x08 // Toolbar button support #define DIAL_TREE 0x10 // Tree view dialog box item support #define DIAL_TABCTRL 0x20 // Tab control dialog box item support #define DIAL_TXTVSTEP 0.6 // Pure text vertical step #define DIAL_SEPVSTEP 0.4 // Separator vertical step #define DIAL_CTRVSTEP 1.0 // Input element vertical step #define DIAL_BUTVSTEP 1.2 // Button vertical step #define DIAL_BUTHEIGHT 0.75 // Default button height #define DIAL_BUTWIDTH (DIAL_BUTHEIGHT*30.0/8.0) // Default button width #define DIAL_BMPBUTHO 2.0 // Bitmap button horizontal oversize #define DIAL_BMPBUTVO 0.5 // Bitmap button vertical oversize #define DIAL_TOPMARG 0.0 // Dialog box top margin #define DIAL_BOTMARG 0.0 // Dialog box bottom margin #define DIAL_BOTEMARG 2.2 // Dialog box bottom element margin #define DIAL_BOTSMARG 2.0 // Dialog box bottom seperator margin #define DIAL_LEFTMARG 0.0 // Dialog box left margin #define DIAL_RIGHTMARG 0.0 // Dialog box right margin #define DIAL_RIGHTEMARG 2.7 // Dialog box right element margin #define DIAL_RIGHTSMARG 1.7 // Dialog box right seperator margin #define DIAL_RIGHTTMARG 2.0 // Dialog box tab control right margin #define DIAL_TABROFF 5.0 // Dialog box tab control right off. // Permanent dialog box definitions #define DIALBOXMAX 10 // Max. dialog box count #define VAR_PDBOXSEQ "pdboxseq%d" // Dialog box callback sequence #define VAR_PDBOXMODE "pdboxmode%d" // Dialog box mode #define VAR_PDBOXIDX "pdboxidx" // Dialog box index #define VAR_PDBOXACT "pdboxaction" // Dialog box callback action code #define VAR_PDBOXREAS "pdboxreason" // Dialog box callback reason #define VAR_PDBOXIVAL "pdboxintval" // Dialog box callback integer value #define VAR_PDBOXNAME "pdboxname" // Dialog box callback item name #define VAR_PDBOXCALL "pdboxcall" // Dialog box caller index #define PDBOXLOADDIS 1 // Box dismiss on element load bit #define PDBOXZOOMUPD 2 // Box update on zoom/color change bit #define PDBOXLOADUPD 4 // Box update on element load bit #define PDBOXPLCUPD 8 // Box update on reference placement bit // Progress bar definitions #define PB_TYPMASK 0xFF // Progress bar type mask #define PB_TYPPERC 0x01 // Progress bar percent count type #define PB_TYPPROC 0x02 // Progress bar process type #define PB_ABORT 0x100 // Progress bar abort button flag //__________________________________________________________________ // Start library-specific source code #ifndef USELIB #ifndef LIBPOP // Messages static string UPRPOPBACK = M(DE_UPRPOPBACK ,EN_UPRPOPBACK ); static string UPRPOPABORT = M(DE_UPRPOPABORT,EN_UPRPOPABORT); static string UPRPOPCONT = M("(Weiter)","(Continue)"); static string UPRABORTX = M("Abbruch","Abort"); // Popup button definitions static int BUTCONTLEN = strlen(UPRPOPCONT)+1; static int BUTABRTLEN = strlen(UPRPOPABORT)+1; // Messages static string REPPOPEND = M(" - Ende -"," - End -"); static string FMTDMPH1 = M("REPORTDATEI '%s'\n\n","REPORT FILE '%s'\n\n"); static string FMTDMPH2 = M(" User Language Programm ..: %s\n", " User Language Program ...: %s\n"); static string FMTDMPH3 = M(" Datum ...................: %02d.%02d.%4d\n", " Date ....................: %02d.%02d.%4d\n"); static string FMTDMPH4 = M(" Uhrzeit .................: %02d:%02d:%02d\n\n", " Time ....................: %02d:%02d:%02d\n\n"); static string UPRSAVE = M("Aktuelles Element '%s' in '%s' sichern ?", "Save current element '%s' to '%s' ?"); static string UPRLDFONT = M("Zeichensatz nicht ladbar! Anderen Zeichensatz laden ?", "Font Load Failure! Load other Font ?"); static string UPRCHKMAC = M("Fehlende Makros/Symbole! Makros pruefen ?", "Macros/Symbols missing! Check Macros ?"); static string UPRCHKNET = M("Fehlende Netzlisten-Pins! Netzliste pruefen ?", "Connected Pins missing! Check Netlist ?"); static string UPRSELWAR = M("%d Elemente selektiert, %d Elemente deselektiert!", "%d Elements selected, %d Elements deselected!"); static string ERRSAVE = M("Fehler beim Sichern des aktuellen Elementes!", "Error saving current element!"); static string ERRELMACC = M("%s '%s' in Datei '%s' nicht vorhanden!", "%s '%s' not available in file '%s'!"); // Buttons static string UPRPOPPROJ = M("(Projekt)","(Project)"); static string UPRPOPDPROJ = M("Projekt","Project"); static string UPRPOPDUMP = M("(Dump)","(Dump)"); static string UPRPOPDDUMP = M("Dump","Dump"); static string UPRPOPDDUMPT = M("Report/Liste in Textdatei schreiben", "Write report/list to text file"); static string UPRPOPDEDIT = M("Edit","Edit"); static string UPRPOPDEDITT = M("Report/Liste in Texteditor bearbeiten", "Edit Report/List in text editor"); static string UPRPOPDPATT = M("Muster anwenden","Apply Pattern"); static string UPRPOPDNEG = M("Negiert","Negated"); static string UPRPOPYES = M("(Ja)","(Yes)"); static string UPRPOPDYES = M("Ja","Yes"); static string UPRPOPNO = M("(Nein)","(No)"); static string UPRPOPDNO = M("Nein","No"); static string UPRPOPQUIT = M("(Quit)","(Quit)"); static string UPRPOPDQUIT = M("Quit","Quit"); static string UPRCONFIRM = M("Bestaetigen","Confirm"); static string UPRQUIT = M("Programmende","Exit Program"); static string UPRPOPDIR = M("(Dir.)","(Dir.)"); static string UPRPOPDDIR = M("Dir.","Dir."); static int BUTBACKLEN = strlen(UPRPOPBACK)+1; static int BUTPROJLEN = strlen(UPRPOPPROJ)+1; static int BUTDIRLEN = strlen(UPRPOPDIR)+1; static int BUTDUMPLEN = strlen(UPRPOPDUMP)+1; static int BUTYESLEN = strlen(UPRPOPYES); static int BUTNOLEN = strlen(UPRPOPNO); static int BUTQUITLEN = strlen(UPRPOPQUIT)+1; #define REPPOPENTRY " : %s" #define UPRPOPOK "(OK)" static int BUTOKLEN = strlen(UPRPOPOK)+1; #define DBUTWIDTH 6.5 // Dialog box button width #define DBUTSPACE 8.5 // Dialog box button hor. spacing #define MAXHEADLINE 8 // Max. header lines #define MINLISTHEIGHT 2.0 // Min. list box height // Item string definitions #define ITMDIR "[DIR] " #define ITMFILE "[FILE] " #define ITMTYPLEN 7 // Color values #define COLOR_ERR 12 // Error display color #define COLOR_WRN 14 // Warning display color #define COLOR_MSG 15 // Standard info display color // BAE popup menu definitions #define POPCOLWIDTH 18 // Popup column width #define POPSIZE 0.4 // Popup default size //__________________________________________________________________ // Messaging functions void M_REPDMPDONE(string fname) /* // Display dump done message // Parameters : // string fname : Output file name */ { string msgbuf; // Message buffer // Build the message string sprintf(msgbuf, M("Daten erfolgreich ausgegeben auf '%s'.", "Data successfully written to '%s'."),strgetvarfilename(fname)); // Issue the message popupmessage(0,-1,-1,msgbuf,"",""); } string M_REPPOPDIR(string dirname) /* // Directory popup header generator // Return value : // Message string // Parameters : // string dirname : Directory name/path */ { string msgbuf; // Message buffer // Build message sprintf(msgbuf, M("Dateiverzeichnis '%s' :","Directory '%s' :"),dirname); // Return the message string return(msgbuf); } string M_REPPOPDIRHD(int ddbcl,string fname) /* // Directory/type popup header generator // Return value : // Message string // Parameters : // int ddbcl : DDB class // string fname : DDB file name */ { string msgbuf; // Message buffer // Build message sprintf(msgbuf,M("Typ %s / Datei %s :","Type %s / File %s :"), ddbclassname(ddbcl),fname); // Return the message string return(msgbuf); } string M_REPSCANDDB() /* // DDB file scan in progress message generator // Return value : // Message string */ { // Get and return the message string return(M("Scannen DDB-Datei '%s'...","Scanning DDB file '%s'...")); } string M_REPSCANDIR() /* // Directory scan in progress message generator // Return value : // Message string */ { // Get and return the message string return(M("Scannen Directory '%s'...","Scanning directory '%s'...")); } //__________________________________________________________________ // Popup menu features double calcpopheight(int r) /* // Calculate popup height percentage for popup rows count // Return value : // popup height percentage // Parameters : // int r : Requested rows count (re-calculated!) */ { int mr; // Maximum row count int mc; // Maximum column count double size = 1.0; // Popup percentage size // Get the screen dimension bae_mtpsize(mc,mr); // Test the requested rows count if (r==0) { // Set default popup size size=POPSIZE; } else if (r<0 || r>mr) { // Out of range; set size to maximum size=POPMAX; } else { // Calculate the size percentage value // Ensure cast to double by pre-assignment if (mr) { size=r; size/=mr; } } // Ensure valid workspace if (size>POPMAX) size=POPMAX; // Re-calculate the row count r=mr*size; // Return the size value return(size); } double calcpopwidth(int c) /* // Calculate popup width percentage for popup columns count // Return value : // popup width percentage // Parameters : // int c : Requested columns count (re-calculated!) */ { int mr; // Maximum row count int mc; // Maximum column count double size = 1.0; // Popup percentage size // Get the screen dimension bae_mtpsize(mc,mr); // Test the requested columns count if (c==0) { // Set default popup size size=POPMAX-POPMIN; } else if (c<0 || c>mc) { // Out of range; set size to maximum size=POPMAX; } else { // Calculate the size percentage value // Ensure cast to double by pre-assignment if (mc) { size=c; size/=mc; } } // Ensure valid workspace if (size>POPMAX) size=POPMAX; // Re-calculate the column count c=mc*size; // Return the size value return(size); } void popupdump(string fname,STRINGS hl,int hn,STRINGS el,int en, int selmode,string prompt,string project,int dirselect,int verify) /* // Dump popup menu contents to file // Parameters : // string fname : Output file name // STRINGS hl : Popup menu header list // int hn : Popup menu header count // STRINGS el : Popup menu entry list // int en : Popup menu entry count // int selmode : Popup menu selection mode // string prompt : Popup menu prompt string // string project : Popup menu project name string // int dirselect : Popup menu dir selection enabled flag // int verify : Popup menu verify mode */ { string ERRDUMP = M("Popup-Dump '%s' fehlgeschlagen!", "Popup dump '%s' failure!"); // Popup contents dump error message string fn = fname; // Output file name int fh; // Output file name handle int day,month,year,hour,min,sec;// Date and time variables int i; // Loop control variable // Abort popup menu dump if running in BAE Demo if (BAE_Demo_check(1)) return; // Abort on abort output file name specification if (fn==UINPOPABORT) return; // Prompt for output file name if not yet specified // (do not display files with BAE system extensions!) if (fn=="" && (bae_askfilename(fn,"-",M(DE_UPRPOPFILE,EN_UPRPOPFILE)) || fn=="")) // Dump abort request return; // Open the output file fh=bae_fopen(fn,1); // Get date and time day=month=year=hour=min=sec=0; get_date(day,month,year); get_time(hour,min,sec); // Write popup menu dump header if (fprintf(fh,FMTDMPH1,convstring(fn,1)) || fprintf(fh,FMTDMPH2,programid()) || fprintf(fh,FMTDMPH3,day,month+1,year+1900) || fprintf(fh,FMTDMPH4,hour,min,sec)) { // File write error fclose(fh); errormsg(ERRDUMP,fn); } // Loop thru the popup menu header list for (i=0;i0 || project!=UINPOPABORT || dirselect)) { // Write buttons if (fprintf(fh,"\n"+REPPOPBUTHD+UPRPOPCONT+" "+UPRPOPBACK) || selmode>0 && project!=UINPOPABORT && fprintf(fh," "+UPRPOPPROJ) || !verify && fprintf(fh," "+UPRPOPABORT) || dirselect && fprintf(fh," "+UPRPOPDIR) || fprintf(fh," "+UPRPOPDUMP) || fprintf(fh,"\n\n")) { // File write error fclose(fh); errormsg(ERRDUMP,fn); } } // Test if verify is activated if (verify) { // Write verify prompt and yes/no menu items if (fprintf(fh,"%s\n\n",prompt) || fprintf(fh," o %-*.*s %s\n\n", POPBUTSPC,POPBUTSPC,UPRPOPYES,REPPOPBUTHD+UPRCONFIRM) || fprintf(fh," o %-*.*s %s\n\n", POPBUTSPC,POPBUTSPC,UPRPOPNO,REPPOPBUTHD+UPRABORTX)) { // File write error fclose(fh); errormsg(ERRDUMP,fn); } // Test if verify quit is enabled if (verify==2) { // Write verify quit menu item if (fprintf(fh," o %-*.*s %s\n\n", POPBUTSPC,POPBUTSPC,UPRPOPQUIT, REPPOPBUTHD+UPRQUIT)) { // File write error fclose(fh); errormsg(ERRDUMP,fn); } } } // Write popup menu prompt if (prompt && fprintf(fh,"%s\n",prompt)) { // File write error fclose(fh); errormsg(ERRDUMP,fn); } // Close the output file if (fclose(fh)) // Error closing output file errormsg(ERRDUMP,fn); // Issue popup dump done message M_REPDMPDONE(fn); } void popupedit(int id,STRINGS hl,int hn,STRINGS el,int en) /* // Edit popup menu contents with external tool // Parameters : // int id : Popup dialog box ID // STRINGS hl : Popup menu header list // int hn : Popup menu header count // STRINGS el : Popup menu entry list // int en : Popup menu entry count */ { string ERRDUMP = M("Popup-Dump '%s' fehlgeschlagen!", "Popup dump '%s' failure!"); // Popup contents dump error message string fn; // Output file name int fh; // Output file name handle int i; // Loop control variable // Abort popup menu dump if running in BAE Demo if (BAE_Demo_check(1)) return; sprintf(fn,"%s_%d.txt",convstring(bae_planfname(),0),id<0 ? 0 : id); // Open the output file fh=bae_fopen(fn,1); // Loop thru the popup menu header list for (i=0;i0) ? fidxl[fidxn-1] : 0; } // Abort if listing mode if (abs(selmode)==3) break; // Test on continue selection if (name==UINPOPCONT) { // Test current new first index if (firstidx==0) // Restart menu fidxn=1; else // Move new first index onto stack fidxl[fidxn++]=firstidx; } // Test on back selection else if (name==UPRPOPBACK) { // Remove first index from stack if (fidxn>0) --fidxn; // Update the first index firstidx=(fidxn>0) ? fidxl[fidxn-1] : 0; } // Display the next name set if (!bae_peekiact()) rdstrlen=popupelem(selmode,mheadl,mheadn,entryl,entryn, project,dirselect,0,firstidx, halign,valign,reqrows,reqcols,verify,prompt,dumpfname); } // Restore the popup if not listing mode if (abs(selmode)!=3 || name!=UINPOPCONT && name!=UPRPOPBACK && name!=mheadl[0]) // Restore the popup area bae_poprestore(); // Test if verification if (verify) { // Get lower case name buffer strlower(namelow=name); // Test if special input switch (namelow) { // Ensure correct yes answer case M_UINYES() : name=M_UINYES(); break; // Ensure correct no answer case UINNO : name=UINNO; break; // Quit answer case UINPOPQUIT : case UINPOPABORT : // Abort from program if quit enabled if (verify==2) error_abort(); break; } } // Test on default project name selection if (name=="" && project!="" && project!=UINPOPABORT) // Select project name name=project; // Return the selected element name return(name); } string popupmenu(int selmode,string prompt, STRINGS mheadl,int mheadn,STRINGS entryl,int entryn,string project, int dirselect,int halign,int valign,int reqrows,int reqcols, int verify,string dumpfname) /* // Perform a popup menu activation // Return value : // selected menu entry string, or empty string on abort // Parameters : // int selmode : Selection mode : // (-3) = Disable select/listing/single col. // (-2) = Disable select/menu delay/multi col. // (-1) = Disable select/multi column // ( 0) = Disable select/single column // ( 1) = Enable select/multi column // ( 2) = Enable select/menu delay/multi col. // ( 3) = Enable select/listing/single col. // ( 4) = Enable select/single column // ( 5) = Enable select/single button column // string prompt : Prompt string // STRINGS mheadl : Menu header list // int mheadn : Menu header count // STRINGS entryl : Menu entry list // int entryn : Menu entry count // string project : Project name string : // UINPOPABORT = not shown // empty string = disabled on select enable // else = enabled on select enable // int dirselect : Directory selection enabled flag // (to return UINPOPDIR on selection) // int halign : Horizontal alignment : // zero = center alignment // positive = right alignment // negative = left alignment // int valign : Vertical alignment : // zero = center alignment // positive = top alignment // negative = bottom alignment // int reqrows : Requested rows count (0=default) // int reqcols : Requested colums count (0=default) // int verify : Verify mode : // (0) = no verification // (1) = standard verification // (2) = verify with quit enable // string dumpfname : Popup menu dump file name : // UINPOPABORT = popup menu dump disabled // empty string = enable with file selection // else = enabled with file name */ { #define STRABLOCK 100 // String allocation blocks #define LISTBASE 10 // List base index string answer; // Answer string string headstr = ""; // Header string string entrystr = ""; // Entry string string blockstr = ""; // Block allocation string int blockcnt = 0; // Block allocation count string dispstr = ""; // Display string int dispn = 0; // Display entry count int popcols = reqcols; // Popup columns count int entrycols = 0; // Entry list columns count double entrybcols = 0.0; // Entry buttons columns count double cy; // Dialog box current y coordinate double xmax; // Box max. width double ymax; // Box max. height double orgymax; // Original box max. height double eboxy; // Entry box y coordinate double eboxw; // Entry box width double eboxh; // Entry box height double scrollw; // Horizontal scroll flag double butx; // Dialog box button x coordinate double hboxy; // Header box y coordinate double hboxh; // Header box height double dialwidth; // Dialog box width double dialheight; // Dialog box height double baseheight; // Dialog box base height int lastboxflag = 0; // Last box size known flag int resizeallowed = 0; // Resize allowed flag int id; // Dialog box ID int editidx = (-1); // Edit field dialog box item index int fentryidx = 0; // First list box entry index int dialres; // Dialog box result buffer int repflag = 0; // Dialog box repeat flag int i; // Loop control variable // Get max. dialog box dimensions bae_getdblpar(0,xmax); xmax-=DIAL_LEFTMARG+DIAL_RIGHTSMARG; bae_getdblpar(1,ymax); ymax-=0.2+DIAL_SEPVSTEP; // Check if dialog box support if (bae_dialclr()) // Use old style popup menu return(oldstylepopupmenu( selmode,prompt,mheadl,mheadn,entryl,entryn,project,dirselect, halign,valign,reqrows,reqcols,verify,dumpfname)); // Get the dialog box ID bae_getintpar(16,id); // Get max. entry length for (i=entryn-1;i>=0;i--) entrycols=maxint(entrycols,strlen(entryl[i])+1); // Get button area size butx=0.0; if (!verify) butx+=2.0*DBUTSPACE; if (dirselect) butx+=DBUTSPACE; if (project!=UINPOPABORT && project!="") butx+=DBUTSPACE; if (dumpfname!=UINPOPABORT) butx+=2.0*DBUTSPACE; // Set the popup columns count if (popcols==0) { if (verify) // Add columns required for verification prompt popcols= maxint(2*DBUTSPACE+UPRQUITLEN,strlen(prompt)+1); // Add columns required for header for (i=mheadn-1;i>=0;i--) popcols=maxint(popcols,strlen(mheadl[i])+1); // Add columns required for prompt popcols=maxint(popcols,strlen(prompt)+1); // Add columns required for entries popcols=maxint(popcols,entrycols); } // Set requested entry box width eboxw=1.0+1.1*popcols; // Check if button area is larger if (butx>eboxw) // Use button area size eboxw=butx; if (eboxw>xmax) { scrollw=eboxw; eboxw=xmax; } // Determine the base box height baseheight=DIAL_TOPMARG+0.2; switch (selmode) { // Single column without select case 0 : // Multi column without select case -1 : // Check if pure small header display if (entryn<1 && mheadnSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Build entry string blockcnt=0; blockstr=""; for (i=0;iSTRABLOCK) { entrystr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) entrystr+=blockstr; // Check if string defined if ((dispstr=headstr+entrystr)!="") baseheight+=DIAL_SEPVSTEP; } // Check verify mode if (verify) { baseheight+= 3.0*DIAL_SEPVSTEP+DIAL_TXTVSTEP+2.0*DIAL_BUTVSTEP; if (verify==2) baseheight+=DIAL_BUTVSTEP; if ((project!=UINPOPABORT && project!="") || dirselect || dumpfname!=UINPOPABORT) baseheight+=DIAL_BUTVSTEP; } else { baseheight+=DIAL_BUTVSTEP; } break; // Enable select/multi column case 1 : // Enable select/single column case 4 : // Check if small header display if (mheadnSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Check if string defined if (headstr!="") baseheight+= MAXHEADLINE*DIAL_TXTVSTEP+DIAL_SEPVSTEP; } baseheight+=DIAL_SEPVSTEP; // Store edit control baseheight+=DIAL_CTRVSTEP; // Store list box entries if (entryl[0]=="") fentryidx=1; for (i=fentryidx;i0) baseheight+=DIAL_SEPVSTEP; for (i=fentryidx;iSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Check if string defined if (headstr!="") baseheight+=DIAL_SEPVSTEP; } // Store button field start position baseheight+=entryn*DIAL_BUTVSTEP; baseheight+=DIAL_SEPVSTEP; // Check verify mode if (verify) { baseheight+= DIAL_TXTVSTEP+DIAL_SEPVSTEP+2.0*DIAL_BUTVSTEP; if (verify==2) baseheight+=DIAL_BUTVSTEP; if ((project!=UINPOPABORT && project!="") || dirselect || dumpfname!=UINPOPABORT) baseheight+=DIAL_BUTVSTEP; } else { baseheight+=DIAL_BUTVSTEP; } break; default : // Use old style popup menu return(oldstylepopupmenu( selmode,prompt,mheadl,mheadn,entryl,entryn,project,dirselect, halign,valign,reqrows,reqcols,verify,dumpfname)); } // Perform input loop do { bae_dialclr(); if (id>=0) { // Try to load previously used box size bae_setintpar(16,id); if (bae_getdblpar(8,dialwidth)==0) { // Use last selected box width eboxw=dialwidth-DIAL_LEFTMARG-DIAL_RIGHTSMARG; // Get buffered height bae_getdblpar(9,dialheight); lastboxflag=1; } else { lastboxflag=0; } } cy=DIAL_TOPMARG; bae_getdblpar(1,orgymax); if (lastboxflag) bae_setdblpar(1,1000.0); bae_getdblpar(1,ymax); bae_setdblpar(1,orgymax); ymax-=0.2+DIAL_SEPVSTEP; dispstr=headstr=entrystr=blockstr=""; fentryidx=0; // Check popup type switch (selmode) { // Single column without select case 0 : // Multi column without select case -1 : // Check if pure small header display if (entryn<1 && mheadnSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Build entry string blockcnt=0; blockstr=""; for (i=0;iSTRABLOCK) { entrystr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) entrystr+=blockstr; // Get total string display lines dispn=entryn+mheadn; // Check if string defined if ((dispstr=headstr+entrystr)!="") { // Get entry box size eboxy=cy; if (verify) { ymax-=4.0*DIAL_SEPVSTEP+DIAL_TXTVSTEP+ (verify==2 ? 3.0 : 2.0)*DIAL_BUTVSTEP; if (dumpfname!=UINPOPABORT || dirselect || (project!=UINPOPABORT && project!="")) ymax-=DIAL_BUTVSTEP; } else { ymax-=DIAL_BUTVSTEP; } // Restrict box size to max. value eboxh= lastboxflag ? (dialheight-baseheight) : (0.5*dispn+1.0); if (eboxh>ymax) eboxh=ymax; else if (eboxhSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Check if string defined if (headstr!="") { // Get header box size hboxy=cy; hboxh=MAXHEADLINE*DIAL_TXTVSTEP; // Delay creation of text box to avoid // initial text inversion caused by focus cy+=hboxh+DIAL_SEPVSTEP; ymax-=hboxh+DIAL_SEPVSTEP; } } // Store entry box position eboxy=cy; ymax-=DIAL_CTRVSTEP; // Get button space if (verify) { ymax-=4.0*DIAL_SEPVSTEP+DIAL_TXTVSTEP+ (verify==2 ? 3.0 : 2.0)*DIAL_BUTVSTEP; if (dumpfname!=UINPOPABORT || dirselect || (project!=UINPOPABORT && project!="")) ymax-=DIAL_BUTVSTEP; } else { ymax-=DIAL_BUTVSTEP; } // Store list box entries if (entryl[0]=="") fentryidx=1; for (i=fentryidx;iymax) eboxh=ymax; // Set min. box height if (eboxh0) { bae_dialaddcontrol(PA_HSEP|PA_HBRDREL,0,0,0,0.0,0.0, 0.0,"",0,DIAL_LEFTMARG,cy,DIAL_RIGHTSMARG,""); cy+=DIAL_SEPVSTEP; } // Init. button column position butx=DIAL_LEFTMARG; // Check verify mode if (verify) { // Store verification prompt cy+=DIAL_SEPVSTEP; bae_dialaddcontrol(PA_HSEP|PA_HBRDREL,0,0,0,0.0,0.0, 0.0,"",0,DIAL_LEFTMARG,cy,DIAL_RIGHTSMARG,""); cy+=DIAL_SEPVSTEP; bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG,cy,0.0,prompt); cy+=DIAL_TXTVSTEP+DIAL_SEPVSTEP; // Store yes controls bae_dialaddcontrol(PA_ACT,0,1,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,cy,DBUTWIDTH,UPRPOPDYES); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRCONFIRM); cy+=DIAL_BUTVSTEP; // Store no controls bae_dialaddcontrol(PA_ACT,0,2,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,cy,DBUTWIDTH,UPRPOPDNO); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRABORTX); cy+=DIAL_BUTVSTEP; if (verify==2) { // Store optional quit controls bae_dialaddcontrol(PA_ACT,0,(-1),0, 0.0,0.0,0.0,"",0,DIAL_LEFTMARG, cy,DBUTWIDTH,UPRPOPDQUIT); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRQUIT); cy+=DIAL_BUTVSTEP; } } else { // Store OK button bae_dialaddcontrol(PA_OK, 0,0,0,0.0,0.0,0.0,"",0,butx,cy,DBUTWIDTH,""); butx+=DBUTSPACE; // Store abort button bae_dialaddcontrol(PA_ABORT, 0,0,0,0.0,0.0,0.0,"",0,butx,cy,DBUTWIDTH,""); butx+=DBUTSPACE; } // Store project button if (project!=UINPOPABORT && project!="") { bae_dialaddcontrol(PA_ACT,0,3,0,0.0,0.0,0.0, "",0,butx,cy,DBUTWIDTH,UPRPOPDPROJ); butx+=DBUTSPACE; } // Store directory button if (dirselect) { bae_dialaddcontrol(PA_ACT,0,4,0,0.0,0.0,0.0, "",0,butx,cy,DBUTWIDTH,UPRPOPDDIR); butx+=DBUTSPACE; } // Store file dump button if (dumpfname!=UINPOPABORT) { bae_dialaddcontrol(PA_ACT,0,5,0,0.0,0.0,0.0, UPRPOPDDUMPT,0,butx,cy,DBUTWIDTH,UPRPOPDDUMP); butx+=DBUTSPACE; bae_dialaddcontrol(PA_ACT,0,6,0,0.0,0.0,0.0, UPRPOPDEDITT,0,butx,cy,DBUTWIDTH,UPRPOPDEDIT); butx+=DBUTSPACE; } // Check if button separator needed if (butx!=DIAL_LEFTMARG) cy+=DIAL_BUTVSTEP; // Check if multiline string display box needed if (headstr!="" && mheadn>=MAXHEADLINE) bae_dialadvcontrol(PA_STR|PA_NOEDIT|PA_FNTFIX,0,0,0, 0.0,0.0,0.0,headstr,2*strlen(headstr), DIAL_LEFTMARG,hboxy,eboxw,hboxh,""); break; // Enable select/single button column case 5 : // Check if small header display if (mheadnSTRABLOCK) { headstr+=blockstr; blockcnt=0; blockstr=""; } } if (blockcnt) headstr+=blockstr; // Check if string defined if (headstr!="") { // Get header box size hboxy=cy; if (lastboxflag) { hboxh=dialheight-baseheight; if (hboxhmheadn*DIAL_TXTVSTEP) hboxh=mheadn*DIAL_TXTVSTEP; } // Delay creation of text box to avoid // initial text inversion caused by focus cy+=hboxh+DIAL_SEPVSTEP; } } // Store button field start position eboxy=cy; cy+=entryn*DIAL_BUTVSTEP; bae_dialaddcontrol(PA_HSEP|PA_HBRDREL,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG,cy,DIAL_RIGHTSMARG,""); cy+=DIAL_SEPVSTEP; // Init. button column position butx=DIAL_LEFTMARG; // Check verify mode if (verify) { // Store verification prompt bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG,cy,0.0,prompt); cy+=DIAL_TXTVSTEP+DIAL_SEPVSTEP; // Store yes controls bae_dialaddcontrol(PA_ACT,0,1,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,cy,DBUTWIDTH,UPRPOPDYES); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRCONFIRM); cy+=DIAL_BUTVSTEP; // Store no controls bae_dialaddcontrol(PA_ACT,0,2,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,cy,DBUTWIDTH,UPRPOPDNO); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRABORTX); cy+=DIAL_BUTVSTEP; if (verify==2) { // Store optional quit controls bae_dialaddcontrol(PA_ACT,0,(-1),0, 0.0,0.0,0.0,"",0,DIAL_LEFTMARG, cy,DBUTWIDTH,UPRPOPDQUIT); bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+DBUTSPACE,cy,0.0,UPRQUIT); cy+=DIAL_BUTVSTEP; } } else { // Store OK button bae_dialaddcontrol(PA_OK, 0,0,0,0.0,0.0,0.0,"",0,butx,cy,DBUTWIDTH,""); butx+=DBUTSPACE; // Store abort button bae_dialaddcontrol(PA_ABORT, 0,0,0,0.0,0.0,0.0,"",0,butx,cy,DBUTWIDTH,""); butx+=DBUTSPACE; } // Store project button if (project!=UINPOPABORT && project!="") { bae_dialaddcontrol(PA_ACT,0,3,0,0.0,0.0,0.0, "",0,butx,cy,DBUTWIDTH,UPRPOPDPROJ); butx+=DBUTSPACE; } // Store directory button if (dirselect) { bae_dialaddcontrol(PA_ACT,0,4,0,0.0,0.0,0.0, "",0,butx,cy,DBUTWIDTH,UPRPOPDDIR); butx+=DBUTSPACE; } // Store file dump button if (dumpfname!=UINPOPABORT) { bae_dialaddcontrol(PA_ACT,0,5,0,0.0,0.0,0.0, UPRPOPDDUMPT,0,butx,cy,DBUTWIDTH,UPRPOPDDUMP); butx+=DBUTSPACE; bae_dialaddcontrol(PA_ACT,0,6,0,0.0,0.0,0.0, UPRPOPDEDITT,0,butx,cy,DBUTWIDTH,UPRPOPDEDIT); butx+=DBUTSPACE; } for (i=0;i=MAXHEADLINE) { resizeallowed=1; bae_dialadvcontrol(PA_STR|PA_NOEDIT|PA_FNTFIX,0,0,0, 0.0,0.0,0.0,headstr,2*strlen(headstr), DIAL_LEFTMARG,hboxy,eboxw,hboxh,""); } // Check if button separator needed if (butx!=DIAL_LEFTMARG) cy+=DIAL_BUTVSTEP; break; default : } // Display dialog box bae_setintpar(16,id); switch (dialres=bae_dialaskparams((resizeallowed ? "!" : "")+ (prompt=="" ? " " : prompt), 0,DIAL_LEFTMARG+eboxw+DIAL_RIGHTSMARG,cy+0.2)) { // Done case 0 : if (editidx<0) { return(""); } else { bae_dialgetdata(editidx,0,0.0,answer); return(answer); } // Yes case 1 : return(M_UINYES()); // No case 2 : return(UINNO); // Project case 3 : return(project); // Directory case 4 : return(UINPOPDIR); // Dump case 5 : // Dump the popup menu contents popupdump(dumpfname, mheadl,mheadn,entryl,entryn,selmode, prompt,project,dirselect,verify); repflag=1; continue; // Edit case 6 : // Dump the popup menu contents popupedit(id,mheadl,mheadn,entryl,entryn); return(""); // Resize case (-2) : repflag=1; break; // Quit/Abort case (-1) : return(UINPOPABORT); default : if (dialres>=LISTBASE && (dialres-LISTBASE)xmax) eboxw=xmax; // Init. the selection state field for (i=0;i=0) { // Try to load previously used box size bae_setintpar(16,id); if (bae_getdblpar(8,dialwidth)==0) { // Use last selected box width eboxw=dialwidth- DIAL_LEFTMARG-DIAL_RIGHTSMARG; // Get buffered height bae_getdblpar(9,dialheight); lastboxflag=1; } else { lastboxflag=0; } } cy=DIAL_TOPMARG; bae_getdblpar(1,orgymax); if (lastboxflag) bae_setdblpar(1,1000.0); bae_getdblpar(1,ymax); bae_setdblpar(1,orgymax); ymax-=0.2+DIAL_SEPVSTEP; // Check if small header display if (mheadnymax) eboxh=ymax; // Set min. box height if (eboxh=MAXHEADLINE) bae_dialadvcontrol(PA_STR|PA_NOEDIT|PA_FNTFIX, 0,0,0,0.0,0.0,0.0,headstr,2*strlen(headstr), DIAL_LEFTMARG,hboxy,eboxw,hboxh,""); // Display dialog box bae_setintpar(16,id); dialres=bae_dialaskparams("!"+(prompt=="" ? " " : prompt),0,DIAL_LEFTMARG+eboxw+DIAL_RIGHTSMARG,cy+0.2); bae_dialgetdata(editidx,0,0.0,answer); for (i=0;i=entryn) { markonn=markoffn=0; for (i=0;i0 && markoffn>0) { sprintf(msg,UPRSELWAR,markonn,markoffn); bae_msgbox(1,msg,""); } answer=""; break; // Resize case (-2) : break; // Quit/Abort case (-1) : default : error_abort(); } } // Stop if no further repeat requests while (repflag); } else { for (i=0;i0) --fidxn; // Update the first index firstidx=(fidxn>0) ? fidxl[fidxn-1] : 0; } else { // Search direct popup selection entries markonn=markoffn=0; for (i=0;i=entryn) { answer="?"+answer; markonn=markoffn=0; for (i=0;i0 && markoffn>0) { sprintf(msg,UPRSELWAR, markonn,markoffn); bae_msgbox(1,msg,""); } // Update the first index firstidx=(fidxn>0) ? fidxl[fidxn-1] : 0; } // Display the next name set rdstrlen=popupelem(selmode,mheadl,mheadn,entryl,entryn, UINPOPABORT,0,1,firstidx, halign,valign,reqrows,reqcols,0,prompt,UINPOPABORT); } // Restore the popup if not listing mode if (abs(selmode)!=3 || answer!=UINPOPCONT && answer!=UPRPOPBACK && answer!=mheadl[0]) // Restore the popup area bae_poprestore(); // Check if abort selected if (answer==UINPOPABORT) error_abort(); // Copy selected elements to selected entry list for (selentryn=i=0;i=0;i--) popcols=maxint(popcols,strlen(mheadl[i])+1); // Add columns required for entries for (i=entryn-1;i>=0;i--) popcols=maxint(popcols,strlen(entryl[i])+1); } // Test if button display is required if (popcols!=0 && (!verify || entryn+mheadn>0 || project!=UINPOPABORT || dirselect || okbutton || dumpfname!=UINPOPABORT)) { // Get space for continue and back button i=BUTHDLEN+BUTCONTLEN+BUTBACKLEN; // Add space for project button if (selmode>0 && project!=UINPOPABORT) i+=BUTPROJLEN; // Add space for abort selection button if (!verify) i+=BUTABRTLEN; // Add space for directory button if (dirselect) i+=BUTDIRLEN; // Add space for OK button if (okbutton) i+=BUTOKLEN; // Add space for dump button (if not BAE Demo software) if (dumpfname!=UINPOPABORT) i+=BUTDUMPLEN; // Update the popup columns count if (popcols=(poprows-2)) for (currow=0,headidx=0; headidx=entryn) { // End of list if (selmode && abs(selmode)!=3) bae_poptext(currow,curcol,REPPOPEND); // Set entry index to sentinel entryidx=entryn+1; // Terminate output (both loops) currow=poprows; break; } // Build the display string if (selmode) sprintf(strbuf,REPPOPENTRY,entryl[entryidx]); else strbuf=entryl[entryidx]; // Check on column overflow if (selmode && curcol+(strlen=strlen(strbuf))>popcols) { // New row required curcol=0; currow++; // Stop output if at end of popup area if (currow>=poprows-2) break; } // Display the current menu entry if (selmode>0) { bae_poptextchoice( currow,curcol,strbuf,entryl[entryidx]); rdstrlen= maxint(rdstrlen,strlen(entryl[entryidx])+1); } else bae_poptext(currow, (selmode ? curcol : 0),entryl[entryidx]); // Increment the menu entry index entryidx++; // Move to next column if multi-column select mode if (selmode && abs(selmode)<3) curcol+=(strlen/POPCOLWIDTH)*POPCOLWIDTH; else break; // Stop output if at end of popup menu entry area if (currow>=poprows-2) break; } // Test if button display is required if (!verify || entryn+mheadn>0 || project!=UINPOPABORT || dirselect || okbutton) { // Display the button header bae_poptext(poprows-1,0,REPPOPBUTHD); // Init the button position butpos=BUTHDLEN; // Test if more pages possible if (entryidx0 && project!=UINPOPABORT) { // Test if project selectable if (project) { // Display enabled project button bae_poptextchoice( poprows-1,butpos,UPRPOPPROJ,project); rdstrlen=maxint(rdstrlen,strlen(project)+1); } else { // Display disabled project button bae_poptext(poprows-1,butpos,UPRPOPPROJ); } // Update the button position butpos+=BUTPROJLEN; } // Test if not verification request if (!verify) { // Display enabled abort button bae_poptextchoice( poprows-1,butpos,UPRPOPABORT,UINPOPABORT); // Update the button position butpos+=BUTABRTLEN; } // Test if directory button is requested if (dirselect) { // Display enabled directory button bae_poptextchoice( poprows-1,butpos,UPRPOPDIR,UINPOPDIR); // Update the button position butpos+=BUTDIRLEN; } // Test if OK button is requested if (okbutton) { // Display enabled OK button bae_poptextchoice(poprows-1,butpos,UPRPOPOK,UINPOPOK); // Update the button position butpos+=BUTOKLEN; } // Test if popup menu dump button is requested and allowed if (dumpfname!=UINPOPABORT) { // Display popup menu dump button bae_poptextchoice( poprows-1,butpos,UPRPOPDUMP,UPRPOPDUMP); // Update the button position butpos+=BUTDUMPLEN; } } // Update the first menu entry index if ((firstidx=entryidx)>entryn) firstidx=0; // Done if verify is not enabled if (!verify) return(rdstrlen); // Display the verification prompt bae_poptext(poprows+1,0,prompt); // Display the yes answer buttons bae_popcolchoice(poprows+3,2,poprows+3,3,10,M_UINYES()); bae_poptextchoice(poprows+3,POPBUTSPC,UPRPOPYES,M_UINYES()); bae_poptext(poprows+3,2*POPBUTSPC,REPPOPBUTHD+UPRCONFIRM); // Display the no answer buttons bae_popcolchoice(poprows+5,2,poprows+5,3,12,UINNO); bae_poptextchoice(poprows+5,POPBUTSPC,UPRPOPNO,UINNO); bae_poptext(poprows+5,2*POPBUTSPC,REPPOPBUTHD+UPRABORTX); // Done if verify quit is not enabled if (verify!=2) return(rdstrlen); // Display the quit answer buttons bae_popcolchoice(poprows+7,2,poprows+7,3,0,UINPOPQUIT); bae_poptextchoice(poprows+7,POPBUTSPC,UPRPOPQUIT,UINPOPQUIT); bae_poptext(poprows+7,2*POPBUTSPC,REPPOPBUTHD+UPRQUIT); // Return the read string length return(rdstrlen); } void popupmessage(int msgtype, int sr,int sc,string msg1,string msg2,string msg3) /* // Display a message popup with up to three messages // Parameters : // int msgtype : Message type : // (-1) = issue error and abort program // ( 1) = issue warning // else = issue standard info // int sr : Message popup start row // int sc : Message popup start column // if sr and sc negative, init centered // popup and restore popup area afterwards // string msg1 : Message string 1 // string msg2 : Message string 2 // string msg3 : Message string 3 */ { int mt; // Message type // Map message type switch (msgtype) { case ( 1) : mt=1; break; // Warning case (-1) : mt=2; break; // Error default : mt=0; break; // Standard/info } // Display message popup bae_msgbox(mt,msg1+" "+msg2+" "+msg3, ddbclassname(DDBCLUL)+" "+programid()); // Abort on error message type if (msgtype==(-1)) error_abort(); } int verify(string prompt,int quitenable) /* // Prompt user for verification with yes or no // Return value : // nonzero on yes answer, zero on no answer // Parameters : // string prompt : Prompt string // int quitenable : Quit program enable flag */ { // Check quit enable flag if (quitenable) { // Verify with quit option switch (bae_msgboxverifyquit(prompt, ddbclassname(DDBCLUL)+" "+programid())) { case 1 : return(1); // Yes anser case 0 : return(0); // No answer } // Assume quit request; abort error_abort(); } // Verify return(bae_msgboxverify(prompt, ddbclassname(DDBCLUL)+" "+programid())); } //__________________________________________________________________ // Dialog box creation int dial_hsep(double y) /* // Create full width horizontal seperator, adjust row // Return value : // Seperator dialog box item index or (-1) on creation failure // Parameters : // double y : Seperator row */ { int res /* Creation result */; res=bae_dialaddcontrol(PA_HSEP|PA_HBRDREL,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG,y,DIAL_RIGHTSMARG,""); y+=DIAL_SEPVSTEP; // Return dialog box item index return(res); } int dial_label(double x,double y,string str) /* // Create left aligned label // Return value : // Label dialog box item index or (-1) on creation failure // Parameters : // double x : Label column // double y : Label row // string str : Label string */ { // Return dialog box item index return(bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+x,y,0.0,str)); } int dial_promptlabel(double x,double y,string str) /* // Create left aligned parameter prompt label // Return value : // Label dialog box item index or (-1) on creation failure // Parameters : // double x : Label column // double y : Label row // string str : Label string */ { // Return dialog box item index return(bae_dialaddcontrol(PA_LAB,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+x,y,0.0,P_DIALOG(str))); } int dial_cliplabel(double x,double y,string str) /* // Create left aligned label with clipboard copy functionality // Return value : // Label dialog box item index or (-1) on creation failure // Parameters : // double x : Label column // double y : Label row // string str : Label string */ { // Return dialog box item index return(bae_dialaddcontrol(PA_STR|PA_NOEDIT,0,0,0,0.0,0.0,0.0,str, MAXTEXTLEN,DIAL_LEFTMARG+x,y,0.0,"")); } int dial_tabgroup() /* // Create a tab control group seperator // Return value : // Tab group seperator dialog box item index or (-1) on creation failure */ { int res /* Creation result */; res=bae_dialaddcontrol(PA_TABGRP,0,0,0,0.0,0.0,0.0,"",0,0.0,0.0,0.0,""); // Return dialog box item index return(res); } int dial_tabend() /* // Create a tab control terminator // Return value : // Tab control terminator dialog box item index or (-1) on creation failure */ { int res /* Creation result */; res=bae_dialaddcontrol(PA_TABGRP,0,0,1,0.0,0.0,0.0,"",0,0.0,0.0,0.0,""); // Return dialog box item index return(res); } int dial_toggle(int val,double x,double y,string str) /* // Create toggle box, adjust row // Return value : // Toggle dialog box item index or (-1) on creation failure // Parameters : // int val : Initial value // double x : Toggle box start column // double y : Toggle box row // string str : Toggle label string */ { int res /* Creation result */; // Store the toggle box res=bae_dialaddcontrol(PA_TOGGLE,0,0, val,0.0,0.0,0.0,"",0,DIAL_LEFTMARG+x,y,0.0,str); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_dist(int digits,double val,double x,double y) /* // Create right aligned positive distance input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // int digits : Fraction display digits // double val : Initial value // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store the input box res=bae_dialaddcontrol(PA_DBL|PA_DIST|PA_CHKLL|PA_HBRDREL,0,digits, 0,0.0,0.0,val,"",0,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_distpar(string str,int digits,double val,double x,double y) /* // Create right aligned labeled positive distance input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string str : Label string // int digits : Fraction display digits // double val : Initial value // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,str); // Store the input box res=bae_dialaddcontrol(PA_DBL|PA_DIST|PA_CHKLL|PA_HBRDREL,0,digits, 0,0.0,0.0,val,"",0,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_double(int digits,double val,double x,double y) /* // Create right aligned positive double input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // int digits : Fraction display digits // double val : Initial value // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store the input box res=bae_dialaddcontrol(PA_DBL|PA_CHKLL|PA_HBRDREL,0,digits,0,0.0,0.0, val,"",0,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_doublepar(string str,int digits,double val,double x,double y) /* // Create right aligned labeled positive double input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string str : Label string // int digits : Fraction display digits // double val : Initial value // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,str); // Store the input box res=bae_dialaddcontrol(PA_DBL|PA_CHKLL|PA_HBRDREL,0,digits,0,0.0,0.0, val,"",0,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_namestring(string str,int len,double x,double y) /* // Create right aligned name string edit box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store the input box res=bae_dialaddcontrol(PA_STR|PA_CHKNAME|PA_HBRDREL,0,0,0,0.0,0.0,0.0, str,len,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_namestringpar(string labstr,string str,int len,double x,double y) /* // Create right aligned labeled name string edit box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string labstr : Label string // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,labstr); // Store the input box res=bae_dialaddcontrol(PA_STR|PA_CHKNAME|PA_HBRDREL,0,0,0,0.0,0.0,0.0, str,len,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_npatstring(string str,int len,double x,double y) /* // Create right aligned name (pattern) string edit box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store the input box res=bae_dialaddcontrol(PA_STR|PA_CHKNPAT|PA_HBRDREL,0,0,0,0.0,0.0,0.0, str,len,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_npatstringpar(string labstr,string str,int len,double x,double y) /* // Create right aligned labeled name (pattern) string edit box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string labstr : Label string // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,labstr); // Store the input box res=bae_dialaddcontrol(PA_STR|PA_CHKNPAT|PA_HBRDREL,0,0,0,0.0,0.0,0.0, str,len,DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_string(string str,int len,double x,double y) /* // Create right aligned string input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store the input box res=bae_dialaddcontrol(PA_STR|PA_HBRDREL,0,0,0,0.0,0.0,0.0,str,len, DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_stringpar(string labstr,string str,int len,double x,double y) /* // Create right aligned labeled string input box, adjust row // Return value : // Edit dialog box item index or (-1) on creation failure // Parameters : // string labstr : Label string // string str : Initial string value // int len : Maximum string length // double x : Edit box start column // double y : Edit box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,labstr); // Store the input box res=bae_dialaddcontrol(PA_STR|PA_HBRDREL,0,0,0,0.0,0.0,0.0,str,len, DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_selbox(int id,double x,double y) /* // Create right aligned selection box start, adjust row // Return value : // Selection dialog box item index or (-1) on creation failure // Parameters : // int id : Initial entry ID // double x : Selection box start column // double y : Selection box row */ { int res /* Creation result */; // Store the selection box header res=bae_dialaddcontrol(PA_SB|PA_HBRDREL,0,0,id,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_selboxpar(string str,int id,double x,double y) /* // Create right aligned labeled selection box start, adjust row // Return value : // Selection dialog box item index or (-1) on creation failure // Parameters : // string str : Label string // int id : Initial entry ID // double x : Selection box start column // double y : Selection box row */ { int res /* Creation result */; // Store parameter label bae_dialaddcontrol( PA_LAB,0,0,0,0.0,0.0,0.0,"",0,DIAL_LEFTMARG,y,0.0,P_DIALOG(str)); // Store the selection box header res=bae_dialaddcontrol(PA_SB|PA_HBRDREL,0,0,id,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+x,y,DIAL_RIGHTEMARG,""); y+=DIAL_CTRVSTEP; // Return dialog box item index return(res); } int dial_lbddbentry( int act,int id,string filename,string elemname,int ddbcl,int style) /* // Add commented DDB element list box entry // Return value : // List box item index or (-1) on creation failure // Parameters : // int act : Entry selection action code (0 no action) // int id : Entry ID // string filename : DDB file name // string elemname : DDB element name // int ddbcl : DDB class code // int style : Comment display style */ { // Return dialog box item index return(bae_dialaddcontrol(PA_LBE,0,act,id,0.0,0.0,0.0,"", 0,0.0,0.0,0.0,ddbcelemname(filename,elemname,ddbcl,style))); } void dial_lbddbclass(string filename,int ddbcl,int style) /* // Add DDB all elements of given class to list box // Parameters : // int act : Entry selection action code (0 no action) // int id : Entry ID // string filename : DDB file name // int ddbcl : DDB class code // int style : Comment display style */ { string elemname = ""; // DDB element name // Store list box entries while (scanddbenames(filename,ddbcl,elemname)==1) dial_lbddbentry(0,0,filename,elemname,ddbcl,style); } int dial_sbentry(int act,int id,string str) /* // Add standard selection box entry // Return value : // Entry dialog box item index or (-1) on creation failure // Parameters : // int act : Entry selection action code (0 no action) // int id : Entry ID // string str : Entry string */ { // Return dialog box item index return(bae_dialaddcontrol(PA_SBE,0,act,id,0.0,0.0,0.0,"", 0,0.0,0.0,0.0,str)); } int dial_action(double x,double y,int action,string str) /* // Create left aligned label // Return value : // Label dialog box item index or (-1) on creation failure // Parameters : // double x : Button column // double y : Button row // int action : Button action code // string str : Button string */ { double butx /* Button column */; // Adjust column butx=x; x+=bae_dialgettextlen(0,str)+(bae_swconfig(3)==2 ? 2.0 : 0.0); // Return dialog box item index return(bae_dialaddcontrol(PA_ACT,0,action,0,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+butx,y,0.0,str)); } void dial_okabort(double y) /* // Create left aligned OK and abort buttons, adjust row // Parameters : // double y : Button row */ { // Store the OK and abort button bae_dialaddcontrol(PA_OK,0,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,y,0.0,""); bae_dialaddcontrol(PA_ABORT,0,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG+5.0,y,0.0,""); y+=DIAL_BUTVSTEP+DIAL_SEPVSTEP; } void dial_okabortini(double y,double width,int iniact) /* // Create left aligned OK and abort buttons, adjust row // Parameters : // double y : Button row // double width : Dialog box width // int iniact : bae.ini save action code */ { string ininame = M(DE_UPRBAEINISAV,EN_UPRBAEINISAV); // INI save action button name // Store the OK and abort button bae_dialaddcontrol(PA_OK,0,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG,y,0.0,""); bae_dialaddcontrol(PA_ABORT,0,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG+5.0,y,0.0,""); bae_dialaddcontrol(PA_ACT,0,iniact,0,0.0,0.0,0.0, M(DE_UPRBAEINITIP,EN_UPRBAEINITIP),0,DIAL_LEFTMARG+width- bae_dialgettextlen(0,ininame)-DIAL_RIGHTEMARG,y,0.0,ininame); y+=DIAL_BUTVSTEP+DIAL_SEPVSTEP; } void dial_getboxsize(int boxid,double w,double h,double defw, double defh) /* // Get dialog box size // Parameters : // int boxid : Dialog box ID // double w, h : Dialog box size return // double defw, defh : Dialog box default size */ { // Set box ID bae_setintpar(16,boxid); // Try to load previously used box size if (bae_getdblpar(8,w)) { // Use default size w=defw; h=defh; } else { // Get buffered height bae_getdblpar(9,h); } } void dial_getboxsizemin(int boxid,double w,double h,double defw, double defh, double minw,double minh) /* // Get dialog box size // Parameters : // int boxid : Dialog box ID // double w, h : Dialog box size return // double defw, defh : Dialog box default size // double minw, minh : Dialog box minimum size */ { // Set box ID bae_setintpar(16,boxid); // Try to load previously used box size if (bae_getdblpar(8,w)) { // Use default size w=defw; h=defh; } else { // Get buffered height bae_getdblpar(9,h); } if (w0) = precede parent dir name // (<0) = blank-sep. append parent dir name // int namemode : Name creation mode : // (-2) = store dirs. only; append slash // (-1) = store directory names only // ( 0) = ignore directory names // ( 1) = store directory names // ( 2) = append slash to dir names // ( 3) = enclose directory names in [] // ( 4) = precede with type indicator // ( 5) = append type indicator // int sortmode : Name sort mode : // ( 0) = no sort // ( 1) = sort by names (numeric sort) // else = sort by names (standard sort) // int quitenable : Quit enable mode : // ( 0) = quit disabled // (>0) = function abort enabled // (<0) = program abort enabled */ { string fn; // Current file name string ufn; // Upper case file name string fullpath; // Full path name buffer string subdir; // Sub-directory path name buffer int dirflag; // Directory name flag string n1,n2; // Name string buffers int slb; // Search lower boundary int sub; // Search upper boundary int sidx; // Search index int compres; // Compare result int classchk = bae_iniintval(PAR_CLASSCHK,1); // Check DDB class flag // Abort if given directory name is invalid if (filetype(dirname)!=0) return(-1); // Issue the directory scan message message(M_REPSCANDIR(),dirname); // Scan the directory fn=""; while (scandirfnames(dirname,fext,fn)==1) { // Check on abort request if (quitenable && kbhit() && verify(quitenable<0 ? M_UPRPEXIT() : M_UPRFEXIT(),0)) { // Evaluate the abort level if (quitenable>0) // Abort function return(1); // Abort program error_abort(); } // Get full path name if (dirname!=CURDIR) fullpath=dirname+"/"+fn; else fullpath=fn; // Test if currently scanned name is directory if (dirflag=(filetype(fullpath)==0)) { // Save the sub-directory path name subdir=fullpath; } else { // Evaluate the file name wildcard if (wildcard) { strupper(ufn=fn); if (!strmatch(ufn,wildcard)) // No wildcard match continue; } // Test if DDB file check is requested if (ddbcl && classchk) { // Skip non-interesting (DDB) files if (ddbcheck(fullpath,ddbcl,"")) continue; } } // Test if name must be stored if (!dirflag || namemode) { // Set the default file name if (dirprec>0 && dirname!=CURDIR) fullpath=dirname+"/"+fn; else if (dirprec<0) fullpath=fn+" "+dirname; else fullpath=fn; // Evaluate the directory mode switch (namemode) { // Append slash if directory case 2 : if (dirflag) { if (dirprec<0) fullpath=fn+"/ "+dirname; else fullpath+="/"; } break; // Enclose with brackets if directory case 3 : if (dirflag) { if (dirprec<0) fullpath="["+fn+"] "+dirname; else fullpath="["+fullpath+"]"; } break; // Precede with type indicator case 4 : fullpath= (dirflag ? ITMDIR : ITMFILE)+fullpath; break; // Append type indicator case 5 : if (dirprec<0) fullpath=fn+" "+ (dirflag ? ITMDIR : ITMFILE)+dirname; else fullpath+= " "+(dirflag ? ITMDIR : ITMFILE); break; // Store directory names only case (-1) : if (!dirflag) continue; break; case (-2) : if (!dirflag) continue; if (dirprec<0) fullpath=fn+"/ "+dirname; else fullpath+="/"; } // Insert the name to the name list if (sortmode) { // Store file name to sorted list // Init the search area slb=0; sub=namen-1; compres=1; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Get first name string if (namemode==4 && (strmatch(fullpath,ITMFILE+"*") || strmatch(fullpath,ITMDIR+"*"))) n1=strextract(fullpath, ITMTYPLEN,MAXPNLEN); else n1=fullpath; // Get second name string n2=namel[sidx]; if (strmatch(n2,ITMFILE+"*") || strmatch(n2,ITMDIR+"*")) n2=strextract(n2, ITMTYPLEN,MAXPNLEN); // Compare names if ((compres=sortmode==1 ? numstrcmp(n1,n2):strcmp(n1,n2))==0) // Ignore multiple names break; // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Avoid multiple name entries if (compres) { // Insert name to name list for (sidx=namen;sidx>slb;sidx--) namel[sidx]=namel[sidx-1]; namel[slb]=fullpath; namen++; } } else { // Just append name to list namel[namen++]=fullpath; } } // Test if sub-directory scan is requested if (dirflag && dirscan && fn!=CURDIR && fn!=PARDIR) { // Perform recursive directory scan if (filelist(namel,namen,subdir, fext,wildcard,ddbcl,dirscan-1,dirprec, namemode,sortmode,quitenable)==1) // Abort file listing return(1); // Re-issue the directory scan message message(M_REPSCANDIR(),dirname); } } // Return without errors return(0); } string askfile(string prompt,STRINGS extlist,int ddbcl) /* // Menu-driven select a file name among those with extensions // Return value : // file name or empty string if none selected // Parameters : // string prompt : Prompt string (""=disable select) // STRINGS extlist : File name extension list // int ddbcl : DDB class selector : // ( 0) = no DDB file check // (-1) = any DDB file // else = DDB file with given DDB class */ { STRINGS mheadl; // Header string list int mheadn = 2; // Header string count STRINGS entryl; // Entry string list int entryn; // Entry list string project; // Project name string dpath = getcwd(); // Current directory path name string fname = UINPOPCONT; // Current file name string cmpfname; // Compare file name string anyext = bae_swversion(3); // Any file name extension pattern int extlistn; // Extension list length int extidx; // Extension index int dpathchg = 1; // Directory path changed flag int dirscanned; // Directory scanned flag int classchk = bae_iniintval(PAR_CLASSCHK,1); // Check DDB class flag int last; // Last path character index // Abort if no extensions specified if ((extlistn=arylength(extlist))<=0) return(""); if (extlistn==1 && (extlist[0]!=DDBEXT || !classchk)) { fname= extlist[0]==DDBEXT || ddbcl==(-1) ? bae_planfname() : "" ; if (bae_askfilename(fname,extlist[0],prompt)) return(""); return(fname==UINPOPABORT ? "" : fname); } // Check current directory if (dpath=="") dpath=CURDIR; // Disable the project name selection project=UINPOPABORT; // Check on valid plan file name if (ddbcl && prompt && bae_planfname()) // Loop thru the extension list for (extidx=0;extidx0 && (dpath[last]=='/' || dpath[last]=='\\')) dpath[last]='\0'; } break; } } // Perform the file name selection while (fname==UINPOPCONT) { // Test if directory path changed if (dpathchg) { // Define the header mheadl[0]=M_REPPOPDIR(dpath); mheadl[1]=""; // Reset the directory scanned flag dirscanned=0; // (Re-)init the entry list entryn=0; // Loop thru the extension list for (extidx=0;extidx=0;extidx--) if (fname[extidx]==' '|| fname[extidx]=='\t') fname[extidx]='\0'; else break; // Abort on request if (fname==UINPOPABORT || fname=="") return(""); // Test on DOS drive specification if (strmatch(fname,"?:*") && isalpha(fname[0])) { // Test on directory specification if (filetype(fname)==0) { // Assume new DOS drive directory path dpath=fname; // Continue fname=UINPOPCONT; continue; } // Assume file name specification return(fname); } // Test on root directory specification if (fname=="/" || fname=="\\" || fname=="\\." || fname=="/.") { // Goto (OS-platform-conform) root directory if (bae_swconfig(0)==BAE_Professional && filetype(bae_swversion(4)+".")==0) dpath=bae_swversion(4)+"."; else if (bae_swconfig(0)==BAE_HighEnd) dpath=bae_swversion(4); else dpath=fname; // Continue fname=UINPOPCONT; continue; } // Test if absolute path name reference if (strmatch(fname,"/?*") || strmatch(fname,"\\?*")) { // Done if selected name does not refer a dir. if (filetype(fname)!=0) return(fname); // Update the current directory path dpath=fname; // Continue fname=UINPOPCONT; continue; } // Strip directory delimiter from selected path strdelchr(fname,"/\\",strlen(fname)-1,MAXPNLEN); // Test if current directory selected if (fname==CURDIR) { // Continue dpathchg=0; fname=UINPOPCONT; continue; } // Test if parent directory selected if (fname==PARDIR) { // Test if valid parent directory if (filetype(dpath+bae_swversion(4)+PARDIR)==0 && !strmatch(dpath,"*"+PARDIR) && strmatch(dpath,"?*/?*")) // Goto parent directory dpath=strextract(dpath,0, strscanprior(dpath,"/\\",MAXPNLEN,1)-1); else { // Append parent directory path if (dpath!=CURDIR) dpath+=bae_swversion(4)+PARDIR; else dpath=PARDIR; } // Continue fname=UINPOPCONT; continue; } // Test if subdirectory selected if (filetype(dpath+bae_swversion(4)+fname)==0) { // Set new directory path name if (dpath!=CURDIR) dpath+=bae_swversion(4)+fname; else dpath=fname; // Continue fname=UINPOPCONT; continue; } // Build the complete file path name if (dpath!=CURDIR) fname=dpath+bae_swversion(4)+fname; } // Return the selected file name (or empty string on abort) return(fname==UINPOPABORT ? "" : fname); } //__________________________________________________________________ // DDB file access string askddbfile(string prompt,int ddbcl) /* // Perform DDB file selection with popup menu // Return value : // name of selected DDB file, or empty string on abort // Parameters : // string prompt : Prompt string // int ddbcl : DDB class (-1 = any DDB file) */ { STRINGS extl = {DDBEXT}; // Extension list string fname; // File name buffer // Perform the file name selection fname=askfile(prompt,extl,ddbcl); // Append DDB file extension if no extension if (fname && strscannext(fname,".", strscanprior(fname,"/\\",MAXPNLEN,1)+1,1)>strlen(fname)) fname+=DDBEXT; // Clear the dialog line bae_prtdialog(""); // Return the file name return(fname); } void loadddbelem(string filename,string elemname,int ddbcl) /* // Load DDB element with extended error handling // Parameters : // string filename : File name // string elemname : Element name // int ddbcl : DDB class */ { // User Language program name definitions #define UL_LOADFONT "loadfont" // ULP Load Font #define UL_CHKSMAC "chksmac" // ULP Check SCM Macros #define UL_CHKLMAC "chklmac" // ULP Check Layout Macros #define UL_CHKIMAC "chkimac" // ULP Check IC Design Macros #define UL_CHECKLNL "checklnl" // ULP Check Layout vs. Netlist #define UL_CHECKINL "checkinl" // ULP Check IC Design vs. Netlist string ERRDDBACC = M( // DDB access error message "Zugriff auf DDB-Datei '%s' fehlgeschlagen!", "Error accessing DDB file '%s'!"); string progname; // Program name int pver; // Program version int ptyp; // Program type // Check if element exists if (ddbcheck(filename,ddbcl,elemname)) { // Check on file or element access error if (ddbcheck(filename,DDBCLUNDEF,"")) { // Reset batch mode flag bae_setintpar(22,0); // DDB file access error errormsg(ERRDDBACC,filename); } else { // Reset batch mode flag bae_setintpar(22,0); // Element not found sprintf(progname,ERRELMACC, ddbclassname(ddbcl),elemname,filename); error(progname); } } // Load the element switch (bae_loadelem(filename,elemname,ddbcl)) { // Element successfully loaded case 0 : break; // Missing character font case 1 : // Suggest load font program run if available if (ulproginfo(UL_LOADFONT,pver,ptyp)==0 && pver<=ulipversion() && pver>=ULCOMPVERSION && (ptyp & uliptype()) && verify(UPRLDFONT,0)) { // Run the load font program runulprog(UL_LOADFONT); // Test if valid font loaded now if (bae_fontname()) // Re-load the current element loadddbelem(filename,elemname,ddbcl); } break; // Incomplete macros case 2 : // Get macro check program name for current interpreter progname=""; if (uliptype() & ULIPCAP) progname=UL_CHKSMAC; else if (uliptype() & ULIPLAY) progname=UL_CHKLMAC; else if (uliptype() & ULIPICD) progname=UL_CHKIMAC; else break; // Suggest macro check program run if available if (ulproginfo(progname,pver,ptyp)==0 && pver<=ulipversion() && pver>=ULCOMPVERSION && (ptyp & uliptype()) && verify(UPRCHKMAC,0)) // Run the macro check program runulprog(progname); break; // Parts changed within netlist case 3 : // Get netlist check program name for current interpreter progname=""; if (uliptype() & ULIPLAY) progname=UL_CHECKLNL; else if (uliptype() & ULIPICD) progname=UL_CHECKINL; else break; // Suggest netlist check program run if available if (ulproginfo(progname,pver,ptyp)==0 && pver<=ulipversion() && pver>=ULCOMPVERSION && (ptyp & uliptype()) && verify(UPRCHKNET,0)) // Run the netlist check program runulprog(progname); break; } // Undefine User Language program name definitions #undef UL_LOADFONT #undef UL_CHKSMAC #undef UL_CHKLMAC #undef UL_CHKIMAC #undef UL_CHECKLNL #undef UL_CHECKINL } void verifysave() /* // Save currently loaded unsaved element with verify */ { string msg; // Message string // Build the message string sprintf(msg,UPRSAVE,bae_planename(),bae_planfname()); // Save current element on request if (bae_plannotsaved() && verify(msg,1) && bae_storeelem(bae_planfname(),bae_planename())<0) // Save error error(ERRSAVE); } //__________________________________________________________________ // Message and error handling int BAE_Demo_check(int action) /* // Check if currently running in BAE Demo software configuration // Return value : // nonzero if in BAE Demo, or zero else // Parameters : // int action : Action to be taken if running BAE demo : // ( 1) = issue Demo output disabled warning // ( 2) = issue Demo output disabled message // and abort program with error // else = no action */ { // Messages string msg = M( "Mit BAE Demo ist keine Ausgabe auf externe Dateien moeglich!", "BAE Demo does not support output to external files!"); // Return without errors if not running in BAE Demo if (bae_swconfig(1)!=BAE_Demo) return(0); // Currently running in BAE Demo // Evaluate the action request code switch (action) { // Issue BAE Demo output disabled message case 1 : popupmessage( 1,-1,-1,msg,"",""); break; // Issue BAE Demo output disabled error and abort program case 2 : popupmessage(-1,-1,-1,msg,"",""); break; } // BAE Demo running return(-1); } void err_intern(string fctname) /* // Issue internal error message and exit from program // Parameters : // string fctname : Name of function causing internal error */ { // Message definitions string fmt = M( "Interner Fehler in '%s' - bitte an Programmierer melden!", "Internal error in '%s' - please report to programmer!"); string msg; // Error message string buffers // Build error message sprintf(msg,fmt,fctname); // Issue error message with popup popupmessage(-1,-1,-1,msg,"",""); } //__________________________________________________________________ // End library-specific source code #endif // LIBPOP #endif // USELIB // Conditional file inclusion end #endif // INCLUDE_POP // User Language include file end