Package g4p_controls.StyledString

Examples of g4p_controls.StyledString.TextLayoutHitInfo


      dragging = false;
      if(stext == null || stext.length() == 0)
        stext = new StyledString(" ", wrapWidth);
//      text = stext.getPlainText();
      LinkedList<TextLayoutInfo> lines = stext.getLines(buffer.g2);
      startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
      startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);

      endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
      int lastChar = endTLHI.tli.layout.getCharacterCount();
      endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);

      calculateCaretPos(endTLHI);
      bufferInvalid = true;
View Full Code Here


   * @return the selected text without styling
   */
  public String getSelectedText(){
    if(!hasSelection())
      return "";
    TextLayoutHitInfo startSelTLHI;
    TextLayoutHitInfo endSelTLHI;
    if(endTLHI.compareTo(startTLHI) == -1){
      startSelTLHI = endTLHI;
      endSelTLHI = startTLHI;
    }
    else {
View Full Code Here

   * @param style
   */
  public void setSelectedTextStyle(TextAttribute style, Object value){
    if(!hasSelection())
      return;
    TextLayoutHitInfo startSelTLHI;
    TextLayoutHitInfo endSelTLHI;
    if(endTLHI.compareTo(startTLHI) == -1){
      startSelTLHI = endTLHI;
      endSelTLHI = startTLHI;
    }
    else {
View Full Code Here

   * Clear any styles applied to the selected text.
   */
  public void clearStyle(){
    if(!hasSelection())
      return;
    TextLayoutHitInfo startSelTLHI;
    TextLayoutHitInfo endSelTLHI;
    if(endTLHI.compareTo(startTLHI) == -1){
      startSelTLHI = endTLHI;
      endSelTLHI = startTLHI;
    }
    else {
View Full Code Here

      return false;
    setStyledText(ss);
    // Now restore any text selection
    if(stext.startIdx >=0){ // we have a selection
      // Selection starts at ...
      startTLHI = new TextLayoutHitInfo();
      startTLHI.tli = stext.getTLIforCharNo(stext.startIdx);
      int pInLayout = stext.startIdx - startTLHI.tli.startCharIndex;
      if(pInLayout == 0)
        startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
      else
        startTLHI.thi = startTLHI.tli.layout.getNextRightHit(pInLayout - 1);
      // Selection ends at ...
      endTLHI = new TextLayoutHitInfo();
      endTLHI.tli = stext.getTLIforCharNo(stext.endIdx);
      pInLayout = stext.endIdx - endTLHI.tli.startCharIndex;

      if(pInLayout == 0)
        endTLHI.thi = endTLHI.tli.layout.getNextLeftHit(1);
View Full Code Here

      if(lines.isEmpty() && defaultText != null)
        lines = defaultText.getLines(g2d);
       
      bufferInvalid = false;

      TextLayoutHitInfo startSelTLHI = null, endSelTLHI = null;
      buffer.beginDraw();
      // Whole control surface if opaque
      if(opaque)
        buffer.background(palette[6]);
      else
View Full Code Here

        if(stext == null || stext.length() == 0){
          stext = new StyledString(" ", wrapWidth);
          stext.getLines(buffer.g2);
        }
        endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
        startTLHI = new TextLayoutHitInfo(endTLHI);
        calculateCaretPos(endTLHI);
        bufferInvalid = true;
      }
      else { // Not over this control so if we have focus loose it
        if(focusIsWith == this)
View Full Code Here

        if(stext == null || stext.length() == 0){
          stext = new StyledString(" ", wrapWidth);
          stext.getLines(buffer.g2);
        }
        endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
        startTLHI = new TextLayoutHitInfo(endTLHI);
        calculateCaretPos(endTLHI);
        bufferInvalid = true;
      }
      else { // Not over this control so if we have focus loose it
        if(focusIsWith == this)
View Full Code Here

      LinkedList<TextLayoutInfo> lines = stext.getLines(g2d)
      if(lines.isEmpty() && defaultText != null)
        lines = defaultText.getLines(g2d);

      bufferInvalid = false;
      TextLayoutHitInfo startSelTLHI = null, endSelTLHI = null;
     
      buffer.beginDraw();
      // Whole control surface if opaque
      if(opaque)
        buffer.background(palette[6]);
View Full Code Here

TOP

Related Classes of g4p_controls.StyledString.TextLayoutHitInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.