/* POPDRAW.ULH (STD) -- Popup Drawing Functions */ /* POPDRAW.ULH (STD) -- Popup-Zeichenfunktionen */ /* // Copyright (c) 1997-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 (070205) ENHANCEMENT: // btp_drawwidearc function added. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (050305) ENHANCEMENT: // popicon_rmouse function added. // rl (040830) RELEASED FOR BAE V6.4. // rl (040830) ENHANCEMENT: // Added popicon_char function. // rl (040307) ENHANCEMENT: // Added pop_drawline function. // rl (030904) RELEASED FOR BAE V6.2. // rl (030512) ENHANCEMENT: // Added inverted color palette correction. // rl (030325) ENHANCEMENT: // Added bitmap drawing utility functions. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (010329) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (001108) ENHANCEMENT: // popicon_lmouse function added. // rl (000509) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (990415) CHANGE: // Added attribute window count definition // rl (980910) RELEASED FOR BAE V4.2. // mb (980723) ENHANCEMENT: // popicon_filenew and popicon_filesave functions added. // mb (980630) CHANGE: // popicon_help function added; // zoom icons and file open icon slightly modified. // rl (980526) ENHANCEMENT: // popicon_fileopen function added. // rl (970929) RELEASED FOR BAE V4.0. // mb (970630) ORIGINAL CODING: // // DESCRIPTION // // The definitions and declarations from include file popdraw.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). popdraw.ulh provides general utilities // and definitions for performing icon and button display and graphical // output within popup menus and for maintaining toolbars. // // FUNCTIONS // // Popup drawing primitives: // pop_aspectratio -- Get/set the aspect ratio // pop_drawline -- Draw a line to popup area // pop_drawpoly -- Draw a polygon to popup area // pop_drawrect -- Draw a rectangle to popup area // pop_displaytext -- Display length restricted text in popup area // // Popup icon/button display routines: // popicon_char -- Display Character button // popicon_info -- Display Info button // popicon_help -- Display Help button // popicon_control -- Display Control button // popicon_filenew -- Display File/New button // popicon_fileopen -- Display File/Open button // popicon_filesave -- Display File/Save button // popicon_down -- Display Down button // popicon_up -- Display Up button // popicon_left -- Display Left button // popicon_right -- Display Right button // popicon_lmouse -- Display Left Mouse button // popicon_rmouse -- Display Right Mouse button // popicon_zoomin -- Display View/Zoom In button // popicon_zoomout -- Display View/Zoom Out button // popicon_zoomwnd -- Display View/Zoom Window button // // Popup logo display routines: // popicon_bartels -- Display Bartels button // poplogo_bartels -- Display Bartels logo // // Bitmap drawing primitives: // bmp_setsize -- Set the bitmap dialog size and transformation matrix // // Bitmap/toolbar/popup drawing primitives // btp_drawcircle -- Draw circle // btp_drawrect -- Draw rectangle // btp_drawline -- Draw line // btp_drawwideline -- Draw wide line // btp_drawwidearc -- Draw wide arc line // btp_drawtext -- Draw text // btp_setcoordtrans -- Set the area coordinate transformation // btp_setdashlen -- Set the dash base length // btp_storepoint -- Store polygon point with coordinate transformation */ // Avoid multiple inclusions #ifndef INCLUDE_POPDRAW #define INCLUDE_POPDRAW // Includes #include "std.ulh" // User Language standard include // INI file parameter name definitions #define PAR_TB_ATT_STD "TB_ATTSTD_STD" // Standard menu toolbar attachment #define PAR_TB_ATT_PDW "TB_ATTPDW_STD" // Pulldown menu toolbar attachment #define PAR_TB_ATTRCNT "TB_ATTRWCNT_SCM" // Toolbar attribute window count #define PAR_TB_LCOLCNT "TB_LCOLCNT_LAY"// Toolbar layer color button count #define PAR_TB_LCOLDIR "TB_LCOLDIR_LAY"// Toolbar layer color count direction #define PAR_TB_PLCOLCNT "TB_PLCOLCNT_LAY" // Toolbar power layer color but.count #define PAR_TB_ALCOLCPAT "TB_ALCOLC%d_LAY" // Toolbar any layer color button code #define PAR_TB_ALCOLTPAT "TB_ALCOLT%d_LAY" // Toolbar any layer color button text #define PAR_TB_DLCOLPAT "TB_DLCOL%d_LAY" // Toolbar doc. layer color button row #define PAR_TB_DLCOLNPAT "TB_DLCOLN%d_LAY" // Toolbar doc. layer color button name #define PAR_TB_ACTBUTN "TB_ACTBUTN%d_STD" // Toolbar action button name #define PAR_TB_ACTBUTS "TB_ACTBUTS%d_STD" // Toolbar action button sequence #define PAR_TB_ACTBUTT "TB_ACTBUTT%d_STD" // Toolbar action button tooltip #define PAR_TB_ACTBUTTC "TB_ACTBUTTC%d_STD" // Toolbar action button text color #define PAR_TB_ACTBUTBC "TB_ACTBUTBC%d_STD" // Toolbar act. button background color // Toolbar display and attachment modes #define GV_TB_ATTACH "tb_attach" // Toolbar attachment variable name #define TB_ATTACH_INV (-1) // Toolbar invisible/fade-out #define TB_ATTACH_BOT 0 // Toolbar bottom attachment #define TB_ATTACH_RGT 1 // Toolbar right attachment #define TB_ATTACH_TOP 2 // Toolbar top attachment #define TB_ATTACH_LFT 3 // Toolbar left attachment #define TB_MAXDCOLROW 32 // Max. documentary layer button rows #define TB_MAXACTBUT 256 // Max. action buttons static int TB_ATTACH_STD = bae_iniintval(PAR_TB_ATT_STD,TB_ATTACH_TOP); // Standard menu toolbar attachment static int TB_ATTACH_PDW = bae_iniintval(PAR_TB_ATT_PDW,TB_ATTACH_LFT); // Pulldown menu toolbar attachment static int TB_ATTRW_CNT = bae_iniintval(PAR_TB_ATTRCNT,2); // Toolbar attribute window count static int TB_LCOL_CNT = bae_iniintval(PAR_TB_LCOLCNT,8); // Toolbar layer color button count static int TB_LCOL_DIR = bae_iniintval(PAR_TB_LCOLDIR,0); // Toolbar layer color count direction static int TB_PLCOL_CNT = bae_iniintval(PAR_TB_PLCOLCNT,0); // Toolbar power layer color but.count // Global variable name patterns for toolbar design view maintenance #define GV_TB_DVX "tb_dvx" // Design view X coordinate #define GV_TB_DVY "tb_dvy" // Design view Y coordinate #define GV_TB_DVW "tb_dvw" // Design view width #define GV_TB_DVH "tb_dvh" // Design view height #define GV_TB_DVN "tb_dvn" // Toolbar window count #define GV_TB_LCX "tb_lcx" // Layer button X coordinate #define GV_TB_LCY "tb_lcy" // Layer button Y coordinate #define GV_TB_LCW "tb_lcw" // Layer button width #define GV_TB_LCH "tb_lch" // Layer button height #define GV_TB_PICKLAY "tb_picklay" // Pick layer #define GV_TB_PICKLAST "tb_picklast" // Pick last layer #define GV_TB_TOPLAY "tb_toplay" // Top layer #define GV_TB_ITOPLAY "tb_itoplay" // Inner top layer #define GV_TB_DVLX "tb_dvlx" // Toolbar design view lower x var. name #define GV_TB_DVLY "tb_dvly" // Toolbar design view lower y var. name #define GV_TB_DVUX "tb_dvux" // Toolbar design view upper x var. name #define GV_TB_DVUY "tb_dvuy" // Toolbar design view upper y var. name #define GV_TB_BGRIDX "tb_bgridx" // Toolbar background grid disp. x pos. #define GV_TB_BGRIDY "tb_bgridy" // Toolbar background grid disp. y pos. #define GV_TB_IGRIDX "tb_igridx" // Toolbar input grid disp. x pos. #define GV_TB_IGRIDY "tb_igridy" // Toolbar input grid disp. y pos. // Global variable names for toolbar zoom window management #define GV_TB_ZOOMFN "tb_zoomfn" // Toolbar zoom file name #define GV_TB_ZOOMEN "tb_zoomen" // Toolbar zoom element name #define GV_TB_ZOOMCLASS "tb_zoomclass" // Toolbar zoom element class #define GV_TB_ZOOMON "tb_zoomon" // Toolbar zoom disp. flag var. name #define GV_TB_ZOOMLX "tb_zoomlx" // Toolbar zoom lower x var. name #define GV_TB_ZOOMLY "tb_zoomly" // Toolbar zoom lower y var. name #define GV_TB_ZOOMUX "tb_zoomux" // Toolbar zoom upper x var. name #define GV_TB_ZOOMUY "tb_zoomuy" // Toolbar zoom upper y var. name #define GV_TB_ZOOMV "tb_zoomv" // Toolbar zoom variant disp. var.name #define GV_TB_ZOOMXO "tb_zoomxo" // Toolbar zoom x offset var. name #define GV_TB_ZOOMYO "tb_zoomyo" // Toolbar zoom y offset var. name #define GV_TB_ZOOMXS "tb_zoomxs" // Toolbar zoom x scale var. name #define GV_TB_ZOOMYS "tb_zoomys" // Toolbar zoom y scale var. name // Global variable names for toolbar history buttons management #define GV_TB_HISTNX "tb_histnx" // History next item x coordinate #define GV_TB_HISTNY "tb_histny" // History next item y coordinate #define GV_TB_HISTPX "tb_histpx" // History previous item x coordinate #define GV_TB_HISTPY "tb_histpy" // History previous item y coordinate #define GV_TB_HIERREQ "hier_req" // Hierarchy requested block ref. name #define GV_TB_HISTMAX "hist_max" // History max. fill count #define GV_TB_HISTPOS "hist_pos" // History current position #define GV_TB_HISTBASE "hist_base" // History base position #define GV_TB_HISTFN "hist_fn%d" // History file name #define GV_TB_HISTEN "hist_en%d" // History element name #define GV_TB_HISTCL "hist_class%d" // History element class #define GV_TB_HISTLX "hist_lx%d" // History zoom window lower x corner #define GV_TB_HISTLY "hist_ly%d" // History zoom window lower y corner #define GV_TB_HISTUX "hist_ux%d" // History zoom window upper x corner #define GV_TB_HISTUY "hist_uy%d" // History zoom window upper y corner #define GV_TB_HISTACT "hist_active" // History load active flag #define HISTMAX 32 // Session history max. count // Popup polygon filling modes #define PPFM_CLINE 0 // Closed line polygon #define PPFM_FILL 1 // Closed fill polygon #define PPFM_LINE 2 // Open line polygon // Button draw definitions #define BUTSCALE 1.3 // Button scaling factor // Color definitions #define COLOR_NONE (-1) // No color #define COLOR_BLACK 0 // Black #define COLOR_BLUE 1 // Blue #define COLOR_GREEN 2 // Green #define COLOR_CYAN 3 // Cyan #define COLOR_RED 4 // Red #define COLOR_MAGENTA 5 // Magenta #define COLOR_BROWN 6 // Brown #define COLOR_LGRAY 7 // Light gray #define COLOR_DGRAY 8 // Dark gray #define COLOR_LBLUE 9 // Light blue #define COLOR_LGREEN 10 // Light green #define COLOR_LCYAN 11 // Light cyan #define COLOR_LRED 12 // Light red #define COLOR_LMAGENTA 13 // Light magenta #define COLOR_YELLOW 14 // Yellow #define COLOR_WHITE 15 // White #define COLOR_WBORDER 16 // Window border color #define COLOR_WSHADOW 17 // Window shadow color #define COLOR_WBACK 18 // Window background color #define COLOR_WFORE 19 // Window foreground color #define COLOR_BBACK 20 // Button background color #define COLOR_BTEXT 21 // Button text color #define COLOR_RGB 22 // RGB color specification #define COLOR_IMASK 0xFF // Color index mask static int TCOLOR_WHITE = bae_getinvcolor() ? COLOR_BLACK : COLOR_WHITE; // True white color palette index static int TCOLOR_BLACK = bae_getinvcolor() ? COLOR_WHITE : COLOR_BLACK; // True black color palette index // Text only color definitions #define TPOPBORDCOL 16 // Popup border color #define TPOPFRAMECOL 17 // Popup frame color #define TPOPBACKCOL 18 // Popup background color #define TPOPTEXTCOL 19 // Popup text color #define TPOPBUTBCOL 20 // Popup button background color #define TPOPBUTTCOL 21 // Popup button text color // Popup polygon type defintions typedef struct { // Popup polygon point descriptor double px; // Popup polygon point X coord. double py; // Popup polygon point Y coord. int ptyp; // Popup polygon point type } POPPOLYPT; // Popup polygon point type typedef struct { // Popup polygon descriptor int color; // Popup polygon color int drawm; // Popup polygon drawing mode int fillm; // Popup polygon filling mode POPPOLYPT pl[]; // Popup polygon point list } POPPOLY; // Popup polygon type typedef POPPOLY POPICON[]; // Popup icon type definition //__________________________________________________________________ // Start library-specific source code #ifndef USELIB #ifndef LIBPOPDRAW // Globals static double curaspectratio = (-1.0); // Aspect ratio static double curbtpxoff = 0; // Popup coord. x offset static double curbtpyoff = 0; // Popup coord. y offset static double curbtpxscale = 0.0; // Popup coord. x scale factor static double curbtpyscale = 0.0; // Popup coord. y scale factor //__________________________________________________________________ // Basic popup icon/button display routines double pop_aspectratio() /* // Get/set the aspect ratio */ { double cxsize; // Character X size double cysize; // Character Y size // Set the aspect ratio if not yet set if (curaspectratio<=0.0) { // Get the character size bae_charsize(cxsize,cysize); // Calculate the aspect ratio (ensure cast to double!) curaspectratio=cysize; curaspectratio/=cxsize; } // Return aspect ratio value return(curaspectratio); } //__________________________________________________________________ // Popup drawing utilities void pop_drawline(double xs,double ys,double xe,double ye,int col) /* // Draw a rectangle to popup area // Parameters : // double xs : Line start X coordinate // double ys : Line start Y coordinate // double xe : Line end X coordinate // double ye : Line end Y coordinate // int col : Line color */ { // Clear the point list bae_clearpoints(); // Store the line points bae_storepoint(xs,ys,0); bae_storepoint(xe,ye,0); // Draw the polygon bae_popdrawpoly(col,DM_REPLACE,PPFM_LINE); // Done } void pop_drawpoly( POPPOLY poly,double x,double y,double hscale,double vscale) /* // Draw a polygon to popup area // Parameters : // POPPOLY poly : Polygon // double x : Polygon X offset // double y : Polygon Y offset // double hscale : Polygon horizontal scaling factor // double vscale : Polygon vertical scaling factor */ { int pn; // Polygon point count int i; // Loop control variable // Get the polygon point count pn=arylength(poly.pl); // Clear the point list bae_clearpoints(); // Store all polygon points for (i=0;i=0) pop_drawpoly(poly,x,y,1.0,1.0); // Display the rectangle frame/outline on request if (frcol>=0) { poly.color=frcol; poly.fillm=PPFM_CLINE; pop_drawpoly(poly,x,y,1.0,1.0); } // Done } void pop_displaytext(double row,double col, int maxlen,int cutend,int fcolor,int bcolor,string text) /* // Display length restricted text in popup area // Parameters : // double row : Text row // double col : Text column // int maxlen : Max. text string length // int cutend : Cut string end flag // int fcolor : Text foreground color // int bcolor : Text background color // string text : Text string */ { string outstr; // Text output string int len = strlen(text); // Text string length // Check the string length if (len>maxlen) { // Check string cut side if (cutend) // Cut the string start outstr=strextract(text,len-maxlen,len); else // Cut the string end outstr=strextract(text,0,maxlen-1); } else { // Get the string outstr=text; sprintf(outstr,"%-*s",maxlen,text); } // Draw the full text field bae_popdrawtext(row,col,fcolor,bcolor,outstr); } //__________________________________________________________________ // Popup button display routines static void pop_displayicon( POPICON icon,double x,double y,double hscale,double vscale) /* // Display a icon within popup menue // Parameters : // POPICON poly : Icon // double x : Icon X offset // double y : Icon Y offset // double hscale : Icon horizontal scaling factor // double vscale : Icon vertical scaling factor */ { int n = arylength(icon); // Icon polygon count int i; // Loop control variable // Draw all icon polygons for (i=0;iwidth) { // Correct the heigth height*=width/nwidth; curbtpyscale=height/ydim; } else { // Correct the width width=nwidth; } curbtpxscale=fabs(curbtpyscale)*aspectratio; // Calculate the center offset cx=-0.5*(owidth-width)/curbtpxscale; cy=-0.5*(oheight-height)/curbtpyscale; // Return without errors return(0); } void btp_setcoordtrans(double xoff,double yoff,double xscale,double yscale) /* // Set the popup coordinate transformation matrix // Parameters : // double xoff, yoff : Translation offset // double xscale, yscale : Coordinate scale factors */ { // Get the drawing offset curbtpxoff=xoff; curbtpyoff=yoff; // Get the drawing scale factors curbtpxscale=xscale; curbtpyscale=yscale; } void btp_setdashlen(double dashlen,double dashspc) /* // Set the popup base dash length // Parameters : // double dashlen : Dash base length // double dashspc : Dash relative spacing */ { // Set the transformed dash base length bae_setpopdash(dashlen*fabs(curbtpyscale),dashspc); } int btp_storepoint(double x,double y,int typ) /* // Store polygon point with bitmap transformation // Return value : // Returns non-zero on error // Parameters : // double x, y : Point coordinates // int typ : Point type */ { // Store the transformed point return(bae_storepoint((x-curbtpxoff)*curbtpxscale, (y-curbtpyoff)*curbtpyscale,(typ && curbtpyscale<0.0) ? 3-typ : typ)); } int btp_drawcircle( int color,int drawmode,int fillflag,double xc,double yc,double rad) /* // Draw circle to bitmap // Return value : // Returns non-zero on error // Parameters : // int color : Circle color // int drawmode : Circle draw mode // int fillflag : Circle fill flag // double xs, ys : Circle center coordinates // double rad : Circle radius */ { // Store the circle points bae_clearpoints(); btp_storepoint(xc-rad,yc,0); btp_storepoint(xc,yc,1); btp_storepoint(xc+rad,yc,0); btp_storepoint(xc,yc,1); // Draw the circle return( bae_popdrawpoly(color,drawmode,fillflag ? PPFM_FILL : PPFM_CLINE)); } int btp_drawrect(int color,int drawmode,int fillflag, double x,double y,double width,double height) /* // Draw rectangle to bitmap // Return value : // Returns non-zero on error // Parameters : // int color : Rectangle color // int drawmode : Rectangle draw mode // int fillflag : Rectangle fill flag // double xs, ys : Rectangle start coordinates // double width,height : Rectangle dimensions */ { // Store the rectangle points bae_clearpoints(); btp_storepoint(x,y,0); btp_storepoint(x+width,y,0); btp_storepoint(x+width,y+height,0); btp_storepoint(x,y+height,0); // Draw the rectangle return( bae_popdrawpoly(color,drawmode,fillflag ? PPFM_FILL : PPFM_CLINE)); } int btp_drawline( int color,int drawmode,double xs,double ys,double xe,double ye) /* // Draw line to bitmap // Return value : // Returns non-zero on error // Parameters : // int color : Line color // int drawmode : Line draw mode // double xs, ys : Line start coordinates // double xe, ye : Line end coordinates */ { // Store the line points bae_clearpoints(); btp_storepoint(xs,ys,0); btp_storepoint(xe,ye,0); // Draw the line return(bae_popdrawpoly(color,drawmode,PPFM_LINE)); } int btp_drawwideline(int color,int drawmode,int fillflag, double xs,double ys,double xe,double ye,double width) /* // Draw line to bitmap // Return value : // Returns non-zero on error // Parameters : // int color : Line color // int drawmode : Line draw mode // int fillflag : Line fill flag // double xs, ys : Line start coordinates // double xe, ye : Line end coordinates // double width : Line width */ { double dfac /* Factor for circle points calc. */; double rad /* Line radius */; double d /* Line length */; double dx,dy /* Line vector */; // Get the line radius rad=0.5*width; // Start and end points not identical ? bae_clearpoints(); if ((xs!=xe)||(ys!=ye)) { // Get the line vector dx=xe-xs; dy=ye-ys; // Get the line length d=sqrt(dx*dx+dy*dy); dfac=rad/d; dx*=dfac; dy*=dfac; // Store polygon points if (btp_storepoint(xe-dy,ye+dx,0) || btp_storepoint(xe,ye,2) || btp_storepoint(xe+dy,ye-dx,0) || btp_storepoint(xs+dy,ys-dx,0) || btp_storepoint(xs,ys,2) || btp_storepoint(xs-dy,ys+dx,0)) return(-1); } else { // Store circle if (btp_storepoint(xs+rad,ys,0) || btp_storepoint(xs,ys,1) || btp_storepoint(xs-rad,ys,0) || btp_storepoint(xs,ys,1)) return(-1); } // Draw the line area return( bae_popdrawpoly(color,drawmode,fillflag ? PPFM_FILL : PPFM_CLINE)); } int btp_drawwidearc(int color,int drawmode,int fillflag, double xs,double ys,double xc,double yc,double xe,double ye,int dir, double width) /* // Draw line to bitmap // Return value : // Returns non-zero on error // Parameters : // int color : Arc color // int drawmode : Arc draw mode // int fillflag : Arc fill flag // double xs, ys : Arc start coordinates // double xc, yc : Arc center coordinates // double xe, ye : Arc end coordinates // int dir : Arc direction // double width : Arc line width */ { double dfac /* Factor for circle points calc. */; double rad /* Line radius */; double d /* Line length */; double dx,dy /* Line vector */; // Get the line radius rad=0.5*width; // Get the first radius vector dx=xc-xs; dy=yc-ys; // Get the line length d=sqrt(dx*dx+dy*dy); dfac=rad/d; dx*=dfac; dy*=dfac; // Store polygon points bae_clearpoints(); if (btp_storepoint(xs-dx,ys+dy,0) || btp_storepoint(xs,ys,dir) || btp_storepoint(xs+dx,ys-dy,0) || btp_storepoint(xc,yc,dir)) return(-1); // Get the second radius vector dx=xc-xe; dy=yc-ye; // Get the line length d=sqrt(dx*dx+dy*dy); dfac=rad/d; dx*=dfac; dy*=dfac; if (btp_storepoint(xe-dx,ye+dy,0) || btp_storepoint(xe,ye,dir) || btp_storepoint(xe+dx,ye-dy,0) || btp_storepoint(xc,yc,dir==2 ? 1 : 2)) return(-1); // Draw the arc line area return( bae_popdrawpoly(color,drawmode,fillflag ? PPFM_FILL : PPFM_CLINE)); } int btp_drawtext(double x,double y,int fcol,int bcol,string txt) /* // Draw line to bitmap // Return value : // Returns non-zero on error // Parameters : // double x, y : Text coordinates // int fcol : Text foreground color // int bcol : Text background color // string txt : Text string */ { // Draw the transformed text return(bae_popdrawtext((y-curbtpyoff)*curbtpyscale, (x-curbtpxoff)*curbtpxscale,fcol,bcol,txt)); } //__________________________________________________________________ // End library-specific source code #endif // LIBPOPDRAW #endif // USELIB // Conditional file inclusion end #endif // INCLUDE_POPDRAW // User Language include file end