6d7237baf9ecee276a4fcc0a3ed10dd5a7d3e0c9
tdreszer
  Mon Nov 28 15:18:57 2011 -0800
Moved calculating of squeezed matrix label heights to js, since it is so browser dependent.
diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 53da686..0009253 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -6153,212 +6153,195 @@
 #ifdef BUTTONS_BY_CSS
 printf(BUTTON_MAT, "true",  ",'", class, "'", '+');
 if (vertical)
     puts("<BR>");
 printf(BUTTON_MAT, "false", ",'", class, "'", '-');
 #else///ifndef BUTTONS_BY_CSS
 printf(PM_BUTTON_UC, "true",  ",'", class, "'", "", "", name,    "add_sm.gif");
 if (vertical)
     puts("<BR>");
 printf(PM_BUTTON_UC, "false", ",'", class, "'", "", "", name, "remove_sm.gif");
 #endif///def BUTTONS_BY_CSS
 }
 
 #define MATRIX_SQUEEZE 10
 #ifdef MATRIX_SQUEEZE
-static int matrixSqueeze(membersForAll_t* membersForAll)
+static boolean matrixSqueeze(membersForAll_t* membersForAll)
 // Returns non-zero if the matrix will be squeezed.  Non-zero is actually squeezedLabelHeight
 {
 char *browserVersion;
 if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '9')
     return 0;
 
-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 = mgFontStringWidth(mgTimes10Font(), ptr);
-                ttlLen += (6 * 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/14)+1;
-        else
-            labelHeight = 0;
+            return TRUE;
         }
     }
-return labelHeight;
+return FALSE;
 }
 #else///ifndef MATRIX_SQUEEZE
-#define matrixSqueeze(membersForAll) 0
+#define matrixSqueeze(membersForAll) FALSE
 #endif///ndef MATRIX_SQUEEZE
 
-static void matrixXheadingsRow1(char *db,struct trackDb *parentTdb,int squeeze, membersForAll_t* membersForAll,boolean top)
+static void matrixXheadingsRow1(char *db,struct trackDb *parentTdb,boolean 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];
 
 #ifdef MATRIX_SQUEEZE
 printf("<TR ALIGN=CENTER valign=%s>\n",top?"BOTTOM":"TOP");
 #else///ifndef MATRIX_SQUEEZE
 printf("<TR ALIGN=CENTER BGCOLOR='%s' valign=%s>\n",COLOR_BG_ALTDEFAULT,top?"BOTTOM":"TOP");
 #endif///ndef MATRIX_SQUEEZE
 if(dimensionX && dimensionY)
     {
     printf("<TH ALIGN=LEFT valign=%s>",top?"TOP":"BOTTOM");
+    //printf("<TH ALIGN=LEFT valign=%s>",(top == squeeze)?"BOTTOM":"TOP");//"TOP":"BOTTOM");
     buttonsForAll();
     puts("&nbsp;All</TH>");
     }
 
 // If there is an X dimension, then titles go across the top
 if(dimensionX)
     {
     int ixX,cntX=0;
     if(dimensionY)
         {
         #ifdef MATRIX_SQUEEZE
-        if(squeeze>0)
-            printf("<TH align=RIGHT style='height:%d.2em;'><div class='%s'><B><EM>%s</EM></B></div></TH>",
-                   squeeze, (top?"up45":"dn45"), dimensionX->groupTitle);
+        if(squeeze)
+            printf("<TH align=RIGHT><div class='%s'><B><EM>%s</EM></B></div></TH>",
+                   (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)
+            if(dimensionY && squeeze)
                 {
                 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++;
             }
         }
     // If dimension is big enough, then add Y buttons to right as well
     if(cntX>MATRIX_RIGHT_BUTTONS_AFTER)
         {
         if(dimensionY)
             {
             #ifdef MATRIX_SQUEEZE
-            if(squeeze>0)
+            if(squeeze)
                 printf("<TH align=LEFT><div class='%s'><B><EM>%s</EM></B></div></TH>",
                     (top?"up45":"dn45"), dimensionX->groupTitle);
             else
             #endif///def MATRIX_SQUEEZE
                 printf("<TH align=LEFT><B><EM>%s</EM></B></TH>", dimensionX->groupTitle);
             printf("<TH ALIGN=RIGHT valign=%s>All&nbsp;",top?"TOP":"BOTTOM");
+            //printf("<TH ALIGN=RIGHT valign=%s>All&nbsp;",(top == squeeze)?"BOTTOM":"TOP");//"TOP":"BOTTOM");
             buttonsForAll();
             puts("</TH>");
             }
         else
             printf("<TH ALIGN=LEFT valign=%s><B><EM>%s</EM></B>&nbsp;&nbsp;</TH>",top?"TOP":"BOTTOM", dimensionX->groupTitle);
         }
     }
 else if(dimensionY)
     {
     printf("<TH ALIGN=RIGHT WIDTH=100 nowrap>");
     printf("<B><EM>%s</EM></B>", dimensionY->groupTitle);
     printf("</TH><TH ALIGN=CENTER WIDTH=60>");
     buttonsForAll();
     puts("</TH>");
     }
 puts("</TR>\n");
 }
 
-static void matrixXheadingsRow2(struct trackDb *parentTdb, int squeeze, membersForAll_t* membersForAll)
+static void matrixXheadingsRow2(struct trackDb *parentTdb, boolean squeeze, membersForAll_t* membersForAll)
 /* prints the 2nd row of a matrix: Y title; X buttons; title Y */
 {
 members_t *dimensionX = membersForAll->members[dimX];
 members_t *dimensionY = membersForAll->members[dimY];
 
 // If there are both X and Y dimensions, then there is a row of buttons in X
 if(dimensionX && dimensionY)
     {
     int ixX,cntX=0;
     #ifdef MATRIX_SQUEEZE
     printf("<TR ALIGN=CENTER><TH ALIGN=CENTER colspan=2><B><EM>%s</EM></B></TH>",dimensionY->groupTitle);
     #else///ifndef MATRIX_SQUEEZE
     printf("<TR ALIGN=CENTER BGCOLOR=\"%s\"><TH ALIGN=CENTER colspan=2><B><EM>%s</EM></B></TH>",COLOR_BG_ALTDEFAULT, dimensionY->groupTitle);
     #endif///ndef MATRIX_SQUEEZE
     for (ixX = 0; ixX < dimensionX->count; ixX++)    // Special row of +- +- +-
         {
         if(dimensionX->subtrackList && dimensionX->subtrackList[ixX] && dimensionX->subtrackList[ixX]->val)
             {
             char objName[SMALLBUF];
             #ifdef MATRIX_SQUEEZE
             printf("<TD nowrap class='matCell %s all'>\n",dimensionX->tags[ixX]);
             #else///ifndef MATRIX_SQUEEZE
             puts("<TD>");
             #endif///ndef MATRIX_SQUEEZE
             safef(objName, sizeof(objName), "plus_%s_all", dimensionX->tags[ixX]);
-            boolean vertical = FALSE;
-            #ifdef MATRIX_SQUEEZE
-            vertical = (squeeze>0);
-            #endif///def MATRIX_SQUEEZE
-            buttonsForOne( objName, dimensionX->tags[ixX], vertical );
+            buttonsForOne( objName, dimensionX->tags[ixX], squeeze );
             puts("</TD>");
             cntX++;
             }
         }
     // If dimension is big enough, then add Y buttons to right as well
     if(cntX>MATRIX_RIGHT_BUTTONS_AFTER)
         printf("<TH ALIGN=CENTER colspan=2><B><EM>%s</EM></B></TH>", dimensionY->groupTitle);
     puts("</TR>\n");
     }
 }
 
-static int matrixXheadings(char *db,struct trackDb *parentTdb, membersForAll_t* membersForAll,boolean top)
+static boolean matrixXheadings(char *db,struct trackDb *parentTdb, membersForAll_t* membersForAll,boolean top)
 /* UI for X headings in matrix */
 {
-int squeeze = matrixSqueeze(membersForAll);
+boolean squeeze = matrixSqueeze(membersForAll);
 
 if(top)
     matrixXheadingsRow1(db,parentTdb,squeeze,membersForAll,top);
 
     matrixXheadingsRow2(parentTdb,squeeze,membersForAll);
 
 if(!top)
     matrixXheadingsRow1(db,parentTdb,squeeze,membersForAll,top);
 
 return squeeze;
 }
 
 static void matrixYheadings(char *db,struct trackDb *parentTdb, membersForAll_t* membersForAll,int ixY,boolean left)
 /* prints the column of Y labels and buttons */
 {
@@ -6697,31 +6680,30 @@
 
 if(membersForAll->abcCount > 0 && membersForAll->filters == FALSE)
     {
     displayABCdimensions(db,cart,parentTdb,subtrackRefList,membersForAll);
     }
 
 if(dimensionX == NULL && dimensionY == NULL) // Could have been just filterComposite. Must be an X or Y dimension
     return FALSE;
 
 #ifdef MATRIX_SQUEEZE
 printf("<TABLE class='greenBox matrix' cellspacing=0 style='background-color:%s;'>\n",COLOR_BG_ALTDEFAULT);
 #else///ifndef MATRIX_SQUEEZE
 printf("<TABLE class='greenBox' style='background-color:%s;'>\n",COLOR_BG_DEFAULT);
 #endif///ndef MATRIX_SQUEEZE
 
-//int squeeze = matrixXheadings(db,parentTdb,membersForAll,TRUE); // right side labels could be dependent upon squeeze
 (void)matrixXheadings(db,parentTdb,membersForAll,TRUE);
 
 // Now the Y by X matrix
 int cntX=0,cntY=0;
 for (ixY = 0; ixY < sizeOfY; ixY++)
     {
     if(dimensionY == NULL || (dimensionY->tags[ixY]))
         {
         cntY++;
         assert(!dimensionY || ixY < dimensionY->count);
     #ifdef MATRIX_SQUEEZE
         printf("<TR ALIGN=CENTER>");
     #else///ifndef MATRIX_SQUEEZE
         printf("<TR ALIGN=CENTER BGCOLOR='%s'>",COLOR_BG_ALTDEFAULT);
     #endif///ndef MATRIX_SQUEEZE