[Thinlet-development] thinlet Widget.java,1.4,1.5 Thinlet.java,1.7,1.8
Brought to you by:
bajzat
From: <ba...@us...> - 2003-03-10 21:29:35
|
Update of /cvsroot/thinlet/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv17406 Modified Files: Widget.java Thinlet.java Log Message: no message Index: Widget.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/Widget.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Widget.java 7 Mar 2003 18:35:13 -0000 1.4 --- Widget.java 10 Mar 2003 21:29:30 -0000 1.5 *************** *** 18,21 **** --- 18,25 ---- } + public String getClass() { + return null; + } + /** * Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/Thinlet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Thinlet.java 2 Mar 2003 17:14:34 -0000 1.7 --- Thinlet.java 10 Mar 2003 21:29:30 -0000 1.8 *************** *** 274,293 **** int gap = getInteger(component, "gap", 0); int[][] grid = getGrid(component, gap); ! if (grid != null) { ! int top = getInteger(component, "top", 0); ! int left = getInteger(component, "left", 0); int bottom = getInteger(component, "bottom", 0); int right = getInteger(component, "right", 0); ! if (classname == "dialog") { ! int titleheight = getSize(component, 0, 0).height; ! setInteger(component, ":titleheight", titleheight, 0); ! top += 4 + titleheight; left += 4; bottom += 4; right += 4; } ! Rectangle bounds = getRectangle(component, "bounds"); ! int wsum = left + getSum(grid[0], 0, grid[0].length, gap, false) + right; ! int hsum = top + getSum(grid[1], 0, grid[1].length, gap, false) + bottom; for (int i = 0; i < 2; i++) { // i=0: horizontal, i=1: vertical ! int d = ((i == 0) ? (bounds.width - wsum) : (bounds.height - hsum)); if (d != 0) { //+ > 0 int w = getSum(grid[2 + i], 0, grid[2 + i].length, 0, false); --- 274,330 ---- int gap = getInteger(component, "gap", 0); int[][] grid = getGrid(component, gap); ! int top = 0; int left = 0; ! int contentwidth = 0; int contentheight = 0; ! if (grid != null) { // has subcomponents ! top = getInteger(component, "top", 0); ! left = getInteger(component, "left", 0); int bottom = getInteger(component, "bottom", 0); int right = getInteger(component, "right", 0); ! // sums the preferred size of cell widths and heights, gaps ! contentwidth = left + getSum(grid[0], 0, grid[0].length, gap, false) + right; ! contentheight = top + getSum(grid[1], 0, grid[1].length, gap, false) + bottom; ! } ! ! Dimension title = getSize(component, 0, 0); // title text and icon ! boolean scrollable = getBoolean(component, "scrollable", false); ! boolean border = ("panel" == classname) && getBoolean(component, "border", false); ! int iborder = (border ? 1 : 0); ! if (scrollable) { // set scrollpane areas ! if ("panel" == classname) { ! int head = title.height / 2; ! int headgap = (title.height > 0) ? (title.height - head - iborder) : 0; ! scrollable = layoutScroll(component, contentwidth, contentheight, ! head, 0, 0, 0, border, headgap); } ! else { // dialog ! scrollable = layoutScroll(component, contentwidth, contentheight, ! 3 + title.height, 3, 3, 3, true, 0); ! } ! } ! ! int areax = 0; int areay = 0; int areawidth = 0; int areaheight = 0; ! if (scrollable) { ! // components are relative to the viewport ! Rectangle port = getRectangle(component, ":port"); ! areawidth = port.width; areaheight = port.height; ! } ! else { // scrollpane isn't required ! // components are relative to top/left corner Rectangle bounds = getRectangle(component, "bounds"); ! areawidth = bounds.width; areaheight = bounds.height; ! if ("panel" == classname) { ! areax = iborder; areay = Math.max(iborder, title.height); ! areawidth -= 2 * iborder; areaheight -= areay - iborder; ! } ! else { // dialog ! areax = 4; areay = 4 + title.height; ! areawidth -= 8; areaheight -= areay + 4; ! } ! } ! ! if (grid != null) { for (int i = 0; i < 2; i++) { // i=0: horizontal, i=1: vertical ! // remaining space ! int d = ((i == 0) ? (areawidth - contentwidth) : (areaheight - contentheight)); if (d != 0) { //+ > 0 int w = getSum(grid[2 + i], 0, grid[2 + i].length, 0, false); *************** *** 301,311 **** } } ! int i = 0; for (Object comp = get(component, ":comp"); comp != null; comp = get(comp, ":next")) { if (!getBoolean(comp, "visible", true)) { continue; } ! int ix = left + getSum(grid[0], 0, grid[4][i], gap, true); ! int iy = top + getSum(grid[1], 0, grid[5][i], gap, true); int iwidth = getSum(grid[0], grid[4][i], grid[6][i], gap, false); int iheight = getSum(grid[1], grid[5][i], grid[7][i], gap, false); --- 338,348 ---- } } ! int i = 0; for (Object comp = get(component, ":comp"); comp != null; comp = get(comp, ":next")) { if (!getBoolean(comp, "visible", true)) { continue; } ! int ix = areax + left + getSum(grid[0], 0, grid[4][i], gap, true); ! int iy = areay + top + getSum(grid[1], 0, grid[5][i], gap, true); int iwidth = getSum(grid[0], grid[4][i], grid[6][i], gap, false); int iheight = getSum(grid[1], grid[5][i], grid[7][i], gap, false); *************** *** 331,338 **** i++; } - - if (getBoolean(component, "scrollable", false)) { - layoutScroll(component, wsum, hsum, 0, 0, 0, 0, false, 0); - } } } --- 368,371 ---- *************** *** 871,882 **** * @param contentwidth preferred component width * @param contentheight preferred component height ! * @param header column height ! * @param topborder border size on the top (1 or 0) ! * @param border define left, bottom, and right border width (1 or 0) * * list: 0, 0, 0, 0, true, 0 | table: header, ... | dialog: header, 3, 3, 3, true, 0 * title-border panel: header / 2, 0, 0, 0, true, head */ ! private void layoutScroll(Object component, int contentwidth, int contentheight, int top, int left, int bottom, int right, boolean border, int topgap) { --- 904,918 ---- * @param contentwidth preferred component width * @param contentheight preferred component height ! * @param top top inset (e.g. table header, dialog title, half of panel title) ! * @param left left inset (e.g. dialog border) ! * @param bottom bottom inset (e.g. dialog border) ! * @param right right inset (e.g. dialog border) ! * @param topgap (lower half of panel title) ! * @return true if scrollpane is required, otherwise false * * list: 0, 0, 0, 0, true, 0 | table: header, ... | dialog: header, 3, 3, 3, true, 0 * title-border panel: header / 2, 0, 0, 0, true, head */ ! private boolean layoutScroll(Object component, int contentwidth, int contentheight, int top, int left, int bottom, int right, boolean border, int topgap) { *************** *** 910,913 **** --- 946,950 ---- } setRectangle(component, ":view", viewx, viewy, contentwidth, contentheight); + return vneed || hneed; } *************** *** 1020,1033 **** } if (("panel" == classname) || (classname == "dialog")) { ! Dimension size = new Dimension( ! getInteger(component, "left", 0) + getInteger(component, "right", 0), ! getInteger(component, "top", 0) + getInteger(component, "bottom", 0)); if (classname == "dialog") { ! int titleheight = getSize(component, 0, 0).height; ! size.width += 8; size.height += 8 + titleheight; } int gap = getInteger(component, "gap", 0); int[][] grid = getGrid(component, gap); ! if (grid != null) { size.width += getSum(grid[0], 0, grid[0].length, gap, false); size.height += getSum(grid[1], 0, grid[1].length, gap, false); --- 1057,1076 ---- } if (("panel" == classname) || (classname == "dialog")) { ! // title text and icon height ! Dimension size = getSize(component, 0, 0); ! // add border size if (classname == "dialog") { ! size.width = 8; size.height += 8; // title width neglected } + else if (getBoolean(component, "border", false)) { // bordered panel + size.width = 2; size.height += (size.height > 0) ? 1 : 2; // title includes line + } + // add paddings + size.width = getInteger(component, "left", 0) + getInteger(component, "right", 0); + size.height += getInteger(component, "top", 0) + getInteger(component, "bottom", 0); + // add content preferred size int gap = getInteger(component, "gap", 0); int[][] grid = getGrid(component, gap); ! if (grid != null) { // has components size.width += getSum(grid[0], 0, grid[0].length, gap, false); size.height += getSum(grid[1], 0, grid[1].length, gap, false); *************** *** 2082,2099 **** g.drawLine(0, r.y + r.height, viewwidth, r.y + r.height); } ! boolean itemenabled = enabled && getBoolean(item, "enabled", true); ! paintContent(item, g, clipx, clipy, clipwidth, clipheight, ! r.x + ITEM.left, r.y + ITEM.top, viewwidth - ITEM.left - ITEM.right, r.height - ITEM.top - ITEM.bottom, ! itemenabled ? c_text : c_disable, "left", false); ! if ("tree" == classname) { ! int x = r.x - block / 2; int y = r.y + (r.height - 1) / 2; ! g.setColor(itemenabled ? c_border : c_disable); ! g.drawLine(x, r.y, x, y); g.drawLine(x, y, r.x, y); ! if (subnode) { ! paintRect(g, x - 4, y - 4, 9, 9, itemenabled ? c_border : c_disable, ! itemenabled ? c_ctrl : c_bg, true, true, true, true, true); ! g.setColor(itemenabled ? c_text : c_disable); ! g.drawLine(x - 2, y, x + 2, y); ! if (!expanded) { g.drawLine(x, y - 2, x, y + 2); } } } --- 2125,2158 ---- g.drawLine(0, r.y + r.height, viewwidth, r.y + r.height); } ! if ("table" != classname) { ! boolean itemenabled = enabled && getBoolean(item, "enabled", true); ! paintContent(item, g, clipx, clipy, clipwidth, clipheight, ! r.x + ITEM.left, r.y + ITEM.top, viewwidth - ITEM.left - ITEM.right, r.height - ITEM.top - ITEM.bottom, ! itemenabled ? c_text : c_disable, "left", false); ! if ("tree" == classname) { ! int x = r.x - block / 2; int y = r.y + (r.height - 1) / 2; ! g.setColor(itemenabled ? c_border : c_disable); ! g.drawLine(x, r.y, x, y); g.drawLine(x, y, r.x, y); ! if (subnode) { ! paintRect(g, x - 4, y - 4, 9, 9, itemenabled ? c_border : c_disable, ! itemenabled ? c_ctrl : c_bg, true, true, true, true, true); ! g.setColor(itemenabled ? c_text : c_disable); ! g.drawLine(x - 2, y, x + 2, y); ! if (!expanded) { g.drawLine(x, y - 2, x, y + 2); } ! } ! } ! } ! else { // tree ! int x = 0; ! for (Object cell = get(item, ":comp"); cell != null; cell = get(cell, ":next")) { ! if (clipx + clipwidth <= x) { break; } ! int iwidth = 80; ! if (clipx < x + iwidth) { ! boolean cellenabled = enabled && getBoolean(cell, "enabled", true); ! paintContent(cell, g, clipx, clipy, clipwidth, clipheight, ! r.x + x + 1, r.y + 1, iwidth - 2, r.height - 3, ! cellenabled ? c_text : c_disable, "left", false); ! } ! x += iwidth; } } |