f7086ca9f432d2f720809669557aa76831bf8ad5
tdreszer
  Wed Nov 23 14:54:25 2011 -0800
New calculation for squeezed label height
diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 66f3595..fe6a9b9 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -23,30 +23,31 @@
 #include "customTrack.h"
 #include "encode/encodePeak.h"
 #include "mdb.h"
 #include "web.h"
 #include "hPrint.h"
 #include "fileUi.h"
 #include "bigBed.h"
 #include "bigWig.h"
 #include "vcfUi.h"
 #include "vcf.h"
 #include "errCatch.h"
 #include "samAlignment.h"
 #include "makeItemsItem.h"
 #include "bedDetail.h"
 #include "pgSnp.h"
+#include "memgfx.h"
 
 #define SMALLBUF 128
 #define MAX_SUBGROUP 9
 #define ADD_BUTTON_LABEL        "add"
 #define CLEAR_BUTTON_LABEL      "clear"
 #define JBUFSIZE 2048
 
 #ifdef BUTTONS_BY_CSS
 #define BUTTON_PM  "<span class='pmButton' onclick=\"setCheckBoxesThatContain('%s',%s,true,'%s','','%s')\">%c</span>"
 #define BUTTON_DEF "<span class='pmButton' onclick=\"setCheckBoxesThatContain('%s',true,false,'%s','','%s'); " \
                                                     "setCheckBoxesThatContain('%s',false,false,'%s','_defOff','%s');\" style='width:56px;font-weight:normal; font-family:default;'>default</span>"
 #define DEFAULT_BUTTON(nameOrId,anc,beg,contains) printf(BUTTON_DEF,(nameOrId),        (beg),(contains),(nameOrId),(beg),(contains))
 #define    PLUS_BUTTON(nameOrId,anc,beg,contains) printf(BUTTON_PM, (nameOrId),"true", (beg),(contains),'+')
 #define   MINUS_BUTTON(nameOrId,anc,beg,contains) printf(BUTTON_PM, (nameOrId),"false",(beg),(contains),'-')
 #else///ifndef BUTTONS_BY_CSS
@@ -6173,39 +6174,43 @@
 
 boolean labelHeight = 0;
 members_t *dimensionX = membersForAll->members[dimX];
 members_t *dimensionY = membersForAll->members[dimY];
 if(dimensionX && dimensionY)
     {
     if(dimensionX->count>MATRIX_SQUEEZE)
         {
         int ixX,cntX=0;
         for (ixX = 0; ixX < dimensionX->count; ixX++)
             {
             if(dimensionX->subtrackList && dimensionX->subtrackList[ixX] && dimensionX->subtrackList[ixX]->val)
                 {
                 cntX++;
                 char *ptr = dimensionX->titles[ixX];
-                int ttlLen = strlen(ptr);
-                while((ptr = strstr(ptr+1,"&nbsp;")) != NULL)  // &nbsp; ????
-                    ttlLen -= 5;
+                int ttlLen = mgFontStringWidth(mgTimes10Font(), ptr);
+                ttlLen += (7 * countCase(ptr,TRUE)); // double counts upperCase letters
+                while((ptr = strstr(ptr+1,"&nbsp;")) != NULL)   // &nbsp; dropped from calculation
+                    ttlLen -= 35;
+                ptr = dimensionX->titles[ixX];
+                while((ptr = strstr(ptr+1,"<BR>")) != NULL)     // Breaks will be removed later
+                    ttlLen -= 21;
                 if (labelHeight < ttlLen)
                     labelHeight = ttlLen;
                 }
             }
         if(cntX>MATRIX_SQUEEZE)
-            labelHeight = (labelHeight * 8) + 5;//0.50;
+            labelHeight = labelHeight + 30;
         else
             labelHeight = 0;
         }
     }
 return labelHeight;
 }
 #else///ifndef MATRIX_SQUEEZE
 #define matrixSqueeze(membersForAll) 0
 #endif///ndef MATRIX_SQUEEZE
 
 static void matrixXheadingsRow1(char *db,struct trackDb *parentTdb,int squeeze, membersForAll_t* membersForAll,boolean top)
 /* prints the top row of a matrix: 'All' buttons; X titles; buttons 'All' */
 {
 members_t *dimensionX = membersForAll->members[dimX];
 members_t *dimensionY = membersForAll->members[dimY];
@@ -6233,32 +6238,35 @@
             printf("<TH align=RIGHT style='height:%dpx;'><div class='%s'><B><EM>%s</EM></B></div></TH>",
                    squeeze, (top?"up45":"dn45"), dimensionX->groupTitle);
         else
         #endif///def MATRIX_SQUEEZE
             printf("<TH align=RIGHT><B><EM>%s</EM></B></TH>", dimensionX->groupTitle);
         }
     else
         printf("<TH ALIGN=RIGHT valign=%s>&nbsp;&nbsp;<B><EM>%s</EM></B></TH>",(top?"TOP":"BOTTOM"), dimensionX->groupTitle);
 
     for (ixX = 0; ixX < dimensionX->count; ixX++)
         {
         if(dimensionX->subtrackList && dimensionX->subtrackList[ixX] && dimensionX->subtrackList[ixX]->val)
             {
         #ifdef MATRIX_SQUEEZE
             if(dimensionY && squeeze>0)
+                {
+                strSwapStrs(dimensionX->titles[ixX],strlen(dimensionX->titles[ixX]),"<BR>"," "); // Breaks must be removed!
                 printf("<TH nowrap='' class='%s'><div class='%s'>%s</div></TH>\n",dimensionX->tags[ixX],(top?"up45":"dn45"),
                        compositeLabelWithVocabLink(db,parentTdb,dimensionX->subtrackList[ixX]->val,dimensionX->groupTag,dimensionX->titles[ixX]));
+                }
             else
         #endif///def MATRIX_SQUEEZE
                 {
                 char *label =replaceChars(dimensionX->titles[ixX]," (","<BR>(");
         #ifdef MATRIX_SQUEEZE
                 printf("<TH WIDTH='60' class='matCell %s all'>&nbsp;%s&nbsp;</TH>",dimensionX->tags[ixX],
         #else///ifndef MATRIX_SQUEEZE
                 printf("<TH WIDTH='60'>&nbsp;%s&nbsp;</TH>",
         #endif///ndef MATRIX_SQUEEZE
                        compositeLabelWithVocabLink(db,parentTdb,dimensionX->subtrackList[ixX]->val,dimensionX->groupTag,label));
                 freeMem(label);
                 }
             cntX++;
             }
         }