<commit_before>/* ***********************************************************************************************

    Unify Project

    Homepage: unify-project.org
    License: MIT + Apache (V2)
    Copyright: 2010, <NAME>, Mainz, Germany, http://unify-training.com

*********************************************************************************************** */

/**
 * The label widget implements text representation in unify widget system
 */
qx.Class.define("unify.ui.widget.basic.Label", {
  extend : unify.ui.widget.core.Widget,
  
  /**
   * Creates a new instance of Label
   * @param text {String} Text content to use 
   */
  construct : function(text) {
    if (text) {
      this.setValue(text);
    }
  },
  
  properties : {
    /** Contains the label content */
    value : {
      check: "String",
      apply: "_applyValue",
      event: "changeValue",
      nullable: true
    },
    
    html : {
      check: "Boolean",
      init: false,
      event: "changeHtml"
    },
    
    // overridden
    allowGrowX : {
      refine : true,
      init : false
    },


    // overridden
    allowGrowY : {
      refine : true,
      init : false
    },

    // overridden
    allowShrinkY : {
      refine : true,
      init : false
    }
  },
  
  members : {
    // overridden
    _createElement : function() {
      return qx.bom.Label.create(this.getValue(), this.getHtml());
    },
    
    /**
     * Applies text to element
     * @param value {String} New value to set
     */
    _applyValue : function(value) {
      qx.bom.Label.setValue(this.getElement(), value);
    }
  }
});
<commit_msg>Add content hint for label to support fonts<commit_after>/* ***********************************************************************************************

    Unify Project

    Homepage: unify-project.org
    License: MIT + Apache (V2)
    Copyright: 2010, <NAME>, Mainz, Germany, http://unify-training.com

*********************************************************************************************** */

/**
 * The label widget implements text representation in unify widget system
 */
qx.Class.define("unify.ui.widget.basic.Label", {
  extend : unify.ui.widget.core.Widget,
  
  /**
   * Creates a new instance of Label
   * @param text {String} Text content to use 
   */
  construct : function(text) {
    if (text) {
      this.setValue(text);
    }
  },
  
  properties : {
    /** Contains the label content */
    value : {
      check: "String",
      apply: "_applyValue",
      event: "changeValue",
      nullable: true
    },
    
    html : {
      check: "Boolean",
      init: false,
      event: "changeHtml"
    },
    
    // overridden
    allowGrowX : {
      refine : true,
      init : false
    },


    // overridden
    allowGrowY : {
      refine : true,
      init : false
    },

    // overridden
    allowShrinkY : {
      refine : true,
      init : false
    }
  },
  
  members : {
    __contentSize : null,
  
    // overridden
    _createElement : function() {
      return qx.bom.Label.create(this.getValue(), this.getHtml());
    },
    
    // overridden
    _getContentHint : function()
    {
      var contentSize = this.__contentSize;
      if (!contentSize)
      {
        contentSize = this.__contentSize = this.__computeContentSize();
      }

      console.log("CONTENT SIZE: ",{
        width : contentSize.width,
        height : contentSize.height
      });

      return {
        width : contentSize.width,
        height : contentSize.height
      };
    },
    
    /**
     * Internal utility to compute the content dimensions.
     *
     * @return {Map} Content size
     */
    __computeContentSize : function()
    {
      var Label = qx.bom.Label;

      var styles = this.getFont();
      console.log("x", styles);
      var content = this.getValue() || "A";

      return Label.getTextSize(content, styles);
    },
    
    /**
     * Applies text to element
     * @param value {String} New value to set
     */
    _applyValue : function(value) {
      this.__contentSize = null;
      qx.bom.Label.setValue(this.getElement(), value);
    }
  }
});

{'fraction_non_alphanumeric': 0.20748792270531402, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 2.2250778816199377, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2009018', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1191, 'n_words': 275}