You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2007/07/10 17:26:00 UTC

svn commit: r554973 - in /myfaces/tobago/trunk: example/demo/src/main/webapp/ example/demo/src/main/webapp/reference/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ theme/scarborough/src/main/resource...

Author: lofwyr
Date: Tue Jul 10 08:25:59 2007
New Revision: 554973

URL: http://svn.apache.org/viewvc?view=rev&rev=554973
Log:
TOBAGO-440: Buttons with proptional font should calculate text size more exactly

Added:
    myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago.properties.xml
      - copied, changed from r554966, myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml
Modified:
    myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp
    myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp?view=diff&rev=554973&r1=554972&r2=554973
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp Tue Jul 10 08:25:59 2007
@@ -1,11 +1,3 @@
-<%@ page import="org.apache.myfaces.tobago.example.reference.SimpleBean" %>
-<%@ page import="org.apache.myfaces.tobago.model.TreeState" %>
-<%@ page import="javax.faces.application.FacesMessage" %>
-<%@ page import="javax.faces.context.FacesContext" %>
-<%@ page import="javax.swing.tree.DefaultMutableTreeNode" %>
-<%@ page import="java.io.PrintWriter" %>
-<%@ page import="java.io.StringWriter" %>
-<%@ page import="java.util.Date" %>
 <%--
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -28,7 +20,7 @@
 
   <tc:panel>
     <f:facet name="layout">
-      <tc:gridLayout columns="70px;70px;130px;1*" rows="15px;fixed"/>
+      <tc:gridLayout columns="fixed;fixed;fixed;*" rows="15px;fixed"/>
     </f:facet>
 
     <tc:cell spanX="4">

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp?view=diff&rev=554973&r1=554972&r2=554973
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp Tue Jul 10 08:25:59 2007
@@ -23,7 +23,7 @@
   <jsp:body>
     <tc:box label="Command Controls">
       <f:facet name="layout">
-        <tc:gridLayout columns="100px;100px;100px;100px;*" rows="fixed;fixed;fixed;fixed;fixed;fixed;*"/>
+        <tc:gridLayout columns="100px;100px;100px;100px;*" rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;*"/>
       </f:facet>
 
       <%-- standard --%>
@@ -101,6 +101,33 @@
       <tc:link label="N/A"  disabled="true"/>
       <tc:link label="Link" link="http://www.apache.org/" target="Command Target"/>
       <tc:cell/>
+
+      <%-- dynamic widths --%>
+
+      <tc:cell spanX="5">
+        <tc:panel>
+          <f:facet name="layout">
+            <tc:gridLayout rows="fixed" columns="fixed;fixed;fixed;*"/>
+          </f:facet>
+
+          <tc:button label="Hello" />
+          <tc:button label="WWWWWWWWWW" />
+          <tc:button label="llllllllll" />
+          <tc:cell/>
+
+        </tc:panel>
+      </tc:cell>
+      <tc:cell spanX="5">
+        <tc:panel>
+          <f:facet name="layout">
+            <tc:gridLayout rows="fixed" columns="fixed;*"/>
+          </f:facet>
+
+          <tc:button label="The goal of Tobago is to provide the community with a well designed set of user interface components." />
+          <tc:cell/>
+
+        </tc:panel>
+      </tc:cell>
 
       <%-- empty --%>
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java?view=diff&rev=554973&r1=554972&r2=554973
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java Tue Jul 10 08:25:59 2007
@@ -126,7 +126,6 @@
     return defaultCommand ? "submit" : "button";
   }
 
-
   public int getFixedWidth(FacesContext facesContext, UIComponent component) {
     int width = 0;
     String imageName = (String) component.getAttributes().get(ATTR_IMAGE);
@@ -136,7 +135,7 @@
     LabelWithAccessKey label = new LabelWithAccessKey(component);
 
     if (label.getText() != null) {
-      width += label.getText().length()*getConfiguredValue(facesContext, component, "fontWidth");
+      width += calculateStringWidth(facesContext, component, label.getText());
     }
     int padding = getConfiguredValue(facesContext, component, "paddingWidth");
     width += 2 * padding;
@@ -147,4 +146,25 @@
     return width;
 
   }
+
+  private int calculateStringWidth(FacesContext facesContext, UIComponent component, String text) {
+    int width = 0;
+    int defaultCharWidth = getConfiguredValue(facesContext, component, "fontWidth");
+
+    String fontWidths = ResourceManagerUtil.getProperty(facesContext, "tobago", "tobago.font.widths");
+
+    for (char c : text.toCharArray()) {
+      int charWidth;
+      if (c >= 32 && c < 128) {
+        int begin = (c - 32) * 2;
+        charWidth = Integer.parseInt(fontWidths.substring(begin, begin + 2), 16);
+      } else {
+        charWidth = defaultCharWidth;
+      }
+      width += charWidth;
+    }
+
+    return width;
+  }
+
 }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml?view=diff&rev=554973&r1=554972&r2=554973
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml Tue Jul 10 08:25:59 2007
@@ -102,4 +102,8 @@
 
 <entry key="tobago.ajax.response.error">Server Error: unable to serve request. Probably a session timeout!</entry>
 
+<!-- Font metric for ArialMT plain 14 -->
+<!-- The String contains all widths for char 32 to 127. Each pair of 2 chars is a hex value-->
+<entry key="tobago.font.widths">04040508080c09030505050804050404080808080808080808080404080808080e09090a0a09090b0a040709080c0a0b090b0a09090a090d0909090404040708050808070808040808030307030c0808080805070408070a070707050405080b</entry>
+
 </properties>

Copied: myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago.properties.xml (from r554966, myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago.properties.xml?view=diff&rev=554973&p1=myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml&r1=554966&p2=myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago.properties.xml&r2=554973
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago.properties.xml (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago.properties.xml Tue Jul 10 08:25:59 2007
@@ -19,87 +19,8 @@
 
 <properties>
 
-<!-- Client Configuration -->
-<entry key="configTitle">Client configuration of the Tobago framework</entry>
-<entry key="configTheme">Theme</entry>
-<entry key="configThemeWithAccessKey">_Theme</entry>
-<entry key="configThemeText">Which theme should be used?</entry>
-<entry key="configDebugMode">Use _debug mode</entry>
-<entry key="configLocale">Locale</entry>
-<entry key="configLocaleText">Which locale should be used?</entry>
-<entry key="configContentType">Content type</entry>
-<entry key="configContentTypeText">Which Content-Type should be used?</entry>
-<entry key="configSubmit">Submit</entry>
-<entry key="configButtonText">Configuration</entry>
-<entry key="configCachecoverage">Cache coverage</entry>
-
-<!-- Sheet -->
-<entry key="sheetFirst">First Page</entry>
-<entry key="sheetPrev">Previous Page</entry>
-<entry key="sheetNext">Next Page</entry>
-<entry key="sheetLast">Last Page</entry>
-<entry key="sheetTipSorting">Click to sort this column</entry>
-<entry key="sheetAscending">Ascending</entry>
-<entry key="sheetDescending">Descending</entry>
-<entry key="sheetPagingInfoRows">Rows &lt;span id="{3}"&gt;{0}&lt;/span&gt; to {1} of {2}</entry>
-<entry key="sheetPagingInfoSingleRow">Row &lt;span id="{3}"&gt;{0}&lt;/span&gt; of {2}</entry>
-<entry key="sheetPagingInfoEmptyRow">No rows available</entry>
-<entry key="sheetPagingInfoRowPagingTip">Click here, to change the first displayed row</entry>
-<entry key="sheetPagingInfoPages">Page &lt;span id="{3}"&gt;{0}&lt;/span&gt; of {1}</entry>
-<entry key="sheetPagingInfoSinglePage">Page &lt;span id="{3}"&gt;{0}&lt;/span&gt; of {1}</entry>
-<entry key="sheetPagingInfoEmptyPage"></entry>
-<entry key="sheetPagingInfoPagePagingTip">Click here, to change the displayed page</entry>
-<entry key="sheetMenuToggleselect">Invert selections</entry>
-<entry key="sheetMenuUnselect">Unselect all</entry>
-<entry key="sheetMenuSelect">Select all</entry>
-
-<!-- Tree -->
-<entry key="treeNew">New</entry>
-<entry key="treeDelete">Delete</entry>
-<entry key="treeEdit">Edit</entry>
-<entry key="treeCut">Cut</entry>
-<entry key="treeCopy">Copy</entry>
-<entry key="treePaste">Paste</entry>
-<entry key="treeMoveUp">Move Up</entry>
-<entry key="treeMoveDown">Move Down</entry>
-<entry key="treeNodeNew">New Node</entry>
-
-<!-- datePicker -->
-<entry key="datePickerTitle">Date Picker</entry>
-<entry key="datePickerOk">OK</entry>
-<entry key="datePickerCancel">Cancel</entry>
-
-<!-- requiredvalidator -->
-<entry key="tobago.requiredvalidator.message.empty.summary">Required field.</entry>
-<entry key="tobago.requiredvalidator.message.empty.detail">Field is required.</entry>
-
- <!-- longrangevalidator -->
-<entry key="tobago.longrangevalidator.message.range.summary">Not in range.</entry>
-<entry key="tobago.longrangevalidator.message.range.detail">Value must be between {0} and {1}.</entry>
-<entry key="tobago.longrangevalidator.message.type.summary">Wrong type.</entry>
-<entry key="tobago.longrangevalidator.message.type.detail">Value is not of the correct type.</entry>
-<entry key="tobago.message.number_conversion_error.summary">Unable to convert number.</entry>
-<entry key="tobago.message.number_conversion_error.detail">Unable to convert ''{0}'' to number type {1}.</entry>
-<entry key="tobago.message.conversion_error.summary">Unable to convert.</entry>
-<entry key="tobago.message.conversion_error.detail">Unable to convert ''{0}'' to type {1}.</entry>
-<entry key="tobago.tree.MESSAGE_NOT_LEAF">Only leaf selection allowed.</entry>
-<entry key="tobago.SelectOne.MESSAGE_VALUE_REQUIRED">Selection required</entry>
-
-<!-- richtexteditor -->
-<entry key="tobago.richtexteditor.edit.label">Edit</entry>
-<entry key="tobago.richtexteditor.edit.title">Switch to editor mode.</entry>
-<entry key="tobago.richtexteditor.preview.label">Preview</entry>
-<entry key="tobago.richtexteditor.preview.title">Switch to preview mode.</entry>
-<entry key="browser.noframe.message.prefix">[ Your user agent does not support frames or is currently configured not to display frames. However, you may visit</entry>
-<entry key="browser.noframe.message.postfix">the related document. ]</entry>
-
-
-<!--  jsf messages -->
-<entry key="javax.faces.validator.LengthValidator.MAXIMUM">Maximum of "{0}" characters exceeded!</entry>
-<entry key="javax.faces.validator.LengthValidator.MAXIMUM_detail">Value is longer than allowable maximum of "{0}" characters!</entry>
-<entry key="javax.faces.validator.LengthValidator.MINIMUM">Minimum of "{0}" characters !</entry>
-<entry key="javax.faces.validator.LengthValidator.MINIMUM_detail">Value is shorter than allowable minimum of "{0}" characters!</entry>
-
-<entry key="tobago.ajax.response.error">Server Error: unable to serve request. Probably a session timeout!</entry>
+  <!-- Font metric for Arial-BoldMT bold 12-->
+  <!-- The String contains all widths for char 32 to 127. Each pair of 2 chars is a hex value-->
+  <entry key="tobago.font.widths">03040607070b09030404050703040303070707070707070707070404070707070c0909090908070909030709070a0909080909080709080b0808070403040707040707070707040707030307030b070707070507040707090707060503050709</entry>
 
 </properties>