Package org.zkoss.zss.ui.impl

Examples of org.zkoss.zss.ui.impl.HeaderPositionHelper$HeaderPositionInfo


    HelperContainer<HeaderPositionHelper> helpers = (HelperContainer) getAttribute(ROW_SIZE_HELPER_KEY);
    if (helpers == null) {
      setAttribute(ROW_SIZE_HELPER_KEY, helpers = new HelperContainer<HeaderPositionHelper>());
    }
    final String sheetId = ((SheetCtrl)sheet).getUuid();
    HeaderPositionHelper helper = helpers.getHelper(sheetId);
       
    int maxcol = 0;
    if (helper == null) {
      int defaultSize = this.getRowheight();
     
      List<HeaderPositionInfo> infos = new ArrayList<HeaderPositionInfo>();
     
      for(Row row: sheet) {
        final boolean hidden = row.getZeroHeight();
        final int height = Utils.getRowHeightInPx(sheet, row);
        if (height != defaultSize || hidden) { //special height or hidden
          infos.add(new HeaderPositionInfo(row.getRowNum(), height, _custRowId.next(), hidden));
        }
        final int colnum = row.getLastCellNum() - 1;
        if (colnum > maxcol) {
          maxcol = colnum;
        }
      }
     
      helpers.putHelper(sheetId, helper = new HeaderPositionHelper(defaultSize, infos));
    }
    return new HeaderPositionHelper[] {helper, myGetColumnPositionHelper(sheet, maxcol)};
  }
View Full Code Here


    HelperContainer<HeaderPositionHelper> helpers = (HelperContainer) getAttribute(COLUMN_SIZE_HELPER_KEY);
    if (helpers == null) {
      setAttribute(COLUMN_SIZE_HELPER_KEY, helpers = new HelperContainer<HeaderPositionHelper>());
    }
    final String sheetId = ((SheetCtrl)sheet).getUuid();
    HeaderPositionHelper helper = helpers.getHelper(sheetId);
   
    if (helper == null) {
      final int defaultColSize = sheet.getDefaultColumnWidth();
      final int defaultColSize256 = defaultColSize * 256;
      final int charWidth = getDefaultCharWidth();
      final int defaultColSizeInPx = Utils.defaultColumnWidthToPx(defaultColSize, charWidth);
      List<HeaderPositionInfo> infos = new ArrayList<HeaderPositionInfo>();
      for(int j=0; j <= maxcol; ++j) {
        final boolean hidden = sheet.isColumnHidden(j); //whether this column is hidden
        final int fileColumnWidth = sheet.getColumnWidth(j); //file column width
        if (fileColumnWidth != defaultColSize256 || hidden) {
          final int colwidth = fileColumnWidth != defaultColSize256 ?
              Utils.fileChar256ToPx(fileColumnWidth, charWidth) : defaultColSizeInPx;
          infos.add(new HeaderPositionInfo(j, colwidth, _custColId.next(), hidden));
        }
      }

      helpers.putHelper(sheetId, helper = new HeaderPositionHelper(defaultColSizeInPx, infos));
    }
    return helper;
  }
View Full Code Here

  private String getSheetDefaultRules() {

    Worksheet sheet = getSelectedSheet();

    HeaderPositionHelper colHelper = this.getColumnPositionHelper(sheet);
    HeaderPositionHelper rowHelper = this.getRowPositionHelper(sheet);
    MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);

    boolean hiderow = isHiderowhead();
    boolean hidecol = isHidecolumnhead();
    boolean showgrid = sheet.isDisplayGridlines();

    int th = hidecol ? 1 : this.getTopheadheight();
    int lw = hiderow ? 1 : this.getLeftheadwidth();
    int cp = this._cellpadding;//
    int rh = this.getRowheight();
    int cw = this.getColumnwidth();
    int lh = 20;// default line height;

    if (lh > rh) {
      lh = rh;
    }

    String sheetPrefix = " .s" + getSelectedSheetId();
    String name = "#" + getUuid();

    int cellwidth;// default
    int cellheight;// default
    Execution exe = Executions.getCurrent();

    boolean isGecko = exe.isGecko();
    boolean isIE = exe.isExplorer();
    // boolean isIE7 = exe.isExplorer7();

    if (isGecko) {// firefox
      cellwidth = cw;
      cellheight = rh;
    } else {
      cellwidth = cw - 2 * cp - 1;// 1 is border width
      cellheight = rh - 1;// 1 is border width
    }

    int celltextwidth = cw - 2 * cp - 1;// 1 is border width

    StringBuffer sb = new StringBuffer();

    // zcss.setRule(name+" .zsdata",["padding-top","padding-left"],[th+"px",lw+"px"],true,sid);
    sb.append(name).append(" .zsdata{");
    sb.append("padding-top:").append(th).append("px;");
    sb.append("padding-left:").append(lw).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zsrow","height",rh+"px",true,sid);
    sb.append(name).append(" .zsrow{");
    sb.append("height:").append(rh).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zscell",["padding","height","width","line-height"],["0px "+cp+"px 0px "+cp+"px",cellheight+"px",cellwidth+"px",lh+"px"],true,sid);
    sb.append(name).append(" .zscell{");
    sb.append("padding:").append("0px " + cp + "px 0px " + cp + "px;");
    sb.append("height:").append(cellheight).append("px;");
    sb.append("width:").append(cellwidth).append("px;");
    if (!showgrid) {
      sb.append("border-bottom:1px solid #FFFFFF;")
        .append("border-right:1px solid #FFFFFF;");
    }
    // sb.append("line-height:").append(lh).append("px;\n");
    sb.append("}");

    // zcss.setRule(name+" .zscelltxt",["width","height"],[celltextwidth+"px",cellheight+"px"],true,sid);
    sb.append(name).append(" .zscelltxt{");
    sb.append("width:").append(celltextwidth).append("px;");
    sb.append("height:").append(cellheight).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zstop",["left","height","line-height"],[lw+"px",(th-2)+"px",lh+"px"],true,sid);

    int toph = th - 1;
    int topheadh = (isGecko) ? toph : toph - 1;
    int cornertoph = th - 1;
    // int topblocktop = toph;
    int fzr = getRowfreeze();
    int fzc = getColumnfreeze();

    if (fzr > -1) {
      toph = toph + rowHelper.getStartPixel(fzr + 1);
    }

    sb.append(name).append(" .zstop{");
    sb.append("left:").append(lw).append("px;");
    sb.append("height:").append(fzr > -1 ? toph - 1 : toph).append("px;");
    // sb.append("line-height:").append(toph).append("px;\n");
    sb.append("}");

    sb.append(name).append(" .zstopi{");
    sb.append("height:").append(toph).append("px;");
    sb.append("}");

    sb.append(name).append(" .zstophead{");
    sb.append("height:").append(topheadh).append("px;");
    sb.append("}");

    sb.append(name).append(" .zscornertop{");
    sb.append("left:").append(lw).append("px;");
    sb.append("height:").append(cornertoph).append("px;");
    sb.append("}");

    // relative, so needn't set top position.
    /*
     * sb.append(name).append(" .zstopblock{\n");
     * sb.append("top:").append(topblocktop).append("px;\n");
     * sb.append("}\n");
     */

    // zcss.setRule(name+" .zstopcell",["padding","height","width","line-height"],["0px "+cp+"px 0px "+cp+"px",th+"px",cellwidth+"px",lh+"px"],true,sid);
    sb.append(name).append(" .zstopcell{");
    sb.append("padding:").append("0px " + cp + "px 0px " + cp + "px;");
    sb.append("height:").append(topheadh).append("px;");
    sb.append("width:").append(cellwidth).append("px;");
    sb.append("line-height:").append(topheadh).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zstopcelltxt","width", celltextwidth
    // +"px",true,sid);
    sb.append(name).append(" .zstopcelltxt{");
    sb.append("width:").append(celltextwidth).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zsleft",["top","width"],[th+"px",(lw-2)+"px"],true,sid);

    int leftw = lw - 1;
    int leftheadw = leftw;
    int leftblockleft = leftw;

    if (fzc > -1) {
      leftw = leftw + colHelper.getStartPixel(fzc + 1);
    }

    sb.append(name).append(" .zsleft{");
    sb.append("top:").append(th).append("px;");
    sb.append("width:").append(fzc > -1 ? leftw - 1 : leftw)
        .append("px;");
    sb.append("}");

    sb.append(name).append(" .zslefti{");
    sb.append("width:").append(leftw).append("px;");
    sb.append("}");

    sb.append(name).append(" .zslefthead{");
    sb.append("width:").append(leftheadw).append("px;");
    sb.append("}");

    sb.append(name).append(" .zsleftblock{");
    sb.append("left:").append(leftblockleft).append("px;");
    sb.append("}");

    sb.append(name).append(" .zscornerleft{");
    sb.append("top:").append(th).append("px;");
    sb.append("width:").append(leftheadw).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zsleftcell",["height","line-height"],[(rh-1)+"px",(rh)+"px"],true,sid);//for
    // middle the text, i use row leight instead of lh
    sb.append(name).append(" .zsleftcell{");
    sb.append("height:").append(rh - 1).append("px;");
    sb.append("line-height:").append(rh - 1).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zscorner",["width","height"],[(lw-2)+"px",(th-2)+"px"],true,sid);

    sb.append(name).append(" .zscorner{");
    sb.append("width:").append(fzc > -1 ? leftw : leftw + 1)
        .append("px;");
    sb.append("height:").append(fzr > -1 ? toph : toph + 1).append("px;");
    sb.append("}");

    sb.append(name).append(" .zscorneri{");
    sb.append("width:").append(lw - 2).append("px;");
    sb.append("height:").append(th - 2).append("px;");
    sb.append("}");

    sb.append(name).append(" .zscornerblock{");
    sb.append("left:").append(lw).append("px;");
    sb.append("top:").append(th).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zshboun","height",th+"px",true,sid);
    sb.append(name).append(" .zshboun{");
    sb.append("height:").append(th).append("px;");
    sb.append("}");

    // zcss.setRule(name+" .zshboun","height",th+"px",true,sid);
/*    sb.append(name).append(" .zshboun{\n");
    sb.append("height:").append(th).append("px;\n");
    sb.append("}\n");
*/
    // zcss.setRule(name+" .zshbouni","height",th+"px",true,sid);
    sb.append(name).append(" .zshbouni{");
    sb.append("height:").append(th).append("px;");
    sb.append("}");

    sb.append(name).append(" .zsfztop{");
    sb.append("border-bottom-style:").append(fzr > -1 ? "solid" : "none")
        .append(";");
    sb.append("}");
    sb.append(name).append(" .zsfzcorner{");
    sb.append("border-bottom-style:").append(fzr > -1 ? "solid" : "none")
        .append(";");
    sb.append("}");

    sb.append(name).append(" .zsfzleft{");
    sb.append("border-right-style:").append(fzc > -1 ? "solid" : "none")
        .append(";");
    sb.append("}");
    sb.append(name).append(" .zsfzcorner{");
    sb.append("border-right-style:").append(fzc > -1 ? "solid" : "none")
        .append(";");
    sb.append("}");

    // TODO transparent border mode
    boolean transparentBorder = false;
    if (transparentBorder) {
      sb.append(name).append(" .zscell {");
      sb.append("border-right-color: transparent;");
      sb.append("border-bottom-color: transparent;");
      if (isIE) {
        /** for IE6 **/
        String color_to_transparent = "tomato";
        sb.append("_border-color:" + color_to_transparent + ";");
        sb.append("_filter:chroma(color=" + color_to_transparent + ");");
      }
      sb.append("}");
    }

    List<HeaderPositionInfo> infos = colHelper.getInfos();
    for (HeaderPositionInfo info : infos) {
      boolean hidden = info.hidden;
      int index = info.index;
      int width = hidden ? 0 : info.size;
      int cid = info.id;

      celltextwidth = width - 2 * cp - 1;// 1 is border width

      // bug 1989680
      if (celltextwidth < 0)
        celltextwidth = 0;

      if (!isGecko) {
        cellwidth = celltextwidth;
      } else {
        cellwidth = width;
      }

      if (width <= 0) {
        sb.append(name).append(" .zsw").append(cid).append("{");
        sb.append("display:none;");
        sb.append("}");

      } else {
        sb.append(name).append(" .zsw").append(cid).append("{");
        sb.append("width:").append(cellwidth).append("px;");
        sb.append("}");

        sb.append(name).append(" .zswi").append(cid).append("{");
        sb.append("width:").append(celltextwidth).append("px;");
        sb.append("}");
      }
    }

    infos = rowHelper.getInfos();
    for (HeaderPositionInfo info : infos) {
      boolean hidden = info.hidden;
      int index = info.index;
      int height = hidden ? 0 : info.size;
      int cid = info.id;
      cellheight = height;
      if (!isGecko) {
        cellheight = height - 1;// 1 is border width
      }

      if (height <= 0) {

        sb.append(name).append(" .zsh").append(cid).append("{\n");
        sb.append("display:none;");
        sb.append("}");

        sb.append(name).append(" .zslh").append(cid).append("{");
        sb.append("display:none;");
        sb.append("}");

      } else {
        sb.append(name).append(" .zsh").append(cid).append("{");
        sb.append("height:").append(height).append("px;");
        sb.append("}");

        sb.append(name).append(" .zshi").append(cid).append("{");
        sb.append("height:").append(cellheight).append("px;");
        sb.append("}");

        int h2 = (height < 1) ? 0 : height - 1;

        sb.append(name).append(" .zslh").append(cid).append("{");
        sb.append("height:").append(h2).append("px;");
        sb.append("line-height:").append(h2).append("px;");
        sb.append("}");

      }
    }
    //TODO: seems no need
    sb.append(".zs_header{}");// for indicating add new rule before this

    // merge size;
    List ranges = mmhelper.getRanges();
    Iterator iter = ranges.iterator();
    final int defaultSize = colHelper.getDefaultSize();
    final int defaultRowSize = rowHelper.getDefaultSize();

    while (iter.hasNext()) {
      MergedRect block = (MergedRect) iter.next();
      int left = block.getLeft();
      int right = block.getRight();
      int width = 0;
      for (int i = left; i <= right; i++) {
        final HeaderPositionInfo info = colHelper.getInfo(i);
        if (info != null) {
          final boolean hidden = info.hidden;
          final int colSize = hidden ? 0 : info.size;
          width += colSize;
        } else {
          width += defaultSize ;
        }
      }
      int top = block.getTop();
      int bottom = block.getBottom();
      int height = 0;
      for (int i = top; i <= bottom; i++) {
        final HeaderPositionInfo info = rowHelper.getInfo(i);
        if (info != null) {
          final boolean hidden = info.hidden;
          final int rowSize = hidden ? 0 : info.size;
          height += rowSize;
        } else {
View Full Code Here

     
      smartUpdate("displayGridlines", !_hideGridlines);
      smartUpdate("protect", _protectSheet);
     
      // generate customized row & column information
      HeaderPositionHelper colHelper = getColumnPositionHelper(sheet);
      HeaderPositionHelper rowHelper = getRowPositionHelper(sheet);
      smartUpdate("csc", getSizeHelperStr(colHelper));
      smartUpdate("csr", getSizeHelperStr(rowHelper));
     
      // generate merge range information
      MergeMatrixHelper mmhelper = getMergeMatrixHelper(sheet);
View Full Code Here

    if (_highlightRect != null) {
      renderer.render("highLightRect", getRectStr(_highlightRect));
    }

    // generate customized row & column information
    HeaderPositionHelper colHelper = getColumnPositionHelper(sheet);
    HeaderPositionHelper rowHelper = getRowPositionHelper(sheet);
    renderer.render("csc", getSizeHelperStr(colHelper));
    renderer.render("csr", getSizeHelperStr(rowHelper));

    // generate merge range information
View Full Code Here

      cellType == Cell.CELL_TYPE_FORMULA ||
      cellType == Cell.CELL_TYPE_BLANK;
  }
 
  private ClientAnchor getClientCenterAnchor(int row, int col, int widgetWidth, int widgetHeight) {
    HeaderPositionHelper rowSizeHelper = (HeaderPositionHelper) spreadsheet.getAttribute("_rowCellSize");
    HeaderPositionHelper colSizeHelper = (HeaderPositionHelper) spreadsheet.getAttribute("_colCellSize");
   
    int lCol = col;
    int tRow = row;
    int rCol = lCol;
    int bRow = tRow;
    int offsetWidth = 0;
    int offsetHeight = 0;
    for (int r = tRow; r < spreadsheet.getMaxrows(); r++) {
      int cellHeight = rowSizeHelper.getSize(r);
      widgetHeight -= cellHeight;
      if (widgetHeight <= 0) {
        bRow = r;
        if (widgetHeight < 0) {
          offsetHeight = cellHeight - Math.abs(widgetHeight);
        }
        break;
      }
    }
    for (int c = lCol; c < spreadsheet.getMaxcolumns(); c++) {
      int cellWidth = colSizeHelper.getSize(c);
      widgetWidth -= cellWidth;
      if (widgetWidth <= 0) {
        rCol = c;
        if (widgetWidth < 0) {
          offsetWidth = cellWidth - Math.abs(widgetWidth);
View Full Code Here

TOP

Related Classes of org.zkoss.zss.ui.impl.HeaderPositionHelper$HeaderPositionInfo

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.