From aa4119f13cc98c9b607cda1925dc90f0e56e7877 Mon Sep 17 00:00:00 2001 From: Brian Frank Date: Thu, 3 Aug 2023 17:33:46 -0400 Subject: [PATCH] webfwt: move to separate fwt repo --- src/fwt/test/TableTest.fan | 132 ---- src/webfwt/build.fan | 38 -- src/webfwt/fan/ActivityPane.fan | 49 -- src/webfwt/fan/ButtonGroup.fan | 135 ---- src/webfwt/fan/CanvasTable.fan | 801 ----------------------- src/webfwt/fan/CenterPane.fan | 89 --- src/webfwt/fan/ColTree.fan | 241 ------- src/webfwt/fan/FileUploader.fan | 242 ------- src/webfwt/fan/FixedPane.fan | 42 -- src/webfwt/fan/FlowPane.fan | 114 ---- src/webfwt/fan/GMap.fan | 77 --- src/webfwt/fan/HPane.fan | 68 -- src/webfwt/fan/HtmlPane.fan | 34 - src/webfwt/fan/Hyperlink.fan | 53 -- src/webfwt/fan/MiniButton.fan | 68 -- src/webfwt/fan/MiniCombo.fan | 104 --- src/webfwt/fan/OverlayPane.fan | 48 -- src/webfwt/fan/PaleTreeList.fan | 22 - src/webfwt/fan/Popup.fan | 70 -- src/webfwt/fan/RowPane.fan | 265 -------- src/webfwt/fan/Shadow.fan | 119 ---- src/webfwt/fan/Sheet.fan | 203 ------ src/webfwt/fan/SlidePane.fan | 50 -- src/webfwt/fan/StyledButton.fan | 176 ----- src/webfwt/fan/TextPane.fan | 34 - src/webfwt/fan/TransitionPane.fan | 36 - src/webfwt/fan/TreeList.fan | 55 -- src/webfwt/fan/Uploader.fan | 53 -- src/webfwt/fan/VPane.fan | 68 -- src/webfwt/fan/WebBorderPane.fan | 22 - src/webfwt/fan/WebCanvas.fan | 22 - src/webfwt/fan/WebCombo.fan | 28 - src/webfwt/fan/WebDialog.fan | 170 ----- src/webfwt/fan/WebLabel.fan | 35 - src/webfwt/fan/WebList.fan | 138 ---- src/webfwt/fan/WebScrollPane.fan | 127 ---- src/webfwt/fan/WebTable.fan | 40 -- src/webfwt/fan/WebTableModel.fan | 38 -- src/webfwt/fan/WebText.fan | 66 -- src/webfwt/fan/hud/HudButton.fan | 28 - src/webfwt/fan/hud/HudButtonGroup.fan | 32 - src/webfwt/fan/hud/HudCheckbox.fan | 52 -- src/webfwt/fan/hud/HudCombo.fan | 24 - src/webfwt/fan/hud/HudList.fan | 22 - src/webfwt/fan/hud/HudMenu.fan | 62 -- src/webfwt/fan/hud/HudPopup.fan | 49 -- src/webfwt/fan/hud/HudScrollPane.fan | 21 - src/webfwt/fan/hud/HudText.fan | 24 - src/webfwt/fan/internal/AbsPane.fan | 39 -- src/webfwt/fan/internal/AlphaPane.fan | 27 - src/webfwt/fan/internal/ButtonBar.fan | 62 -- src/webfwt/fan/internal/LayerPane.fan | 46 -- src/webfwt/fan/internal/ToggleButton.fan | 98 --- src/webfwt/js/ActivityPanePeer.js | 148 ----- src/webfwt/js/AlphaPanePeer.js | 22 - src/webfwt/js/ColUtilPeer.js | 36 - src/webfwt/js/ColWebListPeer.js | 90 --- src/webfwt/js/FileUploaderPeer.js | 251 ------- src/webfwt/js/GMapPeer.js | 279 -------- src/webfwt/js/HtmlPanePeer.js | 60 -- src/webfwt/js/HudButtonPeer.js | 30 - src/webfwt/js/HudComboPeer.js | 43 -- src/webfwt/js/HudListPeer.js | 52 -- src/webfwt/js/HudScrollPanePeer.js | 45 -- src/webfwt/js/HudTextPeer.js | 34 - src/webfwt/js/HyperlinkPeer.js | 46 -- src/webfwt/js/MiniButtonPeer.js | 186 ------ src/webfwt/js/MiniComboPeer.js | 191 ------ src/webfwt/js/OverlayPanePeer.js | 156 ----- src/webfwt/js/PaleTreeListPeer.js | 34 - src/webfwt/js/PopupPeer.js | 229 ------- src/webfwt/js/SheetPeer.js | 167 ----- src/webfwt/js/SlidePanePeer.js | 52 -- src/webfwt/js/StyledButtonPeer.js | 150 ----- src/webfwt/js/TextPanePeer.js | 129 ---- src/webfwt/js/TransitionPanePeer.js | 154 ----- src/webfwt/js/TreeListPeer.js | 216 ------ src/webfwt/js/UploaderPeer.js | 17 - src/webfwt/js/WebBorderPanePeer.js | 31 - src/webfwt/js/WebCanvasPeer.js | 17 - src/webfwt/js/WebComboPeer.js | 22 - src/webfwt/js/WebLabelPeer.js | 75 --- src/webfwt/js/WebListPeer.js | 418 ------------ src/webfwt/js/WebScrollPanePeer.js | 144 ---- src/webfwt/js/WebTableModel.js | 35 - src/webfwt/js/WebTablePeer.js | 36 - src/webfwt/js/WebTextPeer.js | 97 --- src/webfwt/locale/en.props | 12 - src/webfwt/res/img/arrow-down.png | Bin 154 -> 0 bytes src/webfwt/res/img/arrow-right.png | Bin 137 -> 0 bytes src/webfwt/res/img/blank.png | Bin 78 -> 0 bytes src/webfwt/res/img/hud-checkbox-off.png | Bin 282 -> 0 bytes src/webfwt/res/img/hud-checkbox-on.png | Bin 436 -> 0 bytes src/webfwt/res/img/hud-combo-arrows.png | Bin 129 -> 0 bytes src/webfwt/res/img/throbber-charcoal.gif | Bin 1912 -> 0 bytes src/webfwt/res/img/throbber.gif | Bin 1542 -> 0 bytes src/webfwt/test/FileUploadTest.fan | 179 ----- src/webfwt/test/ShadowTest.fan | 56 -- src/webfwt/test/StyledButtonTest.fan | 51 -- src/webfwt/test/TestMod.fan | 147 ----- src/webfwt/test/TransitionPaneTest.fan | 82 --- src/webfwt/test/WebListTest.fan | 229 ------- src/webfwt/test/WebScrollPaneTest.fan | 68 -- 103 files changed, 9274 deletions(-) delete mode 100644 src/fwt/test/TableTest.fan delete mode 100755 src/webfwt/build.fan delete mode 100644 src/webfwt/fan/ActivityPane.fan delete mode 100644 src/webfwt/fan/ButtonGroup.fan delete mode 100644 src/webfwt/fan/CanvasTable.fan delete mode 100644 src/webfwt/fan/CenterPane.fan delete mode 100644 src/webfwt/fan/ColTree.fan delete mode 100644 src/webfwt/fan/FileUploader.fan delete mode 100644 src/webfwt/fan/FixedPane.fan delete mode 100644 src/webfwt/fan/FlowPane.fan delete mode 100644 src/webfwt/fan/GMap.fan delete mode 100644 src/webfwt/fan/HPane.fan delete mode 100644 src/webfwt/fan/HtmlPane.fan delete mode 100644 src/webfwt/fan/Hyperlink.fan delete mode 100644 src/webfwt/fan/MiniButton.fan delete mode 100644 src/webfwt/fan/MiniCombo.fan delete mode 100644 src/webfwt/fan/OverlayPane.fan delete mode 100644 src/webfwt/fan/PaleTreeList.fan delete mode 100644 src/webfwt/fan/Popup.fan delete mode 100644 src/webfwt/fan/RowPane.fan delete mode 100644 src/webfwt/fan/Shadow.fan delete mode 100644 src/webfwt/fan/Sheet.fan delete mode 100644 src/webfwt/fan/SlidePane.fan delete mode 100644 src/webfwt/fan/StyledButton.fan delete mode 100644 src/webfwt/fan/TextPane.fan delete mode 100644 src/webfwt/fan/TransitionPane.fan delete mode 100644 src/webfwt/fan/TreeList.fan delete mode 100644 src/webfwt/fan/Uploader.fan delete mode 100644 src/webfwt/fan/VPane.fan delete mode 100644 src/webfwt/fan/WebBorderPane.fan delete mode 100644 src/webfwt/fan/WebCanvas.fan delete mode 100644 src/webfwt/fan/WebCombo.fan delete mode 100644 src/webfwt/fan/WebDialog.fan delete mode 100644 src/webfwt/fan/WebLabel.fan delete mode 100644 src/webfwt/fan/WebList.fan delete mode 100644 src/webfwt/fan/WebScrollPane.fan delete mode 100644 src/webfwt/fan/WebTable.fan delete mode 100644 src/webfwt/fan/WebTableModel.fan delete mode 100644 src/webfwt/fan/WebText.fan delete mode 100644 src/webfwt/fan/hud/HudButton.fan delete mode 100644 src/webfwt/fan/hud/HudButtonGroup.fan delete mode 100644 src/webfwt/fan/hud/HudCheckbox.fan delete mode 100644 src/webfwt/fan/hud/HudCombo.fan delete mode 100644 src/webfwt/fan/hud/HudList.fan delete mode 100644 src/webfwt/fan/hud/HudMenu.fan delete mode 100644 src/webfwt/fan/hud/HudPopup.fan delete mode 100644 src/webfwt/fan/hud/HudScrollPane.fan delete mode 100644 src/webfwt/fan/hud/HudText.fan delete mode 100644 src/webfwt/fan/internal/AbsPane.fan delete mode 100644 src/webfwt/fan/internal/AlphaPane.fan delete mode 100644 src/webfwt/fan/internal/ButtonBar.fan delete mode 100644 src/webfwt/fan/internal/LayerPane.fan delete mode 100644 src/webfwt/fan/internal/ToggleButton.fan delete mode 100644 src/webfwt/js/ActivityPanePeer.js delete mode 100644 src/webfwt/js/AlphaPanePeer.js delete mode 100644 src/webfwt/js/ColUtilPeer.js delete mode 100644 src/webfwt/js/ColWebListPeer.js delete mode 100644 src/webfwt/js/FileUploaderPeer.js delete mode 100644 src/webfwt/js/GMapPeer.js delete mode 100644 src/webfwt/js/HtmlPanePeer.js delete mode 100644 src/webfwt/js/HudButtonPeer.js delete mode 100644 src/webfwt/js/HudComboPeer.js delete mode 100644 src/webfwt/js/HudListPeer.js delete mode 100644 src/webfwt/js/HudScrollPanePeer.js delete mode 100644 src/webfwt/js/HudTextPeer.js delete mode 100644 src/webfwt/js/HyperlinkPeer.js delete mode 100644 src/webfwt/js/MiniButtonPeer.js delete mode 100644 src/webfwt/js/MiniComboPeer.js delete mode 100644 src/webfwt/js/OverlayPanePeer.js delete mode 100644 src/webfwt/js/PaleTreeListPeer.js delete mode 100644 src/webfwt/js/PopupPeer.js delete mode 100644 src/webfwt/js/SheetPeer.js delete mode 100644 src/webfwt/js/SlidePanePeer.js delete mode 100644 src/webfwt/js/StyledButtonPeer.js delete mode 100644 src/webfwt/js/TextPanePeer.js delete mode 100644 src/webfwt/js/TransitionPanePeer.js delete mode 100644 src/webfwt/js/TreeListPeer.js delete mode 100644 src/webfwt/js/UploaderPeer.js delete mode 100644 src/webfwt/js/WebBorderPanePeer.js delete mode 100644 src/webfwt/js/WebCanvasPeer.js delete mode 100644 src/webfwt/js/WebComboPeer.js delete mode 100644 src/webfwt/js/WebLabelPeer.js delete mode 100644 src/webfwt/js/WebListPeer.js delete mode 100644 src/webfwt/js/WebScrollPanePeer.js delete mode 100644 src/webfwt/js/WebTableModel.js delete mode 100644 src/webfwt/js/WebTablePeer.js delete mode 100644 src/webfwt/js/WebTextPeer.js delete mode 100644 src/webfwt/locale/en.props delete mode 100644 src/webfwt/res/img/arrow-down.png delete mode 100644 src/webfwt/res/img/arrow-right.png delete mode 100644 src/webfwt/res/img/blank.png delete mode 100644 src/webfwt/res/img/hud-checkbox-off.png delete mode 100644 src/webfwt/res/img/hud-checkbox-on.png delete mode 100644 src/webfwt/res/img/hud-combo-arrows.png delete mode 100644 src/webfwt/res/img/throbber-charcoal.gif delete mode 100644 src/webfwt/res/img/throbber.gif delete mode 100644 src/webfwt/test/FileUploadTest.fan delete mode 100644 src/webfwt/test/ShadowTest.fan delete mode 100644 src/webfwt/test/StyledButtonTest.fan delete mode 100644 src/webfwt/test/TestMod.fan delete mode 100644 src/webfwt/test/TransitionPaneTest.fan delete mode 100644 src/webfwt/test/WebListTest.fan delete mode 100644 src/webfwt/test/WebScrollPaneTest.fan diff --git a/src/fwt/test/TableTest.fan b/src/fwt/test/TableTest.fan deleted file mode 100644 index 9a578a709..000000000 --- a/src/fwt/test/TableTest.fan +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright (c) 2010, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 29 Apr 10 Brian Frank Creation -// - -** -** TableTest -** -class TableTest : Test -{ - - Void testView() - { - // start off - m := TestTableModel() - t := Table { model = m } - verifyView(t, null, SortMode.up, [true, true, true], - [["A:0", "B:0", "C:0"], - ["A:1", "B:1", "C:1"], - ["A:2", "B:2", "C:2"]]) - - // sort column 1 - t.sort(1) - verifyView(t, 1, SortMode.up, [true, true, true], - [["A:0", "B:0", "C:0"], - ["A:2", "B:2", "C:2"], - ["A:1", "B:1", "C:1"]]) - - // sort column 1 descending - t.sort(1, SortMode.down) - verifyView(t, 1, SortMode.down, [true, true, true], - [["A:1", "B:1", "C:1"], - ["A:2", "B:2", "C:2"], - ["A:0", "B:0", "C:0"]]) - - // add row - m.numRows = 4 - verifyView(t, 1, SortMode.down, [true, true, true], - [["A:1", "B:1", "C:1"], - ["A:2", "B:2", "C:2"], - ["A:3", "B:3", "C:3"], - ["A:0", "B:0", "C:0"]]) - - // turn off column 0 - t.setColVisible(0, false) - verifyView(t, 1, SortMode.down, [false, true, true], - [["B:1", "C:1"], - ["B:2", "C:2"], - ["B:3", "C:3"], - ["B:0", "C:0"]]) - - // turn on column 0, turn off 1 - t.setColVisible(0, true) - t.setColVisible(1, false) - verifyView(t, 1, SortMode.down, [true, false, true], - [["A:1", "C:1"], - ["A:2", "C:2"], - ["A:3", "C:3"], - ["A:0", "C:0"]]) - - // turn turn off 2, sort col 0 - t.view.setColVisible(2, false) - t.sort(0) - verifyView(t, 0, SortMode.up, [true, false, false], - [["A:0"], - ["A:1"], - ["A:2"], - ["A:3"]]) - } - - Void verifyView(Table t, Int? sortCol, SortMode sortMode, - Bool[] visible, Str[][] viewRows ) - { - // verify fixed model - verifyEq(t.model.numRows, viewRows.size) - verifyEq(t.model.numCols, 3) - 3.times |c| - { - viewRows.size.times |r| - { - verifyEq(t.model.text(c, r), ('A'+c).toChar + ":" + r) - } - } - - // sort/visible - verifyEq(t.sortCol, sortCol) - verifyEq(t.sortMode, sortMode) - visible.each |v, c| { verifyEq(t.isColVisible(c), v) } - - // verify view columns - verifyEq(t.view.numCols, viewRows[0].size) - viewRows[0].each |cell, c| - { - verifyEq(t.view.header(c), cell[0..0]) - } - - // verify view rows - viewRows.each |row, r| - { - row.each |cell, c| - { - verifyEq(t.view.text(c, r), cell) - } - } - - // verify selection - t.selected = [0, 2] - verifyEq(t.selected.size, 2) - verifyEq(t.selected[0], 0) - verifyEq(t.selected[1], 2) - } - -} - -internal class TestTableModel : TableModel -{ - override Int numRows := 3 - override Int numCols() { 3 } - override Str header(Int col) { ('A' + col).toChar } - override Str text(Int col, Int row) { "${header(col)}:$row" } - - override Int sortCompare(Int c, Int row1, Int row2) - { - if (c == 1) return bRanks[row1] <=> bRanks[row2] - return super.sortCompare(c, row1, row2) - } - - Int[] bRanks := [1, 4, 2, 2] // ^ 0, 2, 3, 1 ; v 1, 3, 2, 0 -} \ No newline at end of file diff --git a/src/webfwt/build.fan b/src/webfwt/build.fan deleted file mode 100755 index b689e4cec..000000000 --- a/src/webfwt/build.fan +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env fan -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 8 Jun 2009 Andy Frank Creation -// 17 Mar 2011 Andy Frank Move from frescoKit to webfwt -// 20 Jul 2012 Brian Frank Move to fantom core -// - -using build - -** -** Build: webfwt -** -class Build : BuildPod -{ - new make() - { - podName = "webfwt" - summary = "Web extensions to the FWT toolkit" - meta = ["org.name": "Fantom", - "org.uri": "https://fantom.org/", - "proj.name": "Fantom Core", - "license.name": "Academic Free License 3.0", - "vcs.name": "Git", - "vcs.uri": "https://github.com/fantom-lang/fantom"] - depends = ["sys 1.0", "gfx 1.0", "fwt 1.0", "web 1.0"] - srcDirs = [`fan/`, - //`fan/internal/`, - `fan/hud/`, - `test/`] - jsDirs = [`js/`] - resDirs = [`locale/`, `res/img/`] - docSrc = true - } -} \ No newline at end of file diff --git a/src/webfwt/fan/ActivityPane.fan b/src/webfwt/fan/ActivityPane.fan deleted file mode 100644 index ad7be4c11..000000000 --- a/src/webfwt/fan/ActivityPane.fan +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 21 May 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** ActivityPane blocks input to a Widget while displaying an activity message. -** -@Js -class ActivityPane -{ - ** - ** Throbber image to display next to message. - ** - Image? image := Image(`fan://webfwt/res/img/throbber-charcoal.gif`) - - ** - ** Message to display. - ** - Str msg := "Loading" - - ** - ** Return true while pane is open. - ** - native Bool working() - - ** - ** Open ActivityPane over given widget. - ** - native This open(Widget parent) - - ** - ** Close pane. - ** - native Void close() - - ** - ** Find the first open instance of ActivityPane, or null - ** if none exist. - ** - static native ActivityPane? find() - -} \ No newline at end of file diff --git a/src/webfwt/fan/ButtonGroup.fan b/src/webfwt/fan/ButtonGroup.fan deleted file mode 100644 index 4d9490b64..000000000 --- a/src/webfwt/fan/ButtonGroup.fan +++ /dev/null @@ -1,135 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 21 Jul 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** ButtonGroup. -** -@NoDoc -@Js -class ButtonGroup : ContentPane -{ - -////////////////////////////////////////////////////////////////////////// -// Construction -////////////////////////////////////////////////////////////////////////// - - ** Create new button group with text for buttons. - new make(Str[] text) - { - grid := GridPane - { - hgap = -1 - numCols = text.size - uniformCols = true - halignPane = Halign.center - halignCells = Halign.fill - } - text.each |t,i| { grid.add(button(t, i==0, i==text.size-1)) } - content = grid - select(null) - } - - private Widget button(Str text, Bool right, Bool left) - { - pos := buttons.size - - Border? outer - Border? inner - - bo := borderOuter // #555 - bi := borderInner // #131313 - - if (right) { outer=Border("0,0,1,0 $bo 0,0,0,5"); inner=Border("$bi 5,0,0,5") } - else if (left) { outer=Border("0,0,1,0 $bo 0,0,5,0"); inner=Border("$bi 0,5,5,0") } - else { outer=Border("0,0,1,0 $bo"); inner=Border("$bi") } - - button := BorderPane - { - border = outer - it.onMouseUp.add - { - select(pos) - event := Event { id=EventId.select; widget=this; index=selected } - onSelect.fire(event) - } - BorderPane - { - border = inner - Label { it.text=text; fg=fgNorm; font=Desktop.sysFontSmall; halign=Halign.center }, - }, - } - - buttons.add(button) - return button - } - -////////////////////////////////////////////////////////////////////////// -// Events -////////////////////////////////////////////////////////////////////////// - - ** Currently selected button index. - Int? selected := null - { - set { select(it) } - } - - ** Select the tab at the given index. - private Void select(Int? pos) - { - // udpate widgets - &selected = pos - buttons.each |but,i| - { - sel := &selected == i - inner := (BorderPane)but.content - inner.bg = sel ? bgDown : bgNorm - inner.insets = sel ? Insets(5,12,3,12) : Insets(4,12) - inner.content->fg = sel ? fgDown : fgNorm - } - relayout - } - - ** EventListeners for select event. - EventListeners onSelect := EventListeners() - -////////////////////////////////////////////////////////////////////////// -// Customize -////////////////////////////////////////////////////////////////////////// - - ** Outer Border color. - protected virtual Str borderOuter() { "#e0e0e0" } - - ** Outer Border color. - protected virtual Str borderInner() { "#404040" } - - ** Background when normal. - protected virtual Gradient bgNorm() { brushBgNorm } - - ** Background when pressed. - protected virtual Gradient bgDown() { brushBgDown } - - ** Foreground when normal. - protected virtual Color fgNorm() { Color.black } - - ** Foreground when pressed. - protected virtual Color fgDown() { Color.white } - -////////////////////////////////////////////////////////////////////////// -// Fields -////////////////////////////////////////////////////////////////////////// - - private BorderPane[] buttons := BorderPane[,] - - private static const Gradient brushBgNorm := Gradient("0% 0%, 0% 100%, #fefefe, #cbcbcb") - private static const Gradient brushBgDown := Gradient("0% 0%, 0% 100%, #1b54a5, #3d80df") - -} - diff --git a/src/webfwt/fan/CanvasTable.fan b/src/webfwt/fan/CanvasTable.fan deleted file mode 100644 index c76dff8b3..000000000 --- a/src/webfwt/fan/CanvasTable.fan +++ /dev/null @@ -1,801 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 3 Oct 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** CanvasTable renders an entire table in an Canvas widget, allowing -** each cell to be fully customized by painting with a Graphics -** context. -** -@Js -abstract class CanvasTable : Canvas -{ - -////////////////////////////////////////////////////////////////////////// -// Construction -///////////////////////////////////////////////////////////////////////// - - ** Constructor. - new make(|This|? f) - { - if (f != null) f(this) - - this.headerhDef = 22.max(headerFont.height + headerFont.ascent + headerFont.descent) - this.ay = (headerhDef - 7) / 2 + 1 - - this.onKeyDown.add |e| { handleKeyDown(e) } - this.onMouseMove.add |e| { handleMouse(e) } - this.onMouseDown.add |e| { handleMouse(e) } - this.onMouseUp.add |e| { handleMouse(e) } - this.onMouseWheel.add |e| { handleMouse(e) } - } - - ** Column names. - const Str[] colNames := [,] - - ** Column widths. Integer values represent exact widths. Float - ** values represent a percentage of remaining space (0..1). - const Num[] colWidths := [,] - - ** Wrap the column names - const Bool colNameWrap - - ** Is selection enabled for this table. - Bool selectionEnabled := true - - ** Selected table index. - Int[] selected := [,] - - ** Number of pixels to scroll when scrollbar track is paged. - Int scrollPage := 120 - - ** Callback when a row is double clicked or Space is pressed. - ** - id: EventId.action - ** - index: the row index - once EventListeners onAction() { EventListeners() } - - ** Callback when a column is sorted. - virtual Void onSort(Int col, SortMode mode) {} - - ** Callback when mouse moved in cell. - virtual Void onCellMoved(Event e, Int col, Int row, Point pos, Size cellSize) {} - - ** Callback when mouse pressed in cell. - virtual Void onCellPressed(Event e, Int col, Int row, Point pos, Size cellSize) {} - - ** Get cell position relative to table. - Point cellPosToTable(Point pos, Int col, Int row) - { - x := rowsetBounds.x - hscroll.cur + pos.x - y := rowsetBounds.y - vscroll.cur + pos.y - col.times |i| { x += colw[i] } - row.times |i| { y += rowb[i].h } - return Point(x, y) - } - -////////////////////////////////////////////////////////////////////////// -// Overrides -////////////////////////////////////////////////////////////////////////// - - ** Get number of rows in table. - abstract Int numRows() - - ** Get height for row at given index. - abstract Int rowHeight(Int i) - - ** Paint the cell at given index. - abstract Void paintCell(Graphics g, Int col, Int row, Bool selected, Size cellSize) - - ** Paint the cell overlay at given index. - virtual Void paintCellOverlay(Graphics g, Int col, Int row, Bool selected, Size cellSize) {} - - ** Repaint only the overaly layers. - Void repaintOverlay() { repaint } - -////////////////////////////////////////////////////////////////////////// -// Config -////////////////////////////////////////////////////////////////////////// - - ** Background color of odd rows. - const Color rowOddBg := Color.white - - ** Background color of even rows. - const Color rowEvenBg := Color("#f1f5fa") - - ** Background color of selected row. - const Color rowSelectedBg := Color("#3d80df") - - ** Color of border between rows. - const Color rowBorder := Color("#bbb") - - ** Color of border between cells. - const Color cellBorder := Color("#d9d9d9") - - ** Color of border between cells when row is selected. - const Color cellSelectedBorder := Color("#346dbe") - - ** Font for header columns. - private static const Font defHeaderFont - static - { - if ("js" === Env.cur.runtime) defHeaderFont = Desktop.sysFontSmall.toBold - else defHeaderFont = Font("bold 8pt Helvetica") - } - const Font headerFont := defHeaderFont - -////////////////////////////////////////////////////////////////////////// -// Layout -////////////////////////////////////////////////////////////////////////// - - @NoDoc Void onLayout() - { - // layout header assuming no wrap - headerh = headerhDef - dw := layoutHeader - - // if we have a wrap, then we need to compute how col names fit - colText = Str[][,] - if (colNameWrap) - { - // compute each column - maxLines := 1 - colNames.each |colName, i| - { - lines := wrapCol(colName, colw[i]) - maxLines = maxLines.max(lines.size) - colText.add(lines) - } - - // update heaederh and relayout header - headerh = headerhDef + (maxLines-1) * headerFont.height - dw = layoutHeader - } - - // if no wrap, then we have one line per column - else - { - colNames.each |n| { colText.add([n]) } - } - - // layout rows - dy := 0 - rowb.clear - numRows.times |r| - { - dh := rowHeight(r) - rowb.add(Rect(0, dy, size.w, dh)) - dy += dh - } - - // max scroll bounds - vscroll.max = dy - rowsetBounds.h - 1; vscroll.layout - hscroll.max = dw - rowsetBounds.w - 1; hscroll.layout - } - - private Int layoutHeader() - { - w := size.w-1 - h := size.h-1 - headerBounds = Rect(0, 0, w, headerh) - vscroll.bounds = Rect(w-scrollsz, headerh+1, scrollsz, h-headerh-scrollsz-2) - hscroll.bounds = Rect(0, h-scrollsz, w-scrollsz-1, scrollsz) - rowsetBounds = Rect(0, headerh+1, w-scrollsz-1, h-headerh-scrollsz-2) - - // layout cols - cs := (Int)colWidths.reduce(0) |Int v,c| { v + (c as Int ?: 0) } - rw := rowsetBounds.w - cs - dw := 0 - fc := false - colw.clear - colWidths.each |c,i| - { - cw := 0 - if (c is Int) cw = c - else { cw = (rw * c.toFloat).toInt; fc=true } - if (fc && i == colWidths.size-1) cw = rowsetBounds.w - dw + 1 - colw.add(cw) - dw += cw - } - - return dw - } - - private Str[] wrapCol(Str colName, Int colw) - { - colw = colw - 8 // margin is 4 - words := colName.split(' ') - first := words.first - - // first word goes on first line - cur := StrBuf().add(first) - curw := headerFont.width(first) - spacew := headerFont.width(" ") - - // add rest of the words - lines := Str[,] - for (i:=1; i 0) paintRow(g, r, rh, nrows) - - ry += rh - if (ry > rowsetBounds.h) break - g.translate(0, rh) - } - - g.pop - g.brush = border - g.drawRect(0, 0, size.w-1, size.h-1) - } - - ** Paint column headers. - private Void paintHeader(Graphics g) - { - g.font = headerFont - w := size.w - h := headerBounds.h - dx := 0 - - // header background - // TODO: cache brush based on size - g.brush = Gradient { x1=0; y1=0; x2=0; y2=h; stops=headerStops } - g.fillRect(0, 0, w, h) - - // cols - g.push - g.translate(-hscroll.cur, 0) - colw.each |cw,i| - { - tx := dx+4+(i==0?1:0) - ty := (headerhDef - headerFont.height) / 2 - - sort := sortCol == i - - g.brush = Color.black - g.push - g.clip(Rect(dx, 0, sort ? cw-16 : cw, h)) - colLines := colText[i] - colLines.each |line, j| - { - g.drawText(line, tx, ty) - ty += headerFont.height - } - g.pop - - if (sort) - { - ax := dx + cw - 12 - g.brush = headerArrow - g.translate(ax, ay) - g.fillPolygon(sortMode == SortMode.up ? upArrow : downArrow) - g.translate(-ax, -ay) - } - - dx += cw - if (i < colw.size-1) - { - g.brush = headerBorder - g.drawLine(dx-1, 0, dx-1, h) - } - } - g.pop - - // border - g.brush = border - g.drawRect(0, 0, w-1, h) // hide bottom - } - - ** Paint scrollbars. - private Void paintScrollBars(Graphics g) - { - vb := vscroll.bounds - hb := hscroll.bounds - g.brush = scrollBoxBg - g.fillRect(vb.x, hb.y, vb.w, hb.h) - - // vert - g.brush = Gradient { x1=vb.x+1; y1=0; x2=vb.x+vb.w-2; y2=0; stops=scrollTrackStops } - g.fillRect(vb.x, vb.y, vb.w, vb.h+1) - - if (vscroll.max > 0) - { - tb := vscroll.thumb - ty := tb.y + (tb.h / 2) - g.brush = Gradient { x1=vb.x+1; y1=0; x2=vb.x+vb.w-2; y2=0; stops=scrollThumbStops } - g.fillRoundRect(vb.x+1, vb.y+ty+1, vb.w-1, tb.h-2, 5, 5) - } - - g.brush = border - g.drawLine(vb.x, vb.y, vb.x, size.h) - - // horiz - g.brush = Gradient { x1=0; y1=hb.y+1; x2=0; y2=hb.y+hb.h-2; stops=scrollTrackStops } - g.fillRect(hb.x, hb.y, hb.w+1, hb.h) - - if (hscroll.max > 0) - { - tb := hscroll.thumb - tx := tb.x + (tb.w / 2) - g.brush = Gradient { x1=0; y1=hb.y+1; x2=0; y2=hb.y+hb.h-2; stops=scrollThumbStops } - g.fillRoundRect(hb.x+tx+2, hb.y+1, tb.w-3, hb.h-1, 5, 5) - } - - g.brush = border - g.drawLine(hb.x, hb.y, size.w+1, hb.y) - } - - ** Paint given row. - private Void paintRow(Graphics g, Int r, Int rowh, Int nrows) - { - sel := r == selected.first - w := rowsetBounds.w + hscroll.max + 1 - h := rowh - - g.push - g.clip(Rect(0, 0, w, h)) - - // background - g.brush = sel ? rowSelectedBg : (r.isOdd ? rowOddBg : rowEvenBg) - g.fillRect(0, 0, w, h) - - // paint cells - dx := 0 - colw.each |cw, c| - { - // skip if not visible - if (dx-hscroll.cur > rowsetBounds.w) return - - // paint cell if visible - if (dx+cw > hscroll.cur) - { - g.push - g.translate(dx, 0) - g.clip(Rect(0, 0, cw, h)) - csz := Size(cw, h) - paintCell(g, c, r, sel, csz) - paintCellOverlay(g, c, r, sel, csz) - - // border - if (c < colw.size-1) - { - g.brush = sel ? cellSelectedBorder : cellBorder - g.drawLine(cw-1, 0, cw-1, h-1) - } - g.pop - } - - // advance col - dx += cw - } - - // border - if (r < nrows-1 || vscroll.max == 0) - { - g.brush = rowBorder - g.drawLine(0, h-1, w, h-1) - } - g.pop - } - -////////////////////////////////////////////////////////////////////////// -// Events -////////////////////////////////////////////////////////////////////////// - - private Void handleMouse(Event e) - { - switch (e.id) - { - case EventId.mouseWheel: - if (e.delta.x == 0) vscroll.scroll(e.delta.y) - else hscroll.scroll(e.delta.x) - e.consumed = true - - case EventId.mouseMove: - if (vscroll.dragDelta != null) mouseDragVScroll(e) - else if (hscroll.dragDelta != null) mouseDragHScroll(e) - else if (contains(rowsetBounds, e.pos)) mouseMoveRowset(e) - - case EventId.mouseDown: - if (contains(vscroll.bounds, e.pos)) mouseDownVScroll(e) - else if (contains(hscroll.bounds, e.pos)) mouseDownHScroll(e) - else if (contains(headerBounds, e.pos)) mouseDownHeader(e) - else if (contains(rowsetBounds, e.pos)) mouseDownRowset(e) - - case EventId.mouseUp: - if (vscroll.dragDelta != null) vscroll.dragDelta = null - else if (hscroll.dragDelta != null) hscroll.dragDelta = null - else if (contains(headerBounds, e.pos)) mouseUpHeader(e) - else if (contains(rowsetBounds, e.pos)) mouseUpRowset(e) - } - } - - private Void handleKeyDown(Event e) - { - switch (e.key) - { - case Key.up: - i := ((selected.first ?: 1) - 1).max(0) - updateSelected(i) - e.consume - - case Key.down: - i := ((selected.first ?: -1) + 1).min(numRows-1) - updateSelected(i) - e.consume - - case Key.space: fireAction - } - } - -////////////////////////////////////////////////////////////////////////// -// Scroll Events -////////////////////////////////////////////////////////////////////////// - - private Void mouseDownVScroll(Event e) - { - pos := vscroll.toPos(e.pos.y, true) - cy := vscroll.bounds.y + vscroll.thumb.y + vscroll.thumb.h - if (pos != null) vscroll.dragDelta = e.pos.y - cy - else vscroll.scroll(e.pos.y < cy ? -scrollPage : scrollPage) - e.consumed = true - } - - private Void mouseDragVScroll(Event e) - { - pos := vscroll.toPos(e.pos.y - vscroll.dragDelta) - vscroll.pos(pos) - e.consumed = true - } - - private Void mouseDownHScroll(Event e) - { - pos := hscroll.toPos(e.pos.x, true) - cx := hscroll.bounds.x + hscroll.thumb.x + hscroll.thumb.w - if (pos != null) hscroll.dragDelta = e.pos.x - cx - else hscroll.scroll(e.pos.x < cx ? -scrollPage : scrollPage) - e.consumed = true - } - - private Void mouseDragHScroll(Event e) - { - pos := hscroll.toPos(e.pos.x - hscroll.dragDelta) - hscroll.pos(pos) - e.consumed = true - } - -////////////////////////////////////////////////////////////////////////// -// Header -////////////////////////////////////////////////////////////////////////// - - private Void mouseDownHeader(Event e) - { - } - - private Void mouseUpHeader(Event e) - { - col := toColIndex(e.pos.x) - sortMode = sortCol==col ? sortMode.toggle : SortMode.up - sortCol = col - onSort(col, sortMode) - relayout - } - -////////////////////////////////////////////////////////////////////////// -// Rowset -////////////////////////////////////////////////////////////////////////// - - private Void mouseMoveRowset(Event e) - { - row := toRowIndex(e) - if (row == null) return - - col := toColIndex(e.pos.x) - pos := toCellPos(e.pos, col, row) - size := toCellSize(col, row) - onCellMoved(e, col, row, pos, size) - } - - private Void mouseDownRowset(Event e) - { - if (e.count == 2) fireAction - } - - private Void mouseUpRowset(Event e) - { - row := toRowIndex(e) - if (row == null) - { - // clear selection - updateSelected(null) - } - else - { - updateSelected(row) - - // pos relative to cell - col := toColIndex(e.pos.x) - pos := toCellPos(e.pos, col, row) - size := toCellSize(col, row) - onCellPressed(e, col, row, pos, size) - } - } - - private Void updateSelected(Int? newSelected) - { - if (!selectionEnabled) return - if (selected.first == newSelected) return - selected = newSelected==null ? [,] : [newSelected] - repaintNoLayout = true - repaint - } - - private Void fireAction() - { - i := selected.first - if (i == null) return - onAction.fire(Event { id=EventId.action; widget=this; index=i }) - } - - private Int? toRowIndex(Event e) - { - my := vscroll.cur + e.pos.y - rowsetBounds.y + 2 - return rowb.findIndex |r| { r.contains(0, my) } - } - - private Int? toColIndex(Int x) - { - dx := 0 - x += hscroll.cur - c := colw.findIndex |w| - { - dx += w - return x < dx - } - return c==null ? colw.size-1 : c - } - - private Point toCellPos(Point p, Int col, Int row) - { - x := rowsetBounds.x - hscroll.cur - y := rowsetBounds.y - vscroll.cur - col.times |i| { x += colw[i] } - row.times |i| { y += rowb[i].h } - return Point(p.x-x, p.y-y) - } - - private Size toCellSize(Int col, Int row) - { - Size(colw[col], rowHeight(row)) - } - -////////////////////////////////////////////////////////////////////////// -// GxUtil -////////////////////////////////////////////////////////////////////////// - - ** Clip graphics cx to allow for full Rect bounds. - private Void clip(Graphics g, Rect r) - { - g.clip(Rect(r.x, r.y, r.w+1, r.h+1)) - } - - ** Returns true of Rect contains Point. - private Bool contains(Rect r, Point p) - { - r.contains(p.x, p.y) - } - -////////////////////////////////////////////////////////////////////////// -// Constants -////////////////////////////////////////////////////////////////////////// - - private static const Color border := Color("#9f9f9f") - - private static const Color headerBorder := Color("#bdbdbd") - private static const Color headerArrow := Color("#666") - private static const GradientStop[] headerStops := [ - GradientStop(Color("#f9f9f9"), 0f), - GradientStop(Color("#eee"), 0.5f), - GradientStop(Color("#e1e1e1"), 0.5f), - GradientStop(Color("#f5f5f5"), 1f), - ] - - private static const Point[] upArrow := [ - Point(0, 7), - Point(4, 0), - Point(8, 7) - ] - private static const Point[] downArrow := [ - Point(0, 0), - Point(4, 7), - Point(8, 0) - ] - - private static const Int scrollsz := 12 - private static const Color scrollBoxBg := Color("#eee") - private static const GradientStop[] scrollTrackStops := [ - GradientStop(Color("#eaeaea"), 0f), - GradientStop(Color("#f8f8f8"), 1f) - ] - private static const Color scrollThumbBorder := Color("#848fa6") - private static const GradientStop[] scrollThumbStops := [ - GradientStop(Color("#b5bfcd"), 0f), - GradientStop(Color("#8b99b2"), 1f) - ] - -////////////////////////////////////////////////////////////////////////// -// HTML -////////////////////////////////////////////////////////////////////////// - - ** Write HTML markup for this cell. - virtual Void writeHtml(WebOutStream out, Int col, Int row) {} - - ** Render cell as PNG image encoded as Base64 and write to HTML. - Void writePng(WebOutStream out, Int col, Int row) - { - if ("js" === Env.cur.runtime) ColUtil.writePng(this, out, col, row) - } - -////////////////////////////////////////////////////////////////////////// -// Fields -////////////////////////////////////////////////////////////////////////// - - const private Int headerhDef - const private Int ay - - private Int[] colw := [,] - private Rect[] rowb := [,] - private Int? sortCol := null - private SortMode sortMode := SortMode.up - - private Rect headerBounds := Rect.defVal - internal Rect rowsetBounds := Rect.defVal - private CTScrollBar vscroll := CTScrollBar { table=this } - private CTScrollBar hscroll := CTScrollBar { table=this; orient=Orientation.horizontal } - private Int headerh // header height with wrap applied - private Str[][]? colText // col name lines with wrap applied - - // repaint with no relayout - internal Bool repaintNoLayout := false -} - -************************************************************************** -** CTScrollBar -************************************************************************** -@Js -internal class CTScrollBar -{ - Void scroll(Int ds) - { - // short-circuit if not scrollable, or if already at min/max - if (max < 0) return - if (cur == 0 && ds < 0) return - if (cur == max && ds > 0) return - - cur += ds - cur = cur.max(0).min(max) - layout - table.repaintNoLayout = true - table.repaint - } - - Int? toPos(Int pixel, Bool inThumb := false) - { - if (isVert) - { - dy := pixel - bounds.y - thumb.h / 2 - if (inThumb && !thumb.contains(0, dy)) return null - return (dy.toFloat / (table.rowsetBounds.h - thumb.h).toFloat * max).toInt - } - else - { - dx := pixel - bounds.x - thumb.w / 2 - if (inThumb && !thumb.contains(dx, 0)) return null - return (dx.toFloat / (table.rowsetBounds.w - thumb.w).toFloat * max).toInt - } - } - - Void pos(Int p) - { - // short-ciruct if not scrollbale, or if already at min/max - if (max < 0) return - if (cur == 0 && p < 0) return - if (cur == max && p > max) return - - cur = p.max(0).min(max) - layout - table.repaintNoLayout = true - table.repaint - } - - Bool isVert() { orient == Orientation.vertical } - - Void layout() - { - if (isVert) - { - rh := table.rowsetBounds.h - vh := (rh.toFloat / (rh + max).toFloat * rh).toInt.max(20) - vy := (cur.toFloat / max.toFloat * (rh-vh)).toInt.max(0) - (vh / 2) - thumb = Rect(0, vy, bounds.w, vh) - } - else - { - rw := table.rowsetBounds.w - hw := (rw.toFloat / (rw + max).toFloat * rw).toInt.max(20) - hx := (cur.toFloat / max.toFloat * (rw-hw)).toInt.max(0) - (hw / 2) - thumb = Rect(hx, 0, hw, bounds.h) - } - } - - CanvasTable? table - Orientation orient := Orientation.vertical - Rect bounds := Rect.defVal // scrollbar bounds - Rect thumb := Rect.defVal // thumb bounds - Int cur := 0 // cur scroll pos - Int max := 0 // max scroll pos - Int? dragDelta // if dragging delta to apply -} - -************************************************************************** -** ColUtil -************************************************************************** -@Js -internal final class ColUtil -{ - native static Void writePng(CanvasTable table, WebOutStream out, Int col, Int row) -} diff --git a/src/webfwt/fan/CenterPane.fan b/src/webfwt/fan/CenterPane.fan deleted file mode 100644 index 886c7646c..000000000 --- a/src/webfwt/fan/CenterPane.fan +++ /dev/null @@ -1,89 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Oct 09 Andy Frank Creation -// - -using fwt -using gfx - -** -** CenterPane lays out content in three sections: left,center,right. -** The left and right widget is layed out using their prefSize, -** while the center widget is always centered in the panes bounds -** regardless of the size of the left and right widget. -** -@NoDoc -@Js -class CenterPane : Pane -{ - -////////////////////////////////////////////////////////////////////////// -// Children -////////////////////////////////////////////////////////////////////////// - - ** - ** Left widget is laid out with preferred width. - ** - Widget? left { set { remove(&left).add(it); &left = it } } - - ** - ** Center widget gets centered in remaining space in the center. - ** - Widget? center { set { remove(¢er).add(it); ¢er = it } } - - ** - ** Right widget is laid out with preferred width. - ** - Widget? right { set { remove(&right).add(it); &right = it } } - -////////////////////////////////////////////////////////////////////////// -// Layout -////////////////////////////////////////////////////////////////////////// - - override Size prefSize(Hints hints := Hints.defVal) - { - left := pref(this.left) - center := pref(this.center) - right := pref(this.right) - - w := (left.w + center.w + right.w) - h := left.h.max(center.h).max(right.h) - return Size(w, h) - } - - private Size pref(Widget? w) - { - return w == null || !w.visible ? Size.defVal : w.prefSize(Hints.defVal) - } - - override Void onLayout() - { - w := size.w - h := size.h - - left := this.left - if (left != null) - { - pref := left.prefSize(Hints(null, h)) - left.bounds = Rect(0, (h-pref.h)/2, pref.w, pref.h) - } - - center := this.center - if (center != null) - { - pref := center.prefSize(Hints(null, h)) - center.bounds = Rect((w-pref.w)/2, (h-pref.h)/2, pref.w, pref.h) - } - - right := this.right - if (right != null) - { - pref := right.prefSize(Hints(null, h)) - right.bounds = Rect(w-pref.w, (h-pref.h)/2, pref.w, pref.h) - } - } - -} \ No newline at end of file diff --git a/src/webfwt/fan/ColTree.fan b/src/webfwt/fan/ColTree.fan deleted file mode 100644 index 5b119361f..000000000 --- a/src/webfwt/fan/ColTree.fan +++ /dev/null @@ -1,241 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 3 Feb 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** ColTree visualizes a TreeModel as a series of columns. -** -@NoDoc -@Js -class ColTree : ContentPane -{ - ** Constructor. - new make(|This|? f := null) - { - if (f != null) f(this) - this.lists = [,] - this.listPane = ColListPane(this) - this.scroll = WebScrollPane - { - bg = Color("#eee") - hpolicy = WebScrollPane.auto - vpolicy = WebScrollPane.off - listPane, - } - this.content = scroll - refreshAll - } - - ** Backing data model of tree. - TreeModel model := TreeModel() - - ** - ** Show column headers. To specify column headers, implement - ** a 'header' method on your TreeModel, where the return type - ** can be a Str# or Widget#: - ** - ** Obj header(Obj node) - ** - Bool headerVisible := false - - ** Width of each column in pixels. - Int colw := 200 - - ** Update the entire tree's contents from the model. - Void refreshAll() - { - lists.clear - lists.add(ColList(this, model.roots)) - - listPane.removeAll - listPane.add(lists.first) - relayout - } - - ** Update the specified node from the model. - Void refreshNode(Obj node) - { - // TODO FIXIT - setExpanded(node, true) - } - - ** Get list of selected path in widget. - Obj[] path() - { - if (lists.size <= 1) return [,] - return lists[0..-2].map |x| { x.selected } - } - - ** Set the expanded state for this node. - Void setExpanded(Obj node, Bool expanded) - { - if (!expanded) return - if (!model.hasChildren(node)) return - - // check if we need to rollback - index := lists.findIndex |l| { l.items.contains(node) } - diff := lists.size-1 - index - while (diff > 0) - { - listPane.remove(lists.removeAt(-1)) - diff-- - } - - // make sure item is selected - lists[index].select(node) - - // add new list - kids := model.children(node) - list := ColList(this, kids) - lists.add(list) - listPane.add(list) - scroll.relayout - scroll.scrollToRight - onExpanded.fire(Event { data=node; widget=this }) - } - - ** - ** Callback when a node's expanded state changes. - ** - ** Event fields: - ** - Event.data: node object that was expanded. - ** - once EventListeners onExpanded() { EventListeners() } - - ** - ** Callback when selected nodes change. - ** - ** Event id fired: - ** - EventId.select - ** - ** Event fields: - ** - Event.data: the primary selection node object. - ** - once EventListeners onSelect() { EventListeners() } - - ** Fire onSelect event. - internal Void fireSelect(Obj node) - { - onSelect.fire(Event { id=EventId.select; data=node }) - } - - private ColList[] lists - private ColListPane? listPane - private WebScrollPane scroll -} - -************************************************************************** -** ColListPane -************************************************************************** -@Js -internal class ColListPane : Pane -{ - new make(ColTree tree) { this.tree = tree } - override Size prefSize(Hints hints := Hints.defVal) - { - sz := children.size - pw := sz * tree.colw - (sz-1) - 2 - return Size(pw, 200) - } - override Void onLayout() - { - x := -1 - y := -1 - h := size.h+2 - children.each |kid| - { - kid.bounds = Rect(x, y, tree.colw, h) - x += tree.colw-1 - } - } - private ColTree tree -} - -************************************************************************** -** ColList -************************************************************************** -@Js -internal class ColList : EdgePane -{ - new make(ColTree tree, Obj[] items) - { - this.tree = tree - this.items = items - this.webList = ColWebList(tree, items) - if (tree.headerVisible) this.top = makeHeader - this.center = webList - } - - Obj[] items - Obj? selected() { webList.selected.first } - - Void select(Obj node) { webList.selected = [node] } - - private Widget makeHeader() - { - try - { - h := items.isEmpty ? "" : tree.model->header(items.first) - if (h is Widget) return h - else if (h is Str) - { - return BorderPane - { - bg = labelBg - insets = labelPad - WebLabel - { - text = ((Str)h).upper - fg = labelFg - font = Desktop.sysFontSmall.toBold - style = ["text-shadow":"#fff 0px 1px 1px"] - }, - } - } - } - catch (Err err) { err.trace } - return BorderPane - { - bg = labelBg - insets = labelPad - Label { font=Desktop.sysFontSmall.toBold }, - } - } - - private static const Insets labelPad := Insets(6) - private static const Color labelBg := Color("#eee") - private static const Color labelFg := Color("#666") - - private ColTree tree - private ColWebList webList -} - -************************************************************************** -** ColWebList -************************************************************************** -@Js -internal class ColWebList : WebList -{ - new make(ColTree tree, Obj[] items) - { - this.tree = tree - this.items = items - this.onSelect.add |e| - { - tree.setExpanded(e.data, true) - tree.fireSelect(e.data) - } - } - - // force native peer - private native Void dummy() - - private ColTree tree -} \ No newline at end of file diff --git a/src/webfwt/fan/FileUploader.fan b/src/webfwt/fan/FileUploader.fan deleted file mode 100644 index fbcdfe946..000000000 --- a/src/webfwt/fan/FileUploader.fan +++ /dev/null @@ -1,242 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Jul 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** FileUploader enables file uploading from a browser. -** -@Js -class FileUploader : Pane -{ - ** Return a Dialog to wrap given FileUploader instance. - static Dialog dialog(Window w, FileUploader f) - { - loc := "$" - dlg := WebDialog(w) - { - title = loc - body = f - insetsBody = Insets(10) - } - Command? upload - upload = Command.make(loc, null) |e| - { - upload.enabled = false - f.onComplete.add - { - dlg.commands = [Dialog.ok] - dlg.buildContent - dlg.relayout - } - f.upload - } - upload.enabled = false - f._onFilesChanged.add |e| { upload.enabled = e.index > 0 } - dlg.commands = [upload, Dialog.cancel] - return dlg - } - - ** It-block constructor. - new make(|This|? f := null) - { - if (f != null) f(this) - top = ContentPane() - list = multi - ? WebScrollPane { bg=Color.white } - : BorderPane { bg=Color.white; border=Border("#9f9f9f") } - content = EdgePane - { - // minh prevents content for jumping when icon changes - it.top = ConstraintPane { minh=32; this.top, } - center = ConstraintPane - { - prefh := multi ? (5*36) : 36 - minw=400; maxw=400 - minh=prefh; maxh=prefh - list, - } - } - add(content) - reset - } - - ** Allow multiple file uploading. - const Bool multi := false - - ** Target URI to upload files. Each file is uploaded on a - ** discrete POST request. The original name of the file is - ** contained in the 'FileUpload-filename' request header. - const Uri uri - - ** If 'true' the POST content is formatted as "multipart/form-data". - ** If 'false' the raw file content is posted. - const Bool useMultiPart := false - - ** Additional HTTP headers to POST along with file content. - const Str:Str headers := [:] - - ** EventListener invoked when all uploads have completed. - once EventListeners onComplete() { EventListeners() } - - ** Invoke upload process for currently selected files. - Void upload() - { - working = true - top.content = Label - { - image = Image(`fan://webfwt/res/img/throbber.gif`) - text = "$" - } - onSubmit - relayout - } - - ** Reset this uploader, clearing all completed uploads - ** or selected files. - Void reset() - { - if (working) throw Err("Upload in progress") - top.content = GridPane - { - numCols = 2 - MiniButton { text="$"; onAction.add { onChoose }}, - Label { text="$" }, - } - onClear - relayout - } - - ** Callback when all file uploads are complete. - private Void onUploadComplete(FileUpload[] files) - { - // map files into name:response - map := Str:Str[:] - files.each |f| { map[f.name] = f.response } - - // update interface and notify listeners - working = false - top.content = Label - { - image = Image(`fan://icons/x16/check.png`) - text = "$" - } - relayout - onComplete.fire(Event { id=EventId.action; widget=this; data=map.ro }) - } - - override Size prefSize(Hints hints := Hints.defVal) - { - cp := content.prefSize - return Size(cp.w+12, cp.h+12) - } - - override Void onLayout() - { - content.bounds = Rect(6, 6, size.w-12, size.h-12) - } - - private native Void onChoose() - private native Void onRemove(Int index) - private native Void onClear() - private native Void onSubmit() - - private Void onFilesChanged(FileUpload[] files) - { - vpane := VPane() - files.each |file,i| - { - Widget? status - if (!file.active) - status = MiniButton { text="$"; onAction.add { onRemove(i) }} - else if (file.inProgress) - status = ProgressBar { val=file.progress } - else - status = Label { text=file.status; fg=Color("#777") } - - vpane.add(FileUploadRow([ - WebLabel { text=file.name; softClip=true }, - status, - ], multi && i > 0)) - } - list.content = vpane - list.relayout - - // internal hook for dialog - _onFilesChanged.fire(Event { index=files.size }) - } - - // internal hook for dialog - internal once EventListeners _onFilesChanged() { EventListeners() } - - private Widget content - private ContentPane top - private ContentPane list - private Bool working := false -} - -************************************************************************** -** FileUpload -************************************************************************** -@Js -internal class FileUpload -{ - Str? name // file name - Obj? file // file object - Bool active := false // is upload active - Bool waiting := true // is upload waiting for connection - Bool complete := false // is upload complete - Int progress := 0 // if uploading, cur progress as 0..100% - Str response := "" // response text upon completion - - Str status() - { - if (!active) return "" - if (waiting) return "$" - if (complete) return "$" - return "$progress%" - } - - Bool inProgress() { active && !waiting && !complete } -} - -************************************************************************** -** FileUploadRow -************************************************************************** -@Js -internal class FileUploadRow : Pane -{ - new make(Widget[] kids, Bool sep) - { - addAll(kids) - if (sep) add(BorderPane { border=Border("1,0,0,0 #ccc") }) - } - - override Size prefSize(Hints hints := Hints.defVal) { Size(400, 36) } - - override Void onLayout() - { - w := size.w - 12 - h := size.h - 12 - - b := children[1] - bp := b.prefSize - bx := w - bp.w - by := (h - bp.h) / 2 - b.bounds = Rect(6+bx, 6+by, bp.w, bp.h) - - a := children.first - ap := a.prefSize - ay := (h - ap.h) / 2 - aw := w - bp.w - 12 - a.bounds = Rect(6, 6+ay, aw, ap.h) - - if (children.size == 3) children.last.bounds = Rect(0, 0, size.w, 1) - } -} diff --git a/src/webfwt/fan/FixedPane.fan b/src/webfwt/fan/FixedPane.fan deleted file mode 100644 index d9b3d572f..000000000 --- a/src/webfwt/fan/FixedPane.fan +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 21 May 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** FixedPane assigns a fixed width and/or height to a content widget. -** -@NoDoc -@Js -class FixedPane : ContentPane -{ - ** Fixed width for content, or null for preferred width. - Int? fixw := null - - ** Fixed height for content, or null for preferred width. - Int? fixh := null - - override Size prefSize(Hints hints := Hints.defVal) - { - if (content == null) return Size.defVal - if (fixw != null && fixh != null) return Size(fixw, fixh) - pref := content.prefSize - pw := fixw ?: pref.w - ph := fixh ?: pref.h - return Size(pw, ph) - } - - override Void onLayout() - { - pref := content.prefSize - defw := size.w.min(pref.w) - defh := size.h.min(pref.h) - content.bounds = Rect(0, 0, fixw ?: defw, fixh ?: defh) - } -} \ No newline at end of file diff --git a/src/webfwt/fan/FlowPane.fan b/src/webfwt/fan/FlowPane.fan deleted file mode 100644 index f77d529ad..000000000 --- a/src/webfwt/fan/FlowPane.fan +++ /dev/null @@ -1,114 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Oct 09 Andy Frank Creation -// - -using fwt -using gfx - -** -** FlowPane lays out widgets in rows. Widgets are layed out consecutively -** based on their preferred size. Widgets are wrapped to the next row -** when they exceed the Pane's width. The row height will be the max -** pref size of the widgets in that row. -** -@NoDoc -@Js -class FlowPane : Pane -{ - -////////////////////////////////////////////////////////////////////////// -// Children -////////////////////////////////////////////////////////////////////////// - - ** Gap to leave between widgets horizontally. - Int hgap := 4 - - ** Gap to leave between widgets vertically. - Int vgap := 4 - -////////////////////////////////////////////////////////////////////////// -// Layout -////////////////////////////////////////////////////////////////////////// - - override Size prefSize(Hints hints := Hints.defVal) - { - //w := hints.w==0 ? Int.maxVal : hints.w - w := Int.maxVal - pw := 0 - ph := 0 - rh := 0 // cur row pref width - rw := 0 // cur row pref height - - children.each |kid,i| - { - // widget pref size - tw := 0 - if (i > 0) tw += hgap - pref := kid.prefSize - tw += pref.w - - if (rw+tw > w) - { - // wrap row - pw = pw.max(rw) - ph += rh + vgap - rw = pref.w - rh = pref.h - } - else - { - // accumulate - rw += tw - rh = rh.max(pref.h) - } - } - - pw = pw.max(rw) - ph = ph + rh - return Size(pw, ph) - } - - override Void onLayout() - { - row := Widget[,] - w := size.w - dx := 0 - dy := 0 - rh := 0 // cur row max height - - // valign method - valign := |Widget x, Int h| - { - x.pos = Point(x.pos.x, (h - x.bounds.h) / 2) - } - - children.each |kid| - { - pref := kid.prefSize - - if (dx+pref.w > w) - { - // center vertically for this row - row.each |r| { valign(r, rh) } - - // wrap row - dx = 0 - dy += rh + vgap - rh = 0 - } - else row.add(kid) - - // set bounds - kid.bounds = Rect(dx, dy, pref.w, pref.h) - dx += pref.w + hgap - rh = rh.max(pref.h) - } - - // center vertically any leftovers - row.each |r| { valign(r, rh) } - } -} \ No newline at end of file diff --git a/src/webfwt/fan/GMap.fan b/src/webfwt/fan/GMap.fan deleted file mode 100644 index e044f9a31..000000000 --- a/src/webfwt/fan/GMap.fan +++ /dev/null @@ -1,77 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 26 Jun 2009 Andy Frank Creation -// - -using gfx -using fwt - -************************************************************************** -** GMap embeds a GoogleMap in a widget. -************************************************************************** -@NoDoc -@Js -class GMap : ContentPane -{ - ** Add a marker to place on the map. - native Void addMarker(MapMarker marker) - - ** - ** Add a route to place on the map. List should be pairs of - ** lat,lng coords. - ** - native Void addRoute(Float[] route, Color? color := null) - - ** The zoom level for this map. Defaults to 4. - native Int zoom - - ** Center point for this map. Value should be a single lat,lng - ** pair. Defaults to center of US. - native Float[] center - - ** Configure map to automatically fit all markers/routes into - ** view. This may override `zoom` and `center` fields. - Bool fitBounds := true - - ** Type of map to display. - MapType mapType := MapType.roadMap -} - -************************************************************************** -** Type of map to display for GMap. -************************************************************************** -@NoDoc -@Js -enum class MapType -{ - roadMap, - satellite, - hybrid, - terrain -} - -************************************************************************** -** Marker placed on maps. -************************************************************************** -@NoDoc -@Js -class MapMarker -{ - ** Constructor. - new make(|This| f) { f(this) } - - ** Lat pos for marker. - const Float lat - - ** Long pos for marker. - const Float lng - - ** Marker color, or null for default. - const Color? color := null - - ** HTML markup to display in InfoPopup when marker is clicked. - const Str? infoHtml := null -} diff --git a/src/webfwt/fan/HPane.fan b/src/webfwt/fan/HPane.fan deleted file mode 100644 index 83d122df5..000000000 --- a/src/webfwt/fan/HPane.fan +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 8 Sep 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** HPane lays out widgets horizontally using the same height -** and the preferred width. -** -@NoDoc -@Js -class HPane : Pane -{ - ** Configure where children are aligned when pane contains - ** additional extra horizontal space. If set to 'Halign.fill' - ** children are sized evenly to fit pane width. - Halign halign := Halign.left - - override Size prefSize(Hints hints := Hints.defVal) - { - pw := 0 - ph := 0 - - children.each |kid| - { - pref := kid.prefSize - pw += pref.w - ph = ph.max(pref.h) - } - - return Size(pw, ph) - } - - override Void onLayout() - { - h := size.h - x := 0 - - if (halign == Halign.fill) - { - // fill space - w := size.w / children.size - children.each |kid,i| - { - if (i == children.size-1) w = size.w-x - kid.bounds = Rect(x, 0, w, h) - x += w - } - } - else - { - // use pref size - children.each |kid| - { - p := kid.prefSize - kid.bounds = Rect(x, 0, p.w, h) - x += p.w - } - } - } - -} \ No newline at end of file diff --git a/src/webfwt/fan/HtmlPane.fan b/src/webfwt/fan/HtmlPane.fan deleted file mode 100644 index 9b9c63b9b..000000000 --- a/src/webfwt/fan/HtmlPane.fan +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 11 Dec May 09 Andy Frank Creation -// - -using gfx -using fwt - -** -** HtmlPane displays a HTML fragment inside a fwt::Widget. -** -@Js -class HtmlPane : Pane -{ - ** The width in pixels of the HTML content. - Int width := 100 - - ** Set font used for markup. - Font? font := null - - ** Foreground color used for markup. - Color? fg := null - - ** The HTML fragment to display. - native Str html - - override native Size prefSize(Hints hints := Hints.defVal) - override Void onLayout() {} - -} - diff --git a/src/webfwt/fan/Hyperlink.fan b/src/webfwt/fan/Hyperlink.fan deleted file mode 100644 index 7bb821717..000000000 --- a/src/webfwt/fan/Hyperlink.fan +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 10 Jun May 09 Andy Frank Creation -// - -using gfx -using fwt - -** -** Hyperlink adds link support to WebLabels. -** -@Js -class Hyperlink : WebLabel -{ - ** The uri to hyperlink to if widget is clicked. Defaults to "#". - native Uri uri - - ** Link target. - Str target := "_self" - - ** Underline mode for hyperlink. - UnderlineMode underline := UnderlineMode.underline - - ** Callback to invoke before link is followed. - once EventListeners onBefore() { EventListeners() } -} - -************************************************************************** -** HyperlinkTarget -************************************************************************** -@Js -enum class HyperlinkTarget -{ - underline, - hover, - none -} - -************************************************************************** -** UnderlineMode -************************************************************************** -@Js -enum class UnderlineMode -{ - underline, - hover, - none -} - - diff --git a/src/webfwt/fan/MiniButton.fan b/src/webfwt/fan/MiniButton.fan deleted file mode 100644 index ef2a018f5..000000000 --- a/src/webfwt/fan/MiniButton.fan +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Oct 09 Andy Frank Creation -// - -using fwt -using gfx - -** -** MiniButton. -** -@Js -class MiniButton : Pane -{ - - ** - ** Constructor - ** - new make(|This|? f := null) - { - if (f != null) f(this) - } - - ** - ** Text for button. Defaults to "". - ** - native Str text - - ** - ** Callback function when button is pressed or selection is changed. - ** - ** Event id fired: - ** - `fwt::EventId.action` - ** - ** Event fields: - ** - none - ** - @Transient EventListeners onAction := EventListeners() { private set } - - override native Size prefSize(Hints hints := Hints.defVal) - override Void onLayout() {} - - ** - ** Command associated with this button. Setting the - ** command automatically maps the text, enable state, - ** and eventing to the command. - ** - Command? command - { - set - { - newVal := it - this.&command?.unregister(this) - this.&command = newVal - if (newVal != null) - { - enabled = newVal.enabled - text = newVal.name - onAction.add |e| { newVal.invoke(e) } - newVal.register(this) - } - } - } -} - diff --git a/src/webfwt/fan/MiniCombo.fan b/src/webfwt/fan/MiniCombo.fan deleted file mode 100644 index ca495fb9b..000000000 --- a/src/webfwt/fan/MiniCombo.fan +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Jan 11 Andy Frank Creation -// - -using fwt -using gfx - -** -** MiniCombo. -** -@NoDoc -@Js -class MiniCombo : Pane -{ - -////////////////////////////////////////////////////////////////////////// -// Construction -////////////////////////////////////////////////////////////////////////// - - ** Constructor. - new make(|This|? f := null) - { - if (f != null) f(this) - } - - ** Callback when item is selected. - EventListeners onSelect := EventListeners() { private set } - - ** Text for button. Defaults to "". - native Str text - - ** List of selection items. - Obj[] items := [,] - - ** Selected item. - Obj selected - { - get { i := selectedIndex; return i == null ? "" : items[i] } - set { i := index(it); if (i != null) selectedIndex = i } - } - - ** Index of selected item. - Int? selectedIndex - { - set { &selectedIndex=it; select } - } - - ** Get index of specified item. - Int? index(Obj item) { return items.index(item) } - -////////////////////////////////////////////////////////////////////////// -// Widget -////////////////////////////////////////////////////////////////////////// - - override native Size prefSize(Hints hints := Hints.defVal) - override Void onLayout() {} - -////////////////////////////////////////////////////////////////////////// -// Popup -////////////////////////////////////////////////////////////////////////// - - private Void select() - { - text = selected.toStr - relayout - } - - private Void openDropDown() - { - vpane := VPane() - popup := HudPopup - { - insets = Insets(6) - body = ConstraintPane { minw=125; vpane, } - onClose.add { dropDownClosed } - } - - items.each |item,i| - { - vpane.add(BorderPane - { - it.onMouseUp.add - { - popup.close - text = item.toStr - relayout - onSelect.fire(Event { id=EventId.select; it.widget=this; it.index=i; data=item }) - } - insets = Insets(4) - Label { it.text=item.toStr; fg=Color.white }, - }) - } - - popup.open(this, Point(0, size.h)) - } - - private native Void dropDownClosed() - -} - diff --git a/src/webfwt/fan/OverlayPane.fan b/src/webfwt/fan/OverlayPane.fan deleted file mode 100644 index 3a73acc74..000000000 --- a/src/webfwt/fan/OverlayPane.fan +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) 2013, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 4 Apr 2013 Andy Frank Creation -// - -using gfx -using fwt - -** -** OverlayPane is a dismissable pane that floats above all other content. -** -@Js -class OverlayPane : ContentPane -{ - ** Open this overlay at the coordinates relative to the parent widget. - native This open(Widget parent, Point pos) - - ** Close this overlay. - native Void close() - - ** Callback function directly before overlay is opened. - ** - id: `fwt::EventId.open` - once EventListeners onBeforeOpen() { EventListeners() } - - ** Callback function when overlay is open. - ** - id: `fwt::EventId.open` - once EventListeners onOpen() { EventListeners() } - - ** Callback function when overlay is closed. - ** - id: `fwt::EventId.close` - once EventListeners onClose() { EventListeners() } - - ** Horizontal alignment of overlay, using 'open(pos)' as origin. - Halign halign := Halign.right - - ** Vertial alignment of overlay, using 'open(pos)' as origin. - Valign valign := Valign.bottom - - ** Animate overlay open/close/resize. Must be configured before 'open'. - Bool animate := true - - ** Move overlay to new point, where point is relative to parent - ** widget passed to 'open'. - native Void move(Point pos) -} \ No newline at end of file diff --git a/src/webfwt/fan/PaleTreeList.fan b/src/webfwt/fan/PaleTreeList.fan deleted file mode 100644 index 066537fc8..000000000 --- a/src/webfwt/fan/PaleTreeList.fan +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Dec 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** Pale blue themed TreeList. -** -@NoDoc -@Js -class PaleTreeList : TreeList -{ - // force peer - private native Void dummy() -} - diff --git a/src/webfwt/fan/Popup.fan b/src/webfwt/fan/Popup.fan deleted file mode 100644 index ccf3b7d7a..000000000 --- a/src/webfwt/fan/Popup.fan +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 14 Jul 09 Andy Frank Creation -// - -using gfx -using fwt - -** -** Popup displays a content widget in a popup window. -** -@Js -class Popup : ContentPane -{ - ** Open this popup at the coordinates relative to the parent widget. - native This open(Widget parent, Point pos) - - ** Close this popup. - native Void close() - - ** Find and return the first parent Popup for the given widget, or - ** null if no parent Popup can be found. - static Popup? find(Widget w) - { - p := w.parent - while (p != null && p isnot Popup) p = p.parent - return p - } - - ** Callback function directly before popup is opened. - ** - id: `fwt::EventId.open` - once EventListeners onBeforeOpen() { EventListeners() } - - ** Callback function when popup is open. - ** - id: `fwt::EventId.open` - once EventListeners onOpen() { EventListeners() } - - ** Callback function when popup is closed. - ** - id: `fwt::EventId.close` - once EventListeners onClose() { EventListeners() } - - ** Horizontal alignment of popup, using 'open(pos)' as origin. - Halign halign := Halign.right - - ** Vertial alignment of popup, using 'open(pos)' as origin. - Valign valign := Valign.bottom - - ** Animate popup open/close/resize. Must be configured before 'open'. - Bool animate := true - - ** Move popup to new point, where point is relative to parent - ** widget passed to 'open'. - native Void move(Point pos) - - ** Attach an "onPopup" event handler to the given widget. - static Void attach(Widget w, |Event e| f) - { - active := false - w.onMouseDown.add { active=true } - w.onMouseUp.add |e| - { - if (!active) return - f(e) - active = false - } - } -} \ No newline at end of file diff --git a/src/webfwt/fan/RowPane.fan b/src/webfwt/fan/RowPane.fan deleted file mode 100644 index 0ad0371dd..000000000 --- a/src/webfwt/fan/RowPane.fan +++ /dev/null @@ -1,265 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 14 Feb 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** RowPane lays out rows of widgets into rows and columns. -** -@NoDoc -@Js -class RowPane : Pane -{ - ** Constructor. - new make(|This| f) - { - this.canvas = RowPaneCanvas() - add(canvas) - f(this) - } - - ** Column layouts for pane. - ColLayout[] cols - - ** Background brush for pane, or null for none. - Brush? bg := null - - ** Color to use for drawing row borders, or null for none. - Color? rowBorder := null - - ** Map of row indexes to brushes for overriding row background. - Int:Brush rowBg := [:] - - ** Return the child widgets for this row. - Widget[] rowChildren(Int index) - { - rowSize := (children.size-1) / cols.size - if (index < 0 || index >= rowSize) throw IndexErr() - - s := (index * cols.size) + 1 - e := s + cols.size - return children[s..= y && pos.y <= (y+h)) return true - y += h - if (rowBorder != null) y++ - return false - } - } - - override Size prefSize(Hints hints := Hints.defVal) - { - if ((children.size-1) % cols.size != 0) - throw ArgErr("Children must fill columns evenly") - - // num rows/cols - colSize := cols.size - rowSize := (children.size-1) / colSize - - // calc prefSizes - prefs := Size[,] - children.eachRange(1..-1) |kid| { prefs.add(kid.prefSize) } - - // find column widths and heights - colw := Int[,].fill(0, colSize) - rowh := Int[,].fill(0, rowSize) - offset := 0 - rowSize.times |ri| - { - cols.each |col, ci| - { - p := prefs[offset++] - pw := p.w + (col.insets.left + col.insets.right) - ph := p.h + (col.insets.top + col.insets.bottom) - colw[ci] = colw[ci].max(pw) - rowh[ri] = rowh[ri].max(ph) - } - } - - // find total pref size - Int pw := colw.reduce(0) |Int v, Int w->Int| { w+v } - Int ph := rowh.reduce(0) |Int v, Int h->Int| { h+v } - if (rowBorder != null) ph = (Int)ph + rowSize - 1 - return Size(pw, ph) - } - - override Void onLayout() - { - if ((children.size-1) % cols.size != 0) - throw ArgErr("Children must fill columns evenly") - - // num rows/cols - colSize := cols.size - rowSize := (children.size-1) / colSize - - // calc prefSizes - prefs := Size[,] - children.eachRange(1..-1) |kid| { prefs.add(kid.prefSize) } - - // find column widths and heights - colw := Int[,].fill(0, colSize) - rowh := Int[,].fill(0, rowSize) - offset := 0 - rowSize.times |ri| - { - cols.each |col, ci| - { - p := prefs[offset++] - pw := p.w + (col.insets.left + col.insets.right) - ph := p.h + (col.insets.top + col.insets.bottom) - colw[ci] = colw[ci].max(pw) - rowh[ri] = rowh[ri].max(ph) - } - } - - // calculate flex - maxw := 0 - colw.each |cw| { maxw += cw } - dw := size.w - maxw - if (dw != 0) - { - cols.each |col,i| - { - if (col.flex == 0) return - colw[i] += (dw.toFloat * col.flex.toFloat / 100f).toInt - } - } - - // layout bg - canvas.bg = bg - canvas.rowBorder = rowBorder - canvas.rowHeights = rowh - canvas.rowBg = rowBg - canvas.pos = Point.defVal - canvas.size = size - - // layout children - offset = 0 - dy := 0 - rowSize.times |ri| - { - dx := 0 - rh := rowh[ri] - cols.each |col, ci| - { - cw := colw[ci] - p := prefs[offset] - w := children[offset+1] - - // account for insets - iw := cw - (col.insets.left + col.insets.right) - ih := rh - (col.insets.top + col.insets.bottom) - - wx := 0 // init to left - wy := 0 // init to top - ww := iw.min(p.w) // init to pref/space avail - wh := ih.min(p.h) // init to pref/space avail - - switch (col.halign) - { - case Halign.center: wx = (iw - p.w) / 2 - case Halign.right: wx = iw - p.w - case Halign.fill: ww = iw - } - - switch (col.valign) - { - case Valign.center: wy = (ih - p.h) / 2 - case Valign.bottom: wy = ih - p.h - case Valign.fill: wh = ih - } - - // set bounds and advance - w.bounds = Rect(dx+wx+col.insets.left, dy+wy+col.insets.top, ww, wh) - dx += cw - offset++ - } - - dy += rh - if (rowBorder != null) dy++ - } - } - - private RowPaneCanvas canvas -} - -************************************************************************** -** ColLayout -************************************************************************** -@NoDoc -@Js -class ColLayout -{ - ** Horizontal alignment of widget for this column. - Halign halign := Halign.left - - ** Vertical alignment of widget for this column. - Valign valign := Valign.center - - ** If the difference between the preferred width and the available - ** width is non-zero, then 'flex' is the percetange of that difference - ** to take or give to widgets in this columm. Use '0' to always use - ** the preferred width. - Int flex := 0 - - ** Insets around widgets in this column. - Insets insets := Insets(6) -} - -************************************************************************** -** RowPaneCanvas -************************************************************************** -@Js -internal class RowPaneCanvas : Canvas -{ - Brush? bg := null - Color? rowBorder := null - Int[] rowHeights := [,] - Int:Brush rowBg := [:] - - override Void onPaint(Graphics g) - { - if (bg != null) - { - g.brush = bg - g.fillRect(0, 0, size.w, size.h) - } - - rowBg.each |c,i| - { - y := 0 - i.times |j| - { - y += rowHeights[j] - if (rowBorder != null) y++ - } - g.brush = c - g.fillRect(0, y, size.w, rowHeights[i]) - } - - if (rowBorder != null) - { - g.brush = rowBorder - dy := 0 - rowHeights.each |h| - { - g.drawLine(0, dy+h, size.w, dy+h) - dy += h+1 - } - } - } -} \ No newline at end of file diff --git a/src/webfwt/fan/Shadow.fan b/src/webfwt/fan/Shadow.fan deleted file mode 100644 index 9921f0ba5..000000000 --- a/src/webfwt/fan/Shadow.fan +++ /dev/null @@ -1,119 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 12 Jul 2011 Andy Frank Creation -// - -using gfx -using fwt - -** -** Models styled shadows. -** -@Js -@Serializable { simple=true } -const class Shadow -{ - ** Color of shadow - const Color color := Color.black - - ** Offset for shadow. - const Point offset := Point(0,0) - - ** Blur radius for shadow. - const Int blur := 0 - - ** Spread radius for shadow. - const Int spread := 0 - - ** Default is no shadow. - static const Shadow defVal := Shadow.fromStr("#000 0 0") - - ** Construct with it-block - new make(|This| f) - { - f(this) - toStr = formatStr - } - - ** - ** Parse a shadow from string (see `toStr`). If invalid - ** and checked is true then throw ParseErr otherwise - ** return null. The string is formated as: - ** - ** shadow := color x y [blur [spread]] - ** - ** Color must match `gfx::Color` string format. Position, - ** blur, and spread must all be integers. - ** - ** Examples: - ** Shadow("#000 1 1") => #000 1 1 0 0 - ** Shadow("#f00 1 1 2") => #f00 1 1 2 0 - ** Shadow("#fff 0 -1 1") => #fff 0 -1 1 0 - ** Shadow("#555 2 2 0 5") => #555 2 2 0 5 - ** - static new fromStr(Str str, Bool checked := true) - { - try - { - if (str.isEmpty) return defVal - return makeStr(str) - } - catch {} - if (checked) throw ParseErr("Invalid Shadow: $str") - return null - } - - private new makeStr(Str str) - { - p := str.split(' ') - if (p.size < 3 || p.size > 5) throw Err() - this.color = Color.fromStr(p.first.trim) - this.offset = Point(p[1].trim.toInt, p[2].trim.toInt) - this.blur = p.size > 3 ? p[3].trim.toInt : 0 - this.spread = p.size > 4 ? p[4].trim.toInt : 0 - this.toStr = formatStr - } - - ** Hash is based on string format. - override Int hash() { toStr.hash } - - ** Equality is based on string format. - override Bool equals(Obj? obj) - { - that := obj as Shadow - if (that == null) return false - return toStr == that.toStr - } - - ** String format - see `fromStr` for format. - override const Str toStr - - private Str formatStr() - { - s := StrBuf() - s.join(color.toCss) - s.join(offset.x) - s.join(offset.y) - if (blur > 0 || spread > 0) - { - s.join(blur) - if (spread > 0) s.join(spread) - } - return s.toStr - } - - ** Get CSS string for this Shadow. - Str toCss() - { - s := StrBuf() - s.join("${offset.x}px") - s.join("${offset.y}px") - if (spread > 0) s.join("${blur}px ${spread}px") - else if (blur > 0) s.join("${blur}px") - s.join(color.toCss) - return s.toStr - } -} \ No newline at end of file diff --git a/src/webfwt/fan/Sheet.fan b/src/webfwt/fan/Sheet.fan deleted file mode 100644 index 3499ffc57..000000000 --- a/src/webfwt/fan/Sheet.fan +++ /dev/null @@ -1,203 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 14 Jan 11 Andy Frank Creation -// - -using fwt -using gfx - -** -** Sheet is special modal window that displays from the top -** of a parent Window. -** -@NoDoc -@Js -class Sheet : ContentPane -{ - -////////////////////////////////////////////////////////////////////////// -// Conveniences -////////////////////////////////////////////////////////////////////////// - - ** Make a new Sheet displaying a warning icon, and given - ** title and message. Width is used to control the width - ** of the message text. - static new makeWarn(Str title, Str msg, Int width := 300) - { - Sheet - { - it.image = Image(`fan://icons/x64/warn.png`) - it.body = makeHtmlPane(title, msg, width) - it.commands = [Sheet.cancel] - } - } - - ** Layout an HtmlPane with given title and msg. - private static Widget makeHtmlPane(Str title, Str msg, Int w := 300) - { - HtmlPane - { - width = w - html = "$title.toXml -
- $msg.toXml -
" - } - } - -////////////////////////////////////////////////////////////////////////// -// Content -////////////////////////////////////////////////////////////////////////// - - ** Image to the left of the body when building content. - ** See `buildContent`. - Image? image - - ** Main body of the content: - ** - Str: displays string as label - ** - Widget: used as main content - ** See `buildContent`. - Obj? body - - ** The commands are mapped to buttons along the bottom of the sheet. - ** If a predefined command such as `ok` is passed, then it closes - ** the sheet and is returned as the result. If a custom command - ** is passed, then it should close the dialog as appropiate with - ** the result object. - Command[]? commands - -////////////////////////////////////////////////////////////////////////// -// Predefined Commands -////////////////////////////////////////////////////////////////////////// - - ** Predefined dialog command for OK. - static Command ok() { return SheetCommand("ok") } - - ** Predefined dialog command for Cancel. - static Command cancel() { return SheetCommand("cancel") } - - ** Predefined dialog command for Yes. - static Command yes() { return SheetCommand("yes") } - - ** Predefined dialog command for No. - static Command no() { return SheetCommand("no") } - - ** Convenience for '[ok, cancel]'. - static Command[] okCancel() { return [ok, cancel] } - - ** Convenience for '[yes, no]'. - static Command[] yesNo() { return [yes, no] } - -////////////////////////////////////////////////////////////////////////// -// Events -////////////////////////////////////////////////////////////////////////// - - ** Open sheet under given Window. - native This open(Window win) - - ** Close sheet. - native Void close(Obj? result := null) - - ** Callback function when popup is closed. - ** - Event.id: EventId.close - ** - Event.data: command used to close sheet - @Transient EventListeners onClose := EventListeners() { private set } - -////////////////////////////////////////////////////////////////////////// -// Build -////////////////////////////////////////////////////////////////////////// - - ** Build the sheet content using the `image`, `body`, and `commands` - ** fields. Return this. This method is automatically called by `open` - ** if the content field is null. - virtual This buildContent() - { - // build body widget if necessary - body := this.body - if (body == null) body = Label {} - if (body is Str) body = Label { text = body.toStr } - if (body isnot Widget) throw Err("body is not Str or Widget: ${Type.of(body)}") - - // combine body with image if specified - bodyAndImage := body as Widget - if (image != null) - { - bodyAndImage = GridPane - { - numCols = 2 - hgap = 16 - expandCol = 1 - halignCells = Halign.fill - valignCells = Valign.top - Label { it.image = this.image }, - body, - } - } - - // build buttons from commands - if (commands == null) commands := Command[,] - buttons := GridPane - { - numCols = commands.size - halignCells = Halign.fill - halignPane = Halign.right - uniformRows = true - uniformCols = true - hgap = 2 - } - commands.each |c| - { - if (c is SheetCommand) ((SheetCommand)c).sheet = this - buttons.add(ConstraintPane - { - minw = 70 - Button.makeCommand(c) { insets=Insets(0,10,0,10) }, - }) - } - - // build overall - this.content = WebBorderPane - { - bg = Color("#eaeeeeee") - GridPane - { - expandCol = 0 - expandRow = 0 - valignCells = Valign.fill - halignCells = Halign.fill - InsetPane(16) { bodyAndImage, }, - InsetPane - { - insets = Insets(0,14,14,14) - buttons, - }, - }, - } - - return this - } -} - -************************************************************************** -** SheetCommand -************************************************************************** -@Js -internal class SheetCommand : Command -{ - new make(Str id) : super.makeLocale(typeof.pod, id) - { - this.id = id - } - override Void invoked(Event? e) { sheet?.close(this) } - override Int hash() { return id.hash } - override Bool equals(Obj? that) - { - if (that isnot SheetCommand) return false - return that->id == id - } - Sheet? sheet - const Str id -} \ No newline at end of file diff --git a/src/webfwt/fan/SlidePane.fan b/src/webfwt/fan/SlidePane.fan deleted file mode 100644 index dc89d35d5..000000000 --- a/src/webfwt/fan/SlidePane.fan +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 30 Sep 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** SlidePane slides content into view. -** -@NoDoc -@Js -class SlidePane : Pane -{ - - ** PrefSize is maximum size of all children. - override Size prefSize(Hints hints := Hints.defVal) - { - pw := 0 - ph := 0 - children.each |kid| - { - p := kid.prefSize(hints) - pw = pw.max(p.w) - ph = ph.max(p.h) - } - return Size(pw,ph) - } - - ** Layout widgets. - override Void onLayout() - { - x := 0 - children.each |kid| - { - kid.bounds = Rect(x, 0, size.w, size.h) - x += size.w - } - } - - ** Index of widget currently in view. - Int cur := 0 - - private native Void dummy() // force native - -} \ No newline at end of file diff --git a/src/webfwt/fan/StyledButton.fan b/src/webfwt/fan/StyledButton.fan deleted file mode 100644 index 63b2d4305..000000000 --- a/src/webfwt/fan/StyledButton.fan +++ /dev/null @@ -1,176 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 12 Jul 2011 Andy Frank Creation -// - -using gfx -using fwt - -** -** StyledButton is a customizable button that wraps a content widget. -** -@Js -class StyledButton : ContentPane -{ - ** It-block constructor. - new make(|This|? f := null) - { - if (f != null) f(this) - } - - ** Construct HUD style button. - new makeHud(|This|? f := null) - { - border = Border("#131313 4") - bg = Gradient("0% 0%, 0% 100%, #5b5b5b, #393939") - bgPressed = Gradient("0% 0%, 0% 100%, #333, #484848") - dropShadow = Shadow("#555 0 1") - innerShadow = Shadow("#555 0 1") - innerShadowPressed = Shadow("#222 0 1") - if (f != null) f(this) - } - - ** Border of button, or null for none. This field cannot be - ** changed after widget peer has been created. - Border? border := Border("#9a9a9a 4") - - ** Insets betwee content and button border. - const Insets insets := Insets(1,10) - - ** Inner shadow color, of null for none. - const Shadow? innerShadow := Shadow("#fff 0 1") - - ** Inner shadow color when button is pressed, of null for none. - const Shadow? innerShadowPressed := Shadow("#ccc 0 1") - - ** Drop shadow color, or null for none. - const Shadow? dropShadow := Shadow("#dfdfdf 0 1") - - ** Background brush for button, or null for none. - const Brush? bg := Gradient("0% 0%, 0% 100%, #fefefe, #cfcfcf") - - ** Background brush when button is pressed, or null for none. - const Brush? bgPressed := Gradient("0% 0%, 0% 100%, #cecece, #d9d9d9") - - ** Tooltip to display on mouse hover, or null for none. - const Str? toolTip := null - - ** ButtonMode - only push and toggle are supported. - const ButtonMode mode := ButtonMode.push - - ** The button's selected state (if toggle). - Bool selected := false - { - set { &selected=it; updateState } - } - - ** Command associated with this button. Setting the - ** command automatically maps the enable state and - ** eventing to the command. - Command? command - { - set - { - newVal := it - this.&command?.unregister(this) - this.&command = newVal - if (newVal != null) - { - enabled = newVal.enabled - onAction.add |e| { newVal.invoke(e) } - newVal.register(this) - } - } - } - - ** EventListener invoked when button is pressed. - once EventListeners onAction() { EventListeners() } - - ** EventListener invoked when button is moved to pressed state. - ** Use `onAction` to properly register button action events. - once EventListeners onPressed() { EventListeners() } - - ** EventListener invoked when button is moved to released state. - ** Use `onAction` to properly register button action events. - once EventListeners onReleased() { EventListeners() } - - ** Group a list of StyledButtons into a single widget. - static Widget group(StyledButton[] buttons) - { - if (buttons.size == 1) return buttons.first - - flow := FlowPane { hgap = -1 } - color := buttons.first.border.colorTop - radius := buttons.first.border.radiusTopLeft - - buttons.each |b,i| - { - first := i == 0 - last := i == buttons.size-1 - left := first ? radius : 0 - right := last ? radius : 0 - b.border = Border("$color $left,$right,$right,$left") - flow.add(b) - } - - return flow - } - - ** Fire 'onAction' event. - private Void fireAction() - { - onAction.fire(Event { id=EventId.action; widget=this }) - } - - override Size prefSize(Hints hints := Hints.defVal) - { - if (content == null) return Size(100,40) - - p := content.prefSize - w := p.w + insets.left + insets.right - h := p.h + insets.top + insets.bottom - - if (border != null) - { - w += border.widthLeft + border.widthRight - h += border.widthTop + border.widthBottom - } - - if (dropShadow != null) - h += dropShadow.offset.y + dropShadow.blur + dropShadow.spread - - return Size(w,h) - } - - override Void onLayout() - { - c := content - if (c == null) return - - p := content.prefSize - w := size.w - (insets.left + insets.right) - h := size.h - (insets.top + insets.bottom) - - if (border != null) - { - w -= border.widthLeft + border.widthRight - h -= border.widthTop + border.widthBottom - } - - if (dropShadow != null) - h -= dropShadow.offset.y + dropShadow.blur + dropShadow.spread - - cw := w.min(p.w) - ch := h.min(p.h) - cx := insets.left + ((w-cw) / 2) - cy := insets.top + ((h-ch) / 2) - - c.bounds = Rect(cx, cy, cw, ch) - } - - private native Void updateState() -} - diff --git a/src/webfwt/fan/TextPane.fan b/src/webfwt/fan/TextPane.fan deleted file mode 100644 index 8e43f69f1..000000000 --- a/src/webfwt/fan/TextPane.fan +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 15 Oct 2010 Andy Frank Creation -// - -using fwt -using gfx - -** -** TextPane displays a block of pre-formatted text using -** a fixed-width font. -** -@NoDoc -@Js -class TextPane : Pane -{ - - ** The text to display. - native Str text - - ** Scroll to top of text content within the given duration. - native This scrollToTop(Duration dur := 100ms) - - ** Scroll to bottom of text content within the given duration. - native This scrollToBottom(Duration dur := 100ms) - - override native Size prefSize(Hints hints := Hints.defVal) - override Void onLayout() {} - -} - diff --git a/src/webfwt/fan/TransitionPane.fan b/src/webfwt/fan/TransitionPane.fan deleted file mode 100644 index f2520dce6..000000000 --- a/src/webfwt/fan/TransitionPane.fan +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 18 Oct 2011 Andy Frank Creation -// - -using gfx -using fwt - -** -** TransitionPane animates a transition between two widgets. -** -@NoDoc -@Js -class TransitionPane : ContentPane -{ - ** It-block constructor. - new make(|This|? f := null) { if (f != null) f(this) } - - ** Transition style. - ** - slideUp: slide new widget up from bottom - ** - flip: flip over like a card to reveal new widget - const Str style := "flip" - - ** Duration for transition animation. - const Duration dur := 500ms - - ** Transition to given widget using current style. - native Void transitionTo(Widget w) - - ** Meta data for transition animations. - @NoDoc - Str:Obj meta := [:] -} \ No newline at end of file diff --git a/src/webfwt/fan/TreeList.fan b/src/webfwt/fan/TreeList.fan deleted file mode 100644 index 04d21a64e..000000000 --- a/src/webfwt/fan/TreeList.fan +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 15 Jun 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** TreeList displays a tree-style list. -** -@Js -class TreeList : WebList -{ - ** Return true to use stripe odd/even row backgrounds. - @NoDoc - virtual Bool zebraStripe() { false } - - ** Return true if this item should be treated as group heading. - virtual Bool isHeading(Obj item) { false } - - ** Get display text for this item. - virtual Str text(Obj item) { item.toStr } - - ** Get font used for item, or null for default. - @NoDoc - virtual Font? font(Obj item) { null } - - ** Get the icon for this item. - virtual Image? icon(Obj item, Bool selected) { null } - - ** Get the size of the images returned in `icon`. - virtual Size iconSize() { Size(16,16) } - - ** Get the depth for this item. - virtual Int depth(Obj item) { 0 } - - ** Get the auxiliary text for this item, or null for none. - virtual Str? aux(Obj item) { null } - - ** Get the style used to render aux text. - ** - "def": default style - ** - "pill": pill capsule style - virtual Str auxStyle() { "def" } - - ** Get aux icon. The aux icon size may not exceed `iconSize`. - virtual Image? auxIcon(Obj item, Bool selected) { null } - - // force native peer - private native Void dummy() -} - diff --git a/src/webfwt/fan/Uploader.fan b/src/webfwt/fan/Uploader.fan deleted file mode 100644 index 2f1517fea..000000000 --- a/src/webfwt/fan/Uploader.fan +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Oct 09 Andy Frank Creation -// - -using fwt -using gfx - -** -** Uploader uploads files using a POST request. Once the -** dialog has been been closed via 'Ok', a form submission -** is invoked for the page. -** -@NoDoc -@Js -// TODO: get reworked like fresco? -class Uploader -{ - ** Open Uploader in dialog. - Void open(Window win, Uri uri, Str name) - { - id := "webfwt-uploader" - ok = Command("Upload", null) |e| - { - ok.enabled = false - cancel.enabled = false - submit(id) - } - cancel = Dialog.cancel - - Dialog(win) - { - title = "Upload" - body = HtmlPane - { - width = 350 - html = - "
- -
" - } - commands = [this.ok, this.cancel] - }.open - } - - private native Void submit(Str id) - private Command? ok - private Command? cancel -} - diff --git a/src/webfwt/fan/VPane.fan b/src/webfwt/fan/VPane.fan deleted file mode 100644 index dbe176f29..000000000 --- a/src/webfwt/fan/VPane.fan +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 8 Sep 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** VPane lays out widgets vertically using the same width -** and the preferred height. -** -@NoDoc -@Js -class VPane : Pane -{ - ** Configure where children are aligned when pane contains - ** additional extra vertical space. If set to 'Valign.fill' - ** children are sized evenly to fit pane height. - Valign valign := Valign.top - - override Size prefSize(Hints hints := Hints.defVal) - { - pw := 0 - ph := 0 - - children.each |kid| - { - pref := kid.prefSize - pw = pw.max(pref.w) - ph += pref.h - } - - return Size(pw, ph) - } - - override Void onLayout() - { - w := size.w - y := 0 - - if (valign == Valign.fill) - { - // fill space - h := size.h / children.size - children.each |kid,i| - { - if (i == children.size-1) h = size.h-y - kid.bounds = Rect(0, y, w, h) - y += h - } - } - else - { - // use pref size - children.each |kid| - { - p := kid.prefSize - kid.bounds = Rect(0, y, w, p.h) - y += p.h - } - } - } - -} \ No newline at end of file diff --git a/src/webfwt/fan/WebBorderPane.fan b/src/webfwt/fan/WebBorderPane.fan deleted file mode 100644 index e78524fb0..000000000 --- a/src/webfwt/fan/WebBorderPane.fan +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Oct 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebBorderPane extends BorderPane with additional functionality. -** -@NoDoc -@Js -class WebBorderPane : BorderPane -{ - ** Override style. Defaults to null. - native [Str:Str]? style -} - diff --git a/src/webfwt/fan/WebCanvas.fan b/src/webfwt/fan/WebCanvas.fan deleted file mode 100644 index 235a4cd80..000000000 --- a/src/webfwt/fan/WebCanvas.fan +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Sep 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebCanvas -** -@NoDoc -@Js -abstract class WebCanvas : Canvas -{ - ** Configure if canvas contents are cleared before repaint. - ** Defaults to 'true'. - native Bool clearOnRepaint -} diff --git a/src/webfwt/fan/WebCombo.fan b/src/webfwt/fan/WebCombo.fan deleted file mode 100644 index 42f2eb03c..000000000 --- a/src/webfwt/fan/WebCombo.fan +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 4 Dec 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebCombo extends Combo with additional functionality. -** -@Js -class WebCombo : Combo -{ - ** It-block constructor. - new make(|This|? f := null) : super(f) {} - - ** Get display text for item. - virtual Str itemText(Obj item) { item.toStr } - - // force peer - private native Void dummy() -} - - diff --git a/src/webfwt/fan/WebDialog.fan b/src/webfwt/fan/WebDialog.fan deleted file mode 100644 index 7af7266f8..000000000 --- a/src/webfwt/fan/WebDialog.fan +++ /dev/null @@ -1,170 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 14 Jan 11 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebDialog extends Dialog to add features specific to Browsers. -** -@NoDoc -@Js -class WebDialog : Dialog -{ - ** Constructor. - new make(Window? parent) : super(parent) - { - onClose.add |e| - { - r := e.data - if (r == Dialog.ok || r == Dialog.yes) - onCommit.fire(Event { id=EventId.close; widget=e.widget; data=r }) - } - } - - ** - ** Convenience to construct a message Widget to display - ** a heading message along with optional summary text. - ** Summary text will wrap if needed at given width in - ** pixels. - ** - static Widget msg(Image? icon, Str header, Str? summary := null, Int width := 325) - { - fh := Desktop.sysFont.toBold - fs := Desktop.sysFontSmall - - html := "
$header.toXml
" - if (summary != null) - html += "
$summary.toXml
" - - Widget pane := HtmlPane { it.width=width; it.html=html } - if (icon != null) pane = GridPane - { - hgap = 12 - numCols = 2 - valignCells = Valign.top - Label { image=icon; font=Font("1pt Arial") }, - pane, - } - - return pane - } - - ** Set to false in onValidate to cancel close action. - Bool invalid := false - - ** Event callback to validate dialog content before commit is called. - EventListeners onValidate := EventListeners() { private set } - - ** Event callback when dialog is closed with a commit command. - EventListeners onCommit := EventListeners() { private set } - - ** Insets around body widget. - Insets insetsBody := Insets(16) - - ** Widget displayed across bottom of dialog opposite command buttons. - Widget? aux := null - - ** Return command used to toggle 'details' display. - static Command toggleDetails() { ToggleDetailsCommand() } - - ** Override how content is constructed. - override This buildContent() - { - // build body widget if necessary - body := this.body - if (body == null) body = Label {} - if (body isnot Widget) throw Err("body is not Widget: $body.typeof") - - // detach body if already built - ((Widget)body).parent?.remove(body) - - // build buttons from commands - if (commands == null) commands := Command[,] - buttons := layoutButtons(commands) - - // build overall - this.content = EdgePane - { - center = EdgePane - { - center = InsetPane - { - insets = insetsBody - body, - } - bottom = InsetPane - { - insets = Insets(0, 14, 14, 14) - EdgePane { left=aux; right=buttons }, - } - } - } - - return this - } - - ** Layout buttons in parent Widget for dialog. - @NoDoc - Widget layoutButtons(Command[] cmds) - { - buttons := GridPane - { - numCols = cmds.size - halignCells = Halign.fill - uniformRows = true - uniformCols = true - hgap = 2 - } - cmds.each |c| - { - b := Button.makeCommand(c) { insets=Insets(0,10,0,10) } - if (c == defCommand) setDefButton(b) - buttons.add(ConstraintPane { minw=70; b, }) - } - return buttons - } - - ** Toggle details widget. - internal Void _toggleDetails(Bool visible) - { - if (details == null) return - if (details is Err) details = ((Err)details).traceToStr - if (details is Str) details = ConstraintPane { minw=350; Text - { - multiLine = true - editable = false - prefRows = 20 - font = Desktop.sysFontMonospace - text = details.toStr - }, } - if (details isnot Widget) - throw ArgErr("details not Err, Str, or Widget: ${Type.of(details)}") - content->bottom = details - ((Widget)details).visible = visible - relayout - } -} - -************************************************************************** -** ToggleDetailsCommand -************************************************************************** -@Js -internal class ToggleDetailsCommand : Command -{ - new make() : super.makeLocale(Dialog#.pod, "details") - { - mode = CommandMode.toggle - } - - override Void invoked(Event? e) - { - dlg := (WebDialog)widgets.first.window - dlg._toggleDetails(selected) - } -} diff --git a/src/webfwt/fan/WebLabel.fan b/src/webfwt/fan/WebLabel.fan deleted file mode 100644 index b543bf9ea..000000000 --- a/src/webfwt/fan/WebLabel.fan +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 16 Apr 2010 Andy Frank Creation -// 17 Mar 2011 Andy Frank Rename from FLabel to WebLabel -// - -using fwt -using gfx - -** -** WebLabel extends Label with additional functionality. -** -@Js -class WebLabel : Label -{ - ** Override horizontal gap between image and text. - ** Defaults to null. - native Int? hgap - - ** If enabled, text that is clipped by bounds is indicated - ** with ellipsis (...). Defaults to 'false'. - native Bool softClip - - ** Override image size. Original image will be scaled up or - ** down to match specified size. - native Size? imageSize - - ** Override text CSS style. Defaults to null. - native [Str:Str]? style -} - - diff --git a/src/webfwt/fan/WebList.fan b/src/webfwt/fan/WebList.fan deleted file mode 100644 index 88cd1588b..000000000 --- a/src/webfwt/fan/WebList.fan +++ /dev/null @@ -1,138 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Jun 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebList displays a set of objects as a List. -** -@Js -abstract class WebList : Pane -{ - ** Items to display for this list. Defaults to an empty list. - native Obj[] items - - ** Get the index for the given item. By default, items are - ** matched to indices by 'Obj.equals'. - virtual Int? index(Obj item) { items.index(item) } - - ** Return 'false' to disable selection. Defaults to 'true'. - @NoDoc - virtual Bool selectionEnabled() { true } - - ** Get or set vertical scroll position. - @NoDoc - native Int scrolly - - ** Enable multiple selection. Defaults to 'false' for single selection. - Bool multi := false - - ** If non-null, reported for preferred width. - Int? prefw := null - - ** If non-null, reported for preferred width. - Int? prefh := null - - ** Selected item, or null if no selection. - Obj[] selected := [,] - { - set - { - list := Int[,] - it.each |item| - { - index := index(item) - if (index != null) list.add(index) - } - &selected = it - &selectedIndexes = list - updateSelection - } - } - - ** Index of selected items, or empty list if no selection. - Int[] selectedIndexes := [,] - { - set - { - &selected = it.map |i| - { - if (i < 0 || i >= items.size) throw IndexErr("$i") - return items[i] - } - &selectedIndexes = it - updateSelection - } - } - - ** Fix for old code - @NoDoc Int? selectedIndex - { - get { selectedIndexes.first } - set { selectedIndexes = it == null ? Int#.emptyList : [it] } - } - - ** Update selection due to programtic changes. - private native Void updateSelection() - - ** Callback before an item is selected. To cancel the following - ** selection event, set 'Event.data' to the Str '"cancel"' - ** - `fwt::Event.index`: index of selected item - ** - `fwt::Event.data`: the selected item - once EventListeners onBeforeSelect() { EventListeners() } - - ** Callback when an item is selected. - ** - `fwt::Event.index`: index of selected item - ** - `fwt::Event.data`: the selected item - once EventListeners onSelect() { EventListeners() } - - ** Callback when an item is double-clicked. - ** - `fwt::Event.index`: index of selected item - ** - `fwt::Event.data`: the selected item - once EventListeners onAction() { EventListeners() } - - ** Fire onBeforeSelect with given index - return false to cancel. - private Bool fireBeforeSelect(Int[] index) - { - event := Event { - it.id = EventId.select - it.data = items[index.first] - it.index = index.first - it.widget = this - } - onBeforeSelect.fire(event) - return event.data != "cancel" - } - - ** Fire onSelect with given index. - private Void fireSelect(Int[] index) - { - selectedIndexes = index - onSelect.fire(Event { - it.id = EventId.select - it.data = selected.first - it.index = selectedIndexes.first - it.widget = this - }) - } - - ** Fire onAction with current selection. - private Void fireAction() - { - onAction.fire(Event { - it.id = EventId.select - it.data = selected.first - it.index = selectedIndexes.first - it.widget = this - }) - } - - native override Size prefSize(Hints hints := Hints.defVal) - native override Void onLayout() -} \ No newline at end of file diff --git a/src/webfwt/fan/WebScrollPane.fan b/src/webfwt/fan/WebScrollPane.fan deleted file mode 100644 index 579ed73c1..000000000 --- a/src/webfwt/fan/WebScrollPane.fan +++ /dev/null @@ -1,127 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 9 Sep 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebScrollPane provides a scrollable viewport for a content widget. -** -@NoDoc -@Js -class WebScrollPane : ContentPane -{ - -////////////////////////////////////////////////////////////////////////// -// Fields -////////////////////////////////////////////////////////////////////////// - - ** Background color of scroll pane. - Color bg := Color.white - - ** Border color of scroll pane, or null for default. - Color? border - - ** Scroll policy for horizontal scrollbar. - Int hpolicy := WebScrollPane.off - - ** Scroll policy for vertical scrollbar. - Int vpolicy := WebScrollPane.auto - -////////////////////////////////////////////////////////////////////////// -// Policy Constants -////////////////////////////////////////////////////////////////////////// - - ** Never display the scrollbar. - static const Int off := 0 - - ** Always display the scrollbar. - static const Int on := 1 - - ** Only display scrollbar when needed. - static const Int auto := 2 - -////////////////////////////////////////////////////////////////////////// -// Scrolling -////////////////////////////////////////////////////////////////////////// - - ** Horizontal scroll offset. - native Int scrollX() - - ** Vertical scroll offset. - native Int scrollY() - - ** Scroll to the top of the content. - native Void scrollToTop() - - ** Scroll to the bottom of the content. - native Void scrollToBottom() - - ** Scroll to the left-most point of the content. - native Void scrollToLeft() - - ** Scroll to the right-most point of the content. - native Void scrollToRight() - - ** Callback when content is scrolled. - ** - Event.pos: 'scrollX' and 'scrollY'. - once EventListeners onScroll() { EventListeners() } - -////////////////////////////////////////////////////////////////////////// -// Pane -////////////////////////////////////////////////////////////////////////// - - override Size prefSize(Hints hints := Hints.defVal) - { - if (content == null) return Size.defVal - - // +2 accounts for CSS border - see peer - pref := content.prefSize(hints) - return Size(pref.w+2, pref.h+2) - } - - override Void onLayout() - { - if (content == null) return - - // -2 accounts for CSS border - see peer - // -10 accounts for scrollbar when present - see peer - - if (hpolicy != off && vpolicy != off) - { - // both - pref := content.prefSize - w := (size.w-2).max(pref.w) - h := (size.h-2).max(pref.h) - if (w > size.w || hpolicy == on) h -= 10 - if (h > size.h || vpolicy == on) w -= 10 - content.bounds = Rect(0, 0, w, h) - } - else if (hpolicy != off) - { - // horiz only - pref := content.prefSize - w := (size.w-2).max(pref.w) - h := size.h-2 - if (w > size.w || hpolicy == on) h -= 10 - content.bounds = Rect(0, 0, w, h) - } - else - { - // vert only - pref := content.prefSize - w := size.w-2 - h := (size.h-2).max(pref.h) - if (h > size.h || vpolicy == on) w -= 10 - content.bounds = Rect(0, 0, w, h) - } - } - - // force native - private native Void dummy() -} \ No newline at end of file diff --git a/src/webfwt/fan/WebTable.fan b/src/webfwt/fan/WebTable.fan deleted file mode 100644 index 1b28fce6e..000000000 --- a/src/webfwt/fan/WebTable.fan +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Jun 2012 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebTable extends Table with additional functionality. -** -@NoDoc -@Js -class WebTable : Table -{ - ** Constructor. - new make(|This|? f := null) : super(f) {} - - ** Pos relative to table for given cell. - native Point cellPos(Int col, Int row) - - ** - ** Callback when mouse pressed inside a table cell. - ** Event.data is Str:Str map: - ** - posOnDisplay: mouse pos relative to display - ** - cellSize: cell size in pixels - ** - col: table column of cell - ** - row: table row of cell - ** - once EventListeners onCellMouseDown() { EventListeners() } - - ** Scroll to bottom of table content. - native This scrollToBottom() - - ** The number of pixels that the content of the table is scrolled upward. - @NoDoc native Int scrollTop -} diff --git a/src/webfwt/fan/WebTableModel.fan b/src/webfwt/fan/WebTableModel.fan deleted file mode 100644 index 037149732..000000000 --- a/src/webfwt/fan/WebTableModel.fan +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Apr 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebTableModel extends TableModel with additional functionality. -** -@NoDoc -@Js -abstract class WebTableModel : TableModel -{ - ** Image alignment relative to text. - virtual Halign halignImage(Int c) { Halign.left } - - ** Optional image to display when row is selected. - virtual Image? imageSel(Int col, Int row) { null } - - ** Get the Uri used for this cell. Returning a Uri converts - ** cell content to a hyperlink. - virtual Uri? uri(Int col, Int row) { null } - - ** Get the for the Uri used for this cell, or 'null' - ** for the default behavoir. - virtual Str? uriTarget(Int col, Int row) { null } - - ** Callback when mouse is pressed down on a cell. - @Deprecated { msg="Use WebTableModel.onCellMouseDown" } - virtual Void onMouseDown(Event event, Int col, Int row) {} -} - - diff --git a/src/webfwt/fan/WebText.fan b/src/webfwt/fan/WebText.fan deleted file mode 100644 index 58d376539..000000000 --- a/src/webfwt/fan/WebText.fan +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 23 Sep 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** WebText extends Text with additional functionality. -** -@Js -class WebText : Text -{ - ** Constructor. - new make(|This|? f := null) : super(f) {} - - ** Placeholder text to display in text field if empty. - Str? placeHolder := null - - ** Placeholder text color, or null for default. - Color? placeHolderColor := null - - ** Insets between text and border, or null for default. - Insets? insets := null - - ** Border for text field, or null for default. - Border? textBorder := null - - ** Inner shadow, or null for none. - Shadow? innerShadow := null - - ** Drop shadow, or null for none. - Shadow? dropShadow := null - - ** Image to display inside widget, or null for none. - Image? image := null - - ** Halign of image. Supoported values: 'left' and 'right'. - Halign halignImage := Halign.right - - ** Override style. Defaults to null. - [Str:Str]? style := null - - ** Override disabled style. Defaults to null. - [Str:Str]? disabledStyle := null - - override Size prefSize(Hints hints := Hints.defVal) - { - pref := super.prefSize(hints) - w := pref.w - h := pref.h - - if (dropShadow != null) - h += dropShadow.offset.y + dropShadow.blur + dropShadow.spread - - return Size(w,h) - } - - // force peer - private native Void dummy() -} - diff --git a/src/webfwt/fan/hud/HudButton.fan b/src/webfwt/fan/hud/HudButton.fan deleted file mode 100644 index 27bd2c717..000000000 --- a/src/webfwt/fan/hud/HudButton.fan +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 23 Mar 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudButton. -** -@NoDoc -@Js -class HudButton : MiniButton -{ - ** - ** Constructor - ** - new make(|This|? f := null) : super(f) {} - - // force peer - private native Void dummy() - -} - diff --git a/src/webfwt/fan/hud/HudButtonGroup.fan b/src/webfwt/fan/hud/HudButtonGroup.fan deleted file mode 100644 index 2e9f1a273..000000000 --- a/src/webfwt/fan/hud/HudButtonGroup.fan +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 21 Jul 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudButtonGroup. -** -@NoDoc -@Js -class HudButtonGroup : ButtonGroup -{ - new make(Str[] text) : super(text) {} - - protected override Str borderOuter() { "#555" } - protected override Str borderInner() { "#131313" } - - protected override Color fgNorm() { Color.white } - - protected override Gradient bgNorm() { brushBgNorm } - protected override Gradient bgDown() { brushBgDown } - - private static const Gradient brushBgNorm := Gradient("0% 0%, 0% 100%, #454545, #3b3b3b 0.5, #313131 0.5") - private static const Gradient brushBgDown := Gradient("0% 0%, 0% 100%, #121212, #2e2e2e") -} - diff --git a/src/webfwt/fan/hud/HudCheckbox.fan b/src/webfwt/fan/hud/HudCheckbox.fan deleted file mode 100644 index 9e79ddc15..000000000 --- a/src/webfwt/fan/hud/HudCheckbox.fan +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Jan 2012 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudCheckbox. -** -@NoDoc -@Js -class HudCheckbox : WebLabel -{ - ** Constructor - new make(|This|? f := null) - { - fg = Color("#fff") - if (f != null) f(this) - onMouseUp.add |e| - { - selected = !selected - update - onAction.fire(Event { id=EventId.action; widget=this; data=selected }) - } - update - } - - ** Selection state for checbox. - Bool selected := false - { - set { &selected=it; update } - } - - ** Callback for selection changes. - once EventListeners onAction() { EventListeners() } - - ** Update selection state. - private Void update() - { - image = selected ? imgOn : imgOff - relayout - } - - private static const Image imgOff := Image(`fan://webfwt/res/img/hud-checkbox-off.png`) - private static const Image imgOn := Image(`fan://webfwt/res/img/hud-checkbox-on.png`) -} - diff --git a/src/webfwt/fan/hud/HudCombo.fan b/src/webfwt/fan/hud/HudCombo.fan deleted file mode 100644 index d114bb9fa..000000000 --- a/src/webfwt/fan/hud/HudCombo.fan +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 17 Jun 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudCombo. -** -@NoDoc -@Js -class HudCombo : WebCombo -{ - ** It-block constructor. - new make(|This|? f := null) : super(f) {} - - // force peer - private native Void dummy() -} diff --git a/src/webfwt/fan/hud/HudList.fan b/src/webfwt/fan/hud/HudList.fan deleted file mode 100644 index 3d32cb25a..000000000 --- a/src/webfwt/fan/hud/HudList.fan +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 23 Mar 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudList. -** -@NoDoc -@Js -class HudList : TreeList -{ - // force peer - private native Void dummy() -} - diff --git a/src/webfwt/fan/hud/HudMenu.fan b/src/webfwt/fan/hud/HudMenu.fan deleted file mode 100644 index 789403fe8..000000000 --- a/src/webfwt/fan/hud/HudMenu.fan +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 3 Mar 2011 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudMenu displays a menu in a HudPopup. -** -@Js -class HudMenu : HudPopup -{ - - ** Constructor. - new make(|This|? f := null) : super(null) - { - f(this) - rows := RowPane { cols=[ColLayout { it.insets=Insets(2,12) }] } - rows.onMouseDown.add |e| - { - i := rows.rowAt(e.pos) - if (i == null) return - selected = items[i] - selectedIndex = i - rows.rowBg = [i:bgSelect] - rows.relayout - } - rows.onMouseUp.add |e| - { - if (selected == null) return - close - } - items.each |item,i| - { - rows.add(Label { - it.text = item.toStr - it.fg = Color.white - }) - } - insets = Insets(4,0) - body = rows - } - - ** Menu items. - Obj[] items - - ** Selected menu item, or null if menu was cancelled. - Obj? selected := null - - ** Selected menu item index, or null if menu was cancelled. - Int? selectedIndex := null - - ** selection bg color - private static const Color bgSelect := Color("#3d80df") -} - - diff --git a/src/webfwt/fan/hud/HudPopup.fan b/src/webfwt/fan/hud/HudPopup.fan deleted file mode 100644 index f775eb128..000000000 --- a/src/webfwt/fan/hud/HudPopup.fan +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 5 Oct 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** HudPopup displays a Popup in HUD style. -** -@Js -class HudPopup : Popup -{ - ** Constructor. - new make(|This|? f := null) - { - content = BorderPane - { - it.bg = Color("#f53b3b3b") - it.border = Border("#f5242424 $radius") - it.insets = this.insets - } - if (f != null) f(this) - } - - ** Insets around content. - Insets insets := Insets(12) - { - set { &insets=it; content->insets=it } - } - - ** Border radius for popup. - Insets radius := Insets(5) - { - set { &radius=it; content->border=Border("#f5242424 $it") } - } - - ** Content of popup. - Widget? body - { - get { content->content } - set { content->content = it } - } - -} \ No newline at end of file diff --git a/src/webfwt/fan/hud/HudScrollPane.fan b/src/webfwt/fan/hud/HudScrollPane.fan deleted file mode 100644 index 0139e3eb3..000000000 --- a/src/webfwt/fan/hud/HudScrollPane.fan +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 5 Oct 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudScrollPane customizes WebScrollPane for HUD style. -** -@NoDoc -@Js -class HudScrollPane : WebScrollPane -{ - // force native - private native Void dummy() -} \ No newline at end of file diff --git a/src/webfwt/fan/hud/HudText.fan b/src/webfwt/fan/hud/HudText.fan deleted file mode 100644 index 6e1f2db28..000000000 --- a/src/webfwt/fan/hud/HudText.fan +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 10 Feb 2012 Andy Frank Creation -// - -using fwt -using gfx - -** -** HudText. -** -@Js -class HudText : WebText -{ - ** Constructor. - new make(|This|? f := null) : super(f) {} - - // force peer - private native Void dummy() -} - diff --git a/src/webfwt/fan/internal/AbsPane.fan b/src/webfwt/fan/internal/AbsPane.fan deleted file mode 100644 index 313cca59b..000000000 --- a/src/webfwt/fan/internal/AbsPane.fan +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 12 Aug 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** AbsPane lays out widgets using absolute positioning. -** -@NoDoc -@Js -// TODO: leave as internal until needed -internal class AbsPane : Pane -{ - new make() {} - - override Size prefSize(Hints hints := Hints.defVal) - { - w := 0 - h := 0 - - children.each |kid| - { - w = w.max(kid.pos.x + kid.size.w) - h = h.max(kid.pos.y + kid.size.h) - } - - return Size(w,h) - } - - override Void onLayout() {} - -} - diff --git a/src/webfwt/fan/internal/AlphaPane.fan b/src/webfwt/fan/internal/AlphaPane.fan deleted file mode 100644 index 7120360c5..000000000 --- a/src/webfwt/fan/internal/AlphaPane.fan +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 20 Aug 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** AlphaPane applies an opacity to its content. -** -@NoDoc -@Js -// TODO: leave as internal until needed -internal class AlphaPane : ContentPane -{ - ** - ** Opacity value, where '0' is fully transparent, and '1.0' is fully opaque. - ** - Float opacity := 0.5f - - // force native peer - private native Void dummy() -} \ No newline at end of file diff --git a/src/webfwt/fan/internal/ButtonBar.fan b/src/webfwt/fan/internal/ButtonBar.fan deleted file mode 100644 index bf1d672f2..000000000 --- a/src/webfwt/fan/internal/ButtonBar.fan +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 29 Jun 10 Andy Frank Creation -// - -using gfx -using fwt - -** -** ButtonBar displays buttons flush against a background. -** -@NoDoc -@Js -// TODO: leave as internal until needed -internal class ButtonBar : ContentPane -{ - ** Construct new ButtonBar. - new make(|This|? f := null) - { - if (f != null) f(this) - } - - ** Add a button. - This addButton(Image image, |fwt::Event| onAction) - { - b := BorderPane - { - it.insets = Insets(2,4) - it.border = Border("0,1,0,0 #bebebe") - it.onMouseDown.add |e| { e.widget->bg=Color("#d5d5d5"); e.widget.relayout } - it.onMouseUp.add |e| { e.widget->bg=null; e.widget.relayout; onAction(e) } - Label { it.image=image }, - } - buttons.add(b) - return this - } - - ** Layout widget. - override Void onLayout() - { - // detach buttons - buttons.each |b| { b.parent?.remove(b) } - - // rebuild grid - grid := GridPane { hgap=0; numCols=buttons.size } - buttons.each |b| { grid.add(b) } - content = BorderPane - { - bg = Gradient("0% 0%, 0% 100%, #fbfbfb, #f4f4f4 0.5, #e5e5e5 0.5, #e6e6e6") - grid, - } - - // finish layout - super.onLayout - } - - private Widget[] buttons := Widget[,] - -} \ No newline at end of file diff --git a/src/webfwt/fan/internal/LayerPane.fan b/src/webfwt/fan/internal/LayerPane.fan deleted file mode 100644 index 71d070ae6..000000000 --- a/src/webfwt/fan/internal/LayerPane.fan +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 24 Sep 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** LayerPane lays out widgets to fit bounds of Pane, layering each -** child on top of the previous, in order of 'children'. -** -@NoDoc -@Js -// TODO: leave as internal until needed -internal class LayerPane : Pane -{ - new make() {} - - override Size prefSize(Hints hints := Hints.defVal) - { - w := 0 - h := 0 - - children.each |kid| - { - w = w.max(kid.size.w) - h = h.max(kid.size.h) - } - - return Size(w,h) - } - - override Void onLayout() - { - children.each |kid| - { - kid.bounds = Rect(0, 0, size.w, size.h) - } - } - -} - diff --git a/src/webfwt/fan/internal/ToggleButton.fan b/src/webfwt/fan/internal/ToggleButton.fan deleted file mode 100644 index 7396a171b..000000000 --- a/src/webfwt/fan/internal/ToggleButton.fan +++ /dev/null @@ -1,98 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 23 Aug 10 Andy Frank Creation -// - -using fwt -using gfx - -** -** ToggleButton. -** -@NoDoc -@Js -// TODO: leave as internal until needed -class ToggleButton : ContentPane -{ - -////////////////////////////////////////////////////////////////////////// -// Construction -////////////////////////////////////////////////////////////////////////// - - ** Create new button group with text for buttons. - new make(Str text) - { - content = BorderPane - { - border = Border("0,0,1,0 $borderOuter 0,0,5,5") - it.onMouseUp.add - { - selected = !selected - onSelect.fire( Event { id=EventId.select }) - } - BorderPane - { - border = Border("$borderInner 5") - Label { it.text=text; fg=fgNorm; font=Desktop.sysFontSmall; halign=Halign.center }, - }, - } - select(selected) - } - -////////////////////////////////////////////////////////////////////////// -// Events -////////////////////////////////////////////////////////////////////////// - - ** Currently selected tab index. - Bool selected := false - { - set { &selected=it; select(it) } - } - - ** Select the tab at the given index. - private Void select(Bool sel) - { - inner := (BorderPane)content->content - inner.bg = sel ? bgDown : bgNorm - inner.insets = sel ? Insets(5,12,3,12) : Insets(4,12) - inner.content->fg = sel ? fgDown : fgNorm - relayout - } - - ** EventListeners for select event. - EventListeners onSelect := EventListeners() - -////////////////////////////////////////////////////////////////////////// -// Customize -////////////////////////////////////////////////////////////////////////// - - ** Outer Border color. - protected virtual Str borderOuter() { "#e0e0e0" } - - ** Outer Border color. - protected virtual Str borderInner() { "#404040" } - - ** Background when normal. - protected virtual Gradient bgNorm() { brushBgNorm } - - ** Background when pressed. - protected virtual Gradient bgDown() { brushBgDown } - - ** Foreground when normal. - protected virtual Color fgNorm() { Color.black } - - ** Foreground when pressed. - protected virtual Color fgDown() { Color.white } - -////////////////////////////////////////////////////////////////////////// -// Fields -////////////////////////////////////////////////////////////////////////// - - private static const Gradient brushBgNorm := Gradient("0% 0%, 0% 100%, #fefefe, #cbcbcb") - private static const Gradient brushBgDown := Gradient("0% 0%, 0% 100%, #1b54a5, #3d80df") - -} - diff --git a/src/webfwt/js/ActivityPanePeer.js b/src/webfwt/js/ActivityPanePeer.js deleted file mode 100644 index 27e2e8fea..000000000 --- a/src/webfwt/js/ActivityPanePeer.js +++ /dev/null @@ -1,148 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 21 May 10 Andy Frank Creation -// - -/** - * ActivityPanePeer. - */ -fan.webfwt.ActivityPanePeer = fan.sys.Obj.$extend(fan.sys.Obj); -fan.webfwt.ActivityPanePeer.prototype.$ctor = function(self) -{ - this.$working = false; -} -// disable open/close animation -fan.webfwt.ActivityPanePeer.m_useAnim = true; - -// dislabe for Chrome/Win -if (fan.fwt.DesktopPeer.$isChrome && fan.fwt.DesktopPeer.isWindows()) - fan.webfwt.ActivityPanePeer.m_useAnim = false; - -// CSS -fan.fwt.WidgetPeer.addCss( - "div._webfwt_ActivityPane_mask_ {" + - " position: absolute;" + - " top:0; left:0; width:100%; height:100%;" + - " background: #000;" + - " opacity: 0.25;" + - " z-index: 1000;" + - "}" + - "div._webfwt_ActivityPane_shell_ {" + - " position: absolute;" + - " top:0; left:0; width:100%; height:100%;" + - " z-index: 1001;" + - "}" + - "div._webfwt_ActivityPane_content_ {" + - " position: absolute;" + - " background: #3b3b3b;" + - " color: #fff;" + - " font: bold " + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.$sysFont) + ";" + - " padding: 12px;" + - " border-radius: 5px;" + - "}" + - "div._webfwt_ActivityPane_content_.opening {" + - " opacity: 0.0;" + - " -webkit-transform: scale(0.75);" + - " -moz-transform: scale(0.75);" + - "}" + - "div._webfwt_ActivityPane_content_.open {" + - " opacity: 1.0;" + - " -webkit-transition: -webkit-transform 100ms, opacity 100ms;" + - " -moz-transition: -moz-transform 100ms, opacity 100ms;" + - " -webkit-transform: scale(1.0);" + - " -moz-transform: scale(1.0);" + - "}"); - -fan.webfwt.ActivityPanePeer.$find = null; -fan.webfwt.ActivityPanePeer.find = function() -{ - return fan.webfwt.ActivityPanePeer.$find; -} - -fan.webfwt.ActivityPanePeer.prototype.working = function(self) -{ - return this.$working; -} - -fan.webfwt.ActivityPanePeer.prototype.open = function(self, parent) -{ - this.$parent = parent; - this.$working = true; - - // mount mask that functions as input blocker for modality - var mask = document.createElement("div"); - mask.className = "_webfwt_ActivityPane_mask_"; - - // shell we use to attach widgets to - var shell = document.createElement("div"); - shell.className = "_webfwt_ActivityPane_shell_"; - - // mount content - var content = document.createElement("div"); - content.className = fan.webfwt.ActivityPanePeer.m_useAnim - ? "_webfwt_ActivityPane_content_ opening" - : "_webfwt_ActivityPane_content_"; - if (self.m_image != null) - { - var img = document.createElement("img"); - img.src = fan.fwt.WidgetPeer.uriToImageSrc(self.m_image.m_uri); - img.style.verticalAlign = "middle"; - img.style.paddingRight = "6px"; - content.appendChild(img); - } - content.appendChild(document.createTextNode(self.msg())); - - // add to DOM - shell.appendChild(content); - parent.peer.elem.appendChild(mask); - parent.peer.elem.appendChild(shell); - - // cache elements so we can remove when we close - this.$mask = mask; - this.$shell = shell; - this.$open = true; - - // center content - var sw = shell.offsetWidth; - var sh = shell.offsetHeight; - var cw = content.offsetWidth; - var ch = content.offsetHeight; - content.style.left = ((sw-cw)/2) + "px"; - content.style.top = ((sh-ch)/2) + "px"; - - // animate open - if (fan.webfwt.ActivityPanePeer.m_useAnim) - content.className = "_webfwt_ActivityPane_content_ open"; - - // set find instance - fan.webfwt.ActivityPanePeer.$find = self; - return self; -} - -fan.webfwt.ActivityPanePeer.prototype.close = function(self) -{ - if (!this.$open) return; - - // remove find instance - fan.webfwt.ActivityPanePeer.$find = null; - - // animate close - if (this.$shell && fan.webfwt.ActivityPanePeer.m_useAnim) - { - var content = this.$shell.firstChild; - content.className = "_webfwt_ActivityPane_content_ opening"; - } - - // allow animation to complete - var $this = this; - setTimeout(function() { - $this.$working = false; - if ($this.$shell && $this.$shell.parentNode) $this.$shell.parentNode.removeChild($this.$shell); - if ($this.$mask && $this.$mask.parentNode) $this.$mask.parentNode.removeChild($this.$mask); - $this.$open = false; - }, 100); -} - diff --git a/src/webfwt/js/AlphaPanePeer.js b/src/webfwt/js/AlphaPanePeer.js deleted file mode 100644 index 818eefa1e..000000000 --- a/src/webfwt/js/AlphaPanePeer.js +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 20 Aug 10 Andy Frank Creation -// - -/** - * AlphaPanePeer. - */ -fan.webfwt.AlphaPanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.AlphaPanePeer.prototype.$ctor = function(self) {} - -fan.webfwt.AlphaPanePeer.prototype.create = function(parentElem, self) -{ - var div = this.emptyDiv(); - div.style.opacity = self.m_opacity; - parentElem.appendChild(div); - return div; -} - diff --git a/src/webfwt/js/ColUtilPeer.js b/src/webfwt/js/ColUtilPeer.js deleted file mode 100644 index 566891b0f..000000000 --- a/src/webfwt/js/ColUtilPeer.js +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright (c) 2014, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// - -/** - * ColUtil - */ -fan.webfwt.ColUtilPeer = fan.sys.Obj.$extend(fan.sys.Obj); -fan.webfwt.ColUtilPeer.prototype.$ctor = function(self) {} - -fan.webfwt.ColUtilPeer.writePng = function(table, out, col, row) -{ - var w = table.m_colw.get(col); - var h = table.m_rowb.get(row).m_h; - - // add temp canvas - var canvas = document.createElement("canvas"); - canvas.width = w; - canvas.height = h; - canvas.style.display = "none"; - document.body.appendChild(canvas); - - // render cell - var g = new fan.fwt.FwtGraphics(); - var s = fan.gfx.Size.make(w, h); - var b = fan.gfx.Rect.make(0, 0, w, h); - g.widget = table; - g.paint(canvas, b, function() { table.paintCell(g, col, row, false, s) }); - - // encode to PNG - out.w(""); - - // remove canvas - document.body.removeChild(canvas); -} diff --git a/src/webfwt/js/ColWebListPeer.js b/src/webfwt/js/ColWebListPeer.js deleted file mode 100644 index 13a8a4f1f..000000000 --- a/src/webfwt/js/ColWebListPeer.js +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 20 Jun 2011 Andy Frank Move Fantom implementation to JavaScript -// - -/** - * ColWebListPeer. - */ -fan.webfwt.ColWebListPeer = fan.sys.Obj.$extend(fan.webfwt.WebListPeer); -fan.webfwt.ColWebListPeer.prototype.$ctor = function(self) -{ - // 16 Mar 2012 - WebKit has some weird bug where focusing this - // element shifts our offset -1px - overrriding focus to be a - // noop seems to fix the issue - self.focus = function() {} -} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_ColWebList_ {" + - " background:#fff;" + - "}" + - "div._webfwt_ColWebList_ > div { "+ - " position:relative;" + - " font:" + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.sysFontView()) + ";" + - " padding:3px 4px;" + - " overflow:hidden;" + - " white-space:nowrap;" + - " text-overflow:ellipsis;" + - "}" + - "div._webfwt_ColWebList_ > div > div { "+ - " overflow:hidden;" + - "}" + - "div._webfwt_ColWebList_ > div > span { "+ - " float:right;" + - " padding-top:2px;" + - " padding-left:4px;" + - " color:#999;" + - " font:" + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.sysFont().toSize(10)) + ";" + - "}" + - "div._webfwt_ColWebList_ > div.selected { "+ - " background:#3d80df;" + - " color:#fff;" + - "}" + - "div._webfwt_ColWebList_ > div.selected span { "+ - " color:#fff;" + - "}"); - -// IE seems to have trouble doing text-overflow properly -if (!fan.fwt.DesktopPeer.$isIE) - fan.fwt.WidgetPeer.addCss( - "div._webfwt_ColWebList_ > div > div { text-overflow:ellipsis; }"); - -fan.webfwt.ColWebListPeer.prototype.setupContainer = function(self, elem) -{ - // add css class - elem.className = "_webfwt_WebScrollPane_ _webfwt_WebList_ _webfwt_ColWebList_"; -} - -fan.webfwt.ColWebListPeer.prototype.repaintSelection = function(self, ix, selected) -{ - for (var i=0; i 0) - { - // TODO FIXIT - this code works with the V3 API - // - Would be nice to fitBounds *before* creating map - - var bounds = null; - var clat = this.m_center.get(0).valueOf(); - var clng = this.m_center.get(1).valueOf(); - var options = - { - center: new google.maps.LatLng(clat, clng), - zoom: this.m_zoom, - mapTypeId: this.getMapType(self) - }; - - // center on bounding box of all markers - if (self.m_fitBounds && (this.markers.length > 0 || this.routes.length > 0)) - { - // center on bounding box of all markers - bounds = new google.maps.LatLngBounds( - new google.maps.LatLng(this.minLat, this.minLng), - new google.maps.LatLng(this.maxLat, this.maxLng)); - options.center = bounds.getCenter(); - } - - // create map - this.map = new google.maps.Map(this.elem, options); - - // create info window - this.infoWindow = new google.maps.InfoWindow({ content: "InfoWindow" }); - - // assign markers - for (var i=0; i 15 && this.initialZoom == true) - { - this.setZoom(15); - this.initialZoom = false; - } - }); - this.map.initialZoom = true; - this.map.fitBounds(bounds); - } - } - // } - // catch (err) - // { - // console.trace(err); - // this.elem.innerHTML = "Could not load map"; - // this.elem.style.padding = "12px"; - // fan.fwt.WidgetPeer.prototype.sync.call(this, self); - // return; - // } -} - -fan.webfwt.GMapPeer.prototype.onMarkerClick = function(marker, infoHtml) -{ - var t = this; - return function() { - t.infoWindow.content = infoHtml; - t.infoWindow.open(t.map, marker); - } -} - -fan.webfwt.GMapPeer.prototype.getMapType = function(self) -{ - var v = self.m_mapType; - if (v == fan.webfwt.MapType.m_roadMap) return google.maps.MapTypeId.ROADMAP; - if (v == fan.webfwt.MapType.m_satellite) return google.maps.MapTypeId.SATELLITE; - if (v == fan.webfwt.MapType.m_hybrid) return google.maps.MapTypeId.HYBRID; - if (v == fan.webfwt.MapType.m_terrain) return google.maps.MapTypeId.TERRAIN; - return google.maps.MapTypeId.ROADMAP; -} - -fan.webfwt.GMapPeer.prototype.loadScript = function(self) -{ - if (fan.webfwt.GMapPeer.scriptLoading) return; - fan.webfwt.GMapPeer.scriptLoading = true; - - fanFrescoGMapPeerOnLoad = function() - { - fan.webfwt.GMapPeer.scriptLoaded = true; - var win = self.window(); - if (win != null) win.relayout(); - } - - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=fanFrescoGMapPeerOnLoad"; - document.body.appendChild(script); -} - -var fanFrescoGMapPeerOnLoad = null; -fan.webfwt.GMapPeer.scriptLoading = false; -fan.webfwt.GMapPeer.scriptLoaded = false; - -fan.webfwt.GMapPeer.prototype.markers = null; // set in ctor -fan.webfwt.GMapPeer.prototype.routes = null; // set in ctor - -fan.webfwt.GMapPeer.prototype.minLat = null; // set in updateBounds -fan.webfwt.GMapPeer.prototype.minLng = null; -fan.webfwt.GMapPeer.prototype.maxLat = null; -fan.webfwt.GMapPeer.prototype.maxLng = null; - diff --git a/src/webfwt/js/HtmlPanePeer.js b/src/webfwt/js/HtmlPanePeer.js deleted file mode 100644 index 23e038d08..000000000 --- a/src/webfwt/js/HtmlPanePeer.js +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 11 Dec 09 Andy Frank Creation -// - -fan.webfwt.HtmlPanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.HtmlPanePeer.prototype.$ctor = function(self) -{ - fan.fwt.PanePeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.HtmlPanePeer.prototype.m_html = "" -fan.webfwt.HtmlPanePeer.prototype.html = function(self) { return this.m_html; } -fan.webfwt.HtmlPanePeer.prototype.html$ = function(self, val) -{ - this.m_html = val; - this.needRebuild = true; -} - -fan.webfwt.HtmlPanePeer.prototype.create = function(parentElem, self) -{ - var fixw = self.m_width > 0; - var html = document.createElement("div"); - if (fixw) html.style.width = self.m_width + "px"; - - if (self.m_font != null) html.style.font = fan.fwt.WidgetPeer.fontToCss(self.m_font); - if (self.m_fg != null) html.style.color = self.m_fg.toCss(); - - var div = this.emptyDiv(); - div.style.font = fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.$sysFont); - if (!fixw) div.style.overflow = "auto"; - div.appendChild(html); - parentElem.appendChild(div); - return div; -} - -fan.webfwt.HtmlPanePeer.prototype.needRebuild = true; -fan.webfwt.HtmlPanePeer.prototype.rebuild = function(self) -{ - this.needRebuild = true; - self.relayout(); -} - -fan.webfwt.HtmlPanePeer.prototype.sync = function(self) -{ - if (this.needRebuild) - { - this.elem.firstChild.innerHTML = this.m_html; - this.needRebuild = false; - } - fan.fwt.WidgetPeer.prototype.sync.call(this, self); -} - -fan.webfwt.HtmlPanePeer.prototype.prefSize = function(self, hints) -{ - return fan.fwt.WidgetPeer.prototype.prefSize.call(this, self, hints); -} \ No newline at end of file diff --git a/src/webfwt/js/HudButtonPeer.js b/src/webfwt/js/HudButtonPeer.js deleted file mode 100644 index 1535a5d0c..000000000 --- a/src/webfwt/js/HudButtonPeer.js +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 23 Mar 10 Andy Frank Creation -// - -/** - * HudButtonPeer. - */ -fan.webfwt.HudButtonPeer = fan.sys.Obj.$extend(fan.webfwt.MiniButtonPeer); -fan.webfwt.HudButtonPeer.prototype.$ctor = function(self) -{ - fan.webfwt.MiniButtonPeer.prototype.$ctor.call(this, self); - - // overrides - this.m_textColor = "#fff"; - this.m_border = "1px solid #131313"; - this.m_shadowBg = "#555"; - this.m_bgStart = "#5b5b5b"; - this.m_bgEnd = "#393939"; - this.m_bgPressStart = "#333"; - this.m_bgPressEnd = "#484848"; - this.m_padding = "3px 11px"; - this.m_paddingPress = "4px 11px 2px 11px"; - this.m_borderRadius = "11px"; - this.m_widthOff = 24; -} - diff --git a/src/webfwt/js/HudComboPeer.js b/src/webfwt/js/HudComboPeer.js deleted file mode 100644 index 4b0fecdbc..000000000 --- a/src/webfwt/js/HudComboPeer.js +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 17 Jun 2011 Andy Frank Creation -// - -/** - * HudComboPeer. - */ -fan.webfwt.HudComboPeer = fan.sys.Obj.$extend(fan.webfwt.WebComboPeer); -fan.webfwt.HudComboPeer.prototype.$ctor = function(self) {} - -// CSS - Firefox has trouble renderering content -if (!fan.fwt.DesktopPeer.$isFirefox) -{ - fan.webfwt.HudComboPeer.$bg = "url(" + - fan.fwt.WidgetPeer.uriToImageSrc(fan.sys.Uri.fromStr("fan://webfwt/res/img/hud-combo-arrows.png")) - + ") no-repeat right center"; - fan.fwt.WidgetPeer.addCss( - "select._webfwt_HudCombo_ {" + - " color:#fff;" + - " -webkit-appearance:none;" + - " border:1px solid #131313;" + - " background:" + fan.webfwt.HudComboPeer.$bg + ",-webkit-linear-gradient(top, #5b5b5b, #393939);" + - " background:" + fan.webfwt.HudComboPeer.$bg + ",linear-gradient(top, #5b5b5b #393939);" + - " -webkit-box-shadow:0 1px 1px #555;" + - " box-shadow: 0 1px 1px #555;" + - "}" + - "select._webfwt_HudCombo_ option {" + - " color:#000;" + - "}"); -} - -fan.webfwt.HudComboPeer.prototype.create = function(parentElem, self) -{ - var elem = fan.fwt.ComboPeer.prototype.create.call(this, parentElem, self); - var select = elem.firstChild; - select.className = "_fwt_Combo_ _webfwt_HudCombo_"; - return elem; -} - diff --git a/src/webfwt/js/HudListPeer.js b/src/webfwt/js/HudListPeer.js deleted file mode 100644 index 47eb888f2..000000000 --- a/src/webfwt/js/HudListPeer.js +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Jun 2011 Andy Frank Creation -// - -/** - * HudListPeer. - */ -fan.webfwt.HudListPeer = fan.sys.Obj.$extend(fan.webfwt.TreeListPeer); -fan.webfwt.HudListPeer.prototype.$ctor = function(self) {} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_HudList_ { "+ - " background:none;" + - "}" + - "div._webfwt_HudList_ > div { "+ - " color:#fff;" + - " border-bottom:none;" + - "}" + - "div._webfwt_HudList_ > div.group { "+ - " background:#505050;" + - " border:none;" + - " color:#ccc;" + - " text-shadow:#000 0 -1px;" + - "}" + - "div._webfwt_HudList_ > div.selected { background:#666; }" + - "div._webfwt_HudList_:focus > div.selected { " + - " background:#3d80df;" + - " background-image:-webkit-linear-gradient(top, #5a9ce6, #1d67bc);" + - " background-image:-moz-linear-gradient(top, #5a9ce6, #1d67bc);" + - " background-image:-ms-linear-gradient(top, #5a9ce6, #1d67bc);" + - " background-image:linear-gradient(top, #5a9ce6, #1d67bc);" + - "}" + - "div._webfwt_HudList_ > div > span.def { color:#666; }" + - "div._webfwt_HudList_ > div > span.pill { background:#666; }" + - "div._webfwt_HudList_ > div.selected > span.def { color:#fff; }" + - "div._webfwt_HudList_ > div.selected > span.pill { background:#154f92; }" + - "div._webfwt_HudList_:focus > div.selected > span.pill { background:#154f92; }" + - ""); - -fan.webfwt.HudListPeer.prototype.setupContainer = function(self, container) -{ - // add css class - fan.webfwt.TreeListPeer.prototype.setupContainer.call(this, self, container) - container.className = - "_webfwt_WebScrollPane_ _webfwt_WebList_ _webfwt_TreeList_" + - " _webfwt_HudScrollPane_ _webfwt_HudList_"; -} diff --git a/src/webfwt/js/HudScrollPanePeer.js b/src/webfwt/js/HudScrollPanePeer.js deleted file mode 100644 index dc1224137..000000000 --- a/src/webfwt/js/HudScrollPanePeer.js +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 29 Jun 2011 Andy Frank Creation -// - -/** - * HudScrollPanePeer. - */ -fan.webfwt.HudScrollPanePeer = fan.sys.Obj.$extend(fan.webfwt.WebScrollPanePeer); -fan.webfwt.HudScrollPanePeer.prototype.$ctor = function(self) {} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_HudScrollPane_ { "+ - " background:rgba(0,0,0,0.2);" + - " border:1px solid #222;" + - " -webkit-box-shadow:inset 0px 3px 3px #2c2c2c;" + - " -moz-box-shadow: inset 0px 3px 3px #2c2c2c;" + - " box-shadow: inset 0px 3px 3px #2c2c2c;" + - "}" + - "div._webfwt_HudScrollPane_::-webkit-scrollbar:vertical {" + - " border-left: 1px solid #222;" + - " background: -webkit-gradient(linear, left top, right top, from(#5b5b5b), to(#393939));" + - "}" + - "div._webfwt_HudScrollPane_::-webkit-scrollbar-track-piece:vertical {" + - " background: -webkit-gradient(linear, left top, right top, from(#252525), to(#333));" + - " border: 1px solid #282828;" + - "}" + - "div._webfwt_HudScrollPane_::-webkit-scrollbar-thumb {" + - " border: 1px solid #282828;" + - "}" + - "div._webfwt_HudScrollPane_::-webkit-scrollbar-thumb:vertical {" + - " background: -webkit-gradient(linear, left top, right top, from(#5b5b5b), to(#393939));" + - "}"); - -fan.webfwt.HudScrollPanePeer.prototype.create = function(parentElem, self) -{ - var elem = fan.webfwt.WebScrollPanePeer.prototype.create.call(this, parentElem, self); - elem.className += " _webfwt_HudScrollPane_"; - elem.style.background = "rgba(0,0,0,0.2)"; - return elem; -} \ No newline at end of file diff --git a/src/webfwt/js/HudTextPeer.js b/src/webfwt/js/HudTextPeer.js deleted file mode 100644 index 71162ac1a..000000000 --- a/src/webfwt/js/HudTextPeer.js +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 10 Feb 2012 Andy Frank Creation -// - -/** - * HudTextPeer. - */ -fan.webfwt.HudTextPeer = fan.sys.Obj.$extend(fan.webfwt.WebTextPeer); -fan.webfwt.HudTextPeer.prototype.$ctor = function(self) {} - -fan.fwt.WidgetPeer.addCss( - "._webfwt_HudText_ {" + - " color:#fff;" + - " border:1px solid #181818;" + - " background:#2c2c2c;" + - " -webkit-box-shadow: inset 0px 1px 2px #1c1c1c;" + - " -moz-box-shadow: inset 0px 1px 2px #1c1c1c;" + - " box-shadow: inset 0px 1px 2px #1c1c1c;" + - "}" + - "input._webfwt_HudText_::-webkit-input-placeholder { color: #777 }" + - "input._webfwt_HudText_:-moz-placeholder { color: #777 }" + - "input._webfwt_HudText_:-ms-input-placeholder { color: #777 }" - ); - -fan.webfwt.HudTextPeer.prototype.$cssClass = function(readonly) -{ - return readonly - ? "_fwt_Text_ _webfwt_HudText_ _fwt_Text_readonly_" - : "_fwt_Text_ _webfwt_HudText_"; -} \ No newline at end of file diff --git a/src/webfwt/js/HyperlinkPeer.js b/src/webfwt/js/HyperlinkPeer.js deleted file mode 100644 index a86e9cdeb..000000000 --- a/src/webfwt/js/HyperlinkPeer.js +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 3 Feb 10 Andy Frank Creation -// - -/** - * HyperlinkPeer. - */ -fan.webfwt.HyperlinkPeer = fan.sys.Obj.$extend(fan.webfwt.WebLabelPeer); -fan.webfwt.HyperlinkPeer.prototype.$ctor = function(self) -{ - fan.webfwt.WebLabelPeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.HyperlinkPeer.prototype.m_uri = fan.sys.Uri.m_defVal; -fan.webfwt.HyperlinkPeer.prototype.uri = function(self) { return this.m_uri; } -fan.webfwt.HyperlinkPeer.prototype.uri$ = function(self, val) -{ - this.m_rebuild = true; - this.m_uri = val; -} - -// backdoor hook to reuse Label for hyperlinks -fan.webfwt.HyperlinkPeer.prototype.$uri = function(self) -{ - return { - uri: this.m_uri.encode(), - target: self.m_target, - underline: self.m_underline.toStr() - }; -} - -// backdoor hook to reuse Label for hyperlinks -fan.webfwt.HyperlinkPeer.prototype.$onBeforeUri = function(self) -{ - var list = self.onBefore().list(); - if (list.size() == 0) return; - - var evt = fan.fwt.Event.make(); - evt.m_id = fan.fwt.EventId.m_action; - evt.m_widget = self; - for (var i=0; i vp.m_w-12) { x=6; w=vp.m_w-12; } - if (h > vp.m_h-12) { y=6; h=vp.m_h-12; } - if (x+w >= vp.m_w-6) x = vp.m_w-w-6; - if (y+h >= vp.m_h-6) y = vp.m_h-h-6; - if (x < 6) x = 6; - if (y < 6) y = 6; - - this.pos$(self, fan.gfx.Point.make(x, y)); - this.size$(self, fan.gfx.Size.make(w, h)); - fan.fwt.WidgetPeer.prototype.sync.call(this, self); -} - diff --git a/src/webfwt/js/PaleTreeListPeer.js b/src/webfwt/js/PaleTreeListPeer.js deleted file mode 100644 index 2bc9dafff..000000000 --- a/src/webfwt/js/PaleTreeListPeer.js +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Dec 2011 Andy Frank Creation -// - -/** - * PaleTreeListPeer. - */ -fan.webfwt.PaleTreeListPeer = fan.sys.Obj.$extend(fan.webfwt.TreeListPeer); -fan.webfwt.PaleTreeListPeer.prototype.$ctor = function(self) {} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_PaleTreeList_ { "+ - " background:#d4dbe3;" + - "}" + - "div._webfwt_PaleTreeList_ > div.group {" + - " color:#325373;" + - " background:#aec0d0;" + - " border-color:#9aacbc;" + - " text-shadow:#e2e8f0 0px 1px;" + - "}" + - ""); - -fan.webfwt.PaleTreeListPeer.prototype.setupContainer = function(self, container) -{ - // add css class - fan.webfwt.TreeListPeer.prototype.setupContainer.call(this, self, container) - container.className = - "_webfwt_WebScrollPane_ _webfwt_WebList_ _webfwt_TreeList_ _webfwt_PaleTreeList_"; -} diff --git a/src/webfwt/js/PopupPeer.js b/src/webfwt/js/PopupPeer.js deleted file mode 100644 index ddd6fefd5..000000000 --- a/src/webfwt/js/PopupPeer.js +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 20 Aug 09 Andy Frank Creation -// - -/** - * PopupPeer. - */ -fan.webfwt.PopupPeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.PopupPeer.prototype.$ctor = function(self) -{ - this.hasKeyBinding = false; -} - -// we want to get img.onload notifications -fan.webfwt.PopupPeer.prototype.notifyImgLoad = true; - -fan.webfwt.PopupPeer.prototype.move = function(self, point) -{ - this.$point = point; - this.sync(self); -} - -fan.webfwt.PopupPeer.prototype.open = function(self, parent, point) -{ - // fire onBeforeOpen event listener - var be = fan.fwt.Event.make(); - be.m_widget = self; - be.m_id = fan.fwt.EventId.m_open; - var list = self.onBeforeOpen().list(); - for (var i=0; i vp.m_w-12) { x=6; w=vp.m_w-12; } - if (h > vp.m_h-12) { y=6; h=vp.m_h-12; } - if (x+w >= vp.m_w-6) x = vp.m_w-w-6; - if (y+h >= vp.m_h-6) y = vp.m_h-h-6; - if (x < 6) x = 6; - if (y < 6) y = 6; - - this.pos$(self, fan.gfx.Point.make(x, y)); - this.size$(self, fan.gfx.Size.make(w, h)); - fan.fwt.WidgetPeer.prototype.sync.call(this, self); -} - diff --git a/src/webfwt/js/SheetPeer.js b/src/webfwt/js/SheetPeer.js deleted file mode 100644 index ee766c12e..000000000 --- a/src/webfwt/js/SheetPeer.js +++ /dev/null @@ -1,167 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 20 Aug 09 Andy Frank Creation -// - -/** - * SheetPeer. - */ -fan.webfwt.SheetPeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.SheetPeer.prototype.$ctor = function(self) -{ - this.hasKeyBinding = false; -} - -// we want to get img.onload notifications -fan.webfwt.SheetPeer.prototype.notifyImgLoad = true; - -fan.webfwt.SheetPeer.prototype.open = function(self, win) -{ - this.$window = win; - - // buildContent if not built - if (self.m_content == null) self.buildContent(); - - // mount mask that functions as input blocker for modality - var mask = document.createElement("div") - with (mask.style) - { - position = "fixed"; - top = "0"; - left = "0"; - width = "100%"; - height = "100%"; - background = "#fff"; - opacity = "0.01"; - filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=1);" - zIndex = 200; - } - - // mount shell we use to attach widgets to - var shell = document.createElement("div") - with (shell.style) - { - position = "fixed"; - top = "0"; - left = "0"; - width = "100%"; - height = "100%"; - zIndex = 201; - } - var $this = this; - - // mount sheet - var sheet = this.emptyDiv(); - with (sheet.style) - { - MozBoxShadow = "0 5px 12px #555"; - webkitBoxShadow = "0 5px 12px #555"; - boxShadow = "0 5px 12px #555"; - overflow = "hidden"; - } - - // attach key bindings - if (!this.hasKeyBinding) - { - this.hasKeyBinding = true; - self.onKeyDown().add(fan.sys.Func.make( - fan.sys.List.make(fan.sys.Param.$type, [new fan.sys.Param("it","fwt::Event",false)]), - fan.sys.Void.$type, - function(it) { - if (it.m_key === fan.fwt.Key.m_esc) { self.close(null); it.consume(); } - })); - } - - // attach to DOM - shell.appendChild(sheet); - this.attachTo(self, sheet); - document.body.appendChild(mask); - document.body.appendChild(shell); - self.relayout(); - - // cache elements so we can remove when we close - this.$mask = mask; - this.$shell = shell; - - // cache height so we can animate - var height = sheet.offsetHeight; - sheet.style.height = "0px"; - var dummy = sheet.offsetHeight; // force reflow - - // animate open - sheet.style.MozTransition = "height 250ms"; - sheet.style.webkitTransition = "height 250ms"; - sheet.style.height = height + "px"; - - // try to focus first form element - give DOM a few ms - // to layout content before we attempt to focus - setTimeout(function() { - var elem = fan.fwt.DialogPeer.findFormControl(sheet); - if (elem != null) elem.focus() - else self.focus() - }, 50); - - // attach resize animations - setTimeout(function() { - sheet.style.MozTransition = "left 250ms, width 250ms, height 250ms"; - sheet.style.webkitTransition = "left 250ms, width 250ms, height 250ms"; - }, 100); -} - -fan.webfwt.SheetPeer.prototype.close = function(self, result) -{ - // short-cirtuit if not already open - if (this.$shell.parentNode == null) return; - - var evt = fan.fwt.Event.make(); - evt.m_id = fan.fwt.EventId.m_close; - evt.m_widget = self; - evt.m_data = result; - var list = self.onClose().list(); - for (var i=0; i vp.m_w-12) { x=6; w=vp.m_w-12; } - if (h > vp.m_h-12) { y=6; h=vp.m_h-12; } - - this.pos$(self, fan.gfx.Point.make(x, y)); - this.size$(self, fan.gfx.Size.make(w, h)); - fan.fwt.WidgetPeer.prototype.sync.call(this, self); -} - diff --git a/src/webfwt/js/SlidePanePeer.js b/src/webfwt/js/SlidePanePeer.js deleted file mode 100644 index 2d4f51583..000000000 --- a/src/webfwt/js/SlidePanePeer.js +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 30 Sep 10 Andy Frank Creation -// - -fan.webfwt.SlidePanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.SlidePanePeer.prototype.$ctor = function(self) -{ - fan.fwt.PanePeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.SlidePanePeer.prototype.create = function(parentElem, self) -{ - var div = this.emptyDiv(); - var sub = this.emptyDiv(); - sub.style.webkitTransition = "left 200ms ease-in"; - sub.style.MozTransition = "left 200ms ease-in"; - div.appendChild(sub); - parentElem.appendChild(div); - return sub; -} - -fan.webfwt.SlidePanePeer.prototype.sync = function(self) -{ - var slide = this.elem; - var parent = slide.parentNode; - - var w = this.m_size.m_w; - var h = this.m_size.m_h; - - with (parent.style) - { - display = this.m_visible ? "block" : "none"; - left = this.m_pos.m_x + "px"; - top = this.m_pos.m_y + "px"; - width = w + "px"; - height = h + "px"; - } - - with (slide.style) - { - left = -(self.m_cur * w) + "px"; - top = "0px" - width = (self.children().size() * w) + "px"; - height = h + "px"; - } -} - - diff --git a/src/webfwt/js/StyledButtonPeer.js b/src/webfwt/js/StyledButtonPeer.js deleted file mode 100644 index 06f7b6fc0..000000000 --- a/src/webfwt/js/StyledButtonPeer.js +++ /dev/null @@ -1,150 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 12 Jul 2011 Andy Frank Creation -// - -/** - * StyledButtonPeer. - */ -fan.webfwt.StyledButtonPeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.StyledButtonPeer.prototype.$ctor = function(self) -{ - fan.fwt.PanePeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.StyledButtonPeer.prototype.create = function(parentElem, self) -{ - var button = this.emptyDiv(); - this.m_pressed = false; - this.updateState(self, button); - fan.fwt.WidgetPeer.setBorder(button, self.m_border); - if (self.m_toolTip != null) button.title = self.m_toolTip; - - var $this = this; - button.onmousedown = function(event) - { - if (!self.enabled()) return false; - $this.m_pressed = true; - $this.updateState(self, button, true); - return false; - } - - button.onmouseout = function(event) - { - if (!self.enabled()) return; - if (!$this.m_pressed) return; - $this.m_pressed = false; - $this.updateState(self, button, true); - } - - button.onmouseup = function(event) - { - if (!self.enabled()) return; - if (!$this.m_pressed) return; - $this.m_pressed = false; - if (self.m_mode == fan.fwt.ButtonMode.m_toggle) - self.m_selected = !self.m_selected; - $this.updateState(self, button, true); - self.fireAction(); - } - - parentElem.appendChild(button); - return button; -} - -fan.webfwt.StyledButtonPeer.prototype.updateState = function(self, button, notify) -{ - if (button === undefined) button = this.elem; - if (notify === undefined) notify = false; - if (button == null) return; - - if (this.m_pressed || self.m_selected) - { - // notify pressed event - if (notify) - { - var e = fan.fwt.Event.make(); - e.m_id = fan.fwt.EventId.m_mouseDown; - e.m_widget = self; - self.onPressed().fire(e); - } - - // TODO FIXIT: offset doesn't get picked up - // on first paint - peer not yet exist - so - // need to handle inside sync() - fan.fwt.WidgetPeer.setBg(button, self.m_bgPressed); - this.setShadow(button, self); - this.offsetContent(self, 0, 1) - } - else - { - // notify released event - if (notify) - { - var e = fan.fwt.Event.make(); - e.m_id = fan.fwt.EventId.m_mouseUp; - e.m_widget = self; - self.onReleased().fire(e); - } - - // update state - fan.fwt.WidgetPeer.setBg(button, self.m_bg); - this.setShadow(button, self); - this.offsetContent(self, 0, 0) - } -} - -fan.webfwt.StyledButtonPeer.prototype.setShadow = function(button, self) -{ - var shadow = ""; - if (self.m_dropShadow != null) - shadow += self.m_dropShadow.toCss(); - - if (this.m_pressed || self.m_selected) - { - if (self.m_innerShadowPressed != null) - { - if (shadow.length > 0) shadow += ","; - shadow += "inset " + self.m_innerShadowPressed.toCss(); - } - } - else - { - if (self.m_innerShadow != null) - { - if (shadow.length > 0) shadow += ","; - shadow += "inset " + self.m_innerShadow.toCss(); - } - } - - button.style.webkitBoxShadow = shadow; - button.style.MozBoxShadow = shadow; - button.style.boxShadow = shadow; -} - -fan.webfwt.StyledButtonPeer.prototype.offsetContent = function(self, dx, dy) -{ - var c = self.m_content; - if (c != null && c.peer.elem != null) - { - if (this.m_origPos == null) this.m_origPos = c.peer.m_pos; - var p = this.m_origPos; - c.peer.m_pos = fan.gfx.Point.make(p.m_x+dx, p.m_y+dy); - c.peer.sync(c); - } -} - -fan.webfwt.StyledButtonPeer.prototype.sync = function(self) -{ - // sync size - var b = self.m_border; - var d = self.m_dropShadow; - var w = this.m_size.m_w - (b == null ? 0 : b.m_widthLeft + b.m_widthRight); - var h = this.m_size.m_h - (b == null ? 0 : b.m_widthTop + b.m_widthBottom); - if (d != null) h -= d.m_offset.m_y + d.m_blur + d.m_spread; - this.elem.style.opacity = this.m_enabled ? "1.0" : "0.35"; - fan.fwt.WidgetPeer.prototype.sync.call(this, self, w, h); -} diff --git a/src/webfwt/js/TextPanePeer.js b/src/webfwt/js/TextPanePeer.js deleted file mode 100644 index 5d53cf903..000000000 --- a/src/webfwt/js/TextPanePeer.js +++ /dev/null @@ -1,129 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 15 Oct 2010 Andy Frank Creation -// - -////////////////////////////////////////////////////////////////////////// -// TextPanePeer -////////////////////////////////////////////////////////////////////////// - -fan.webfwt.TextPanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.TextPanePeer.prototype.$ctor = function(self) -{ - fan.fwt.PanePeer.prototype.$ctor.call(this, self); - this.needsRebuild = true; -} - -fan.webfwt.TextPanePeer.prototype.m_text = ""; -fan.webfwt.TextPanePeer.prototype.text = function(self) { return this.m_text; } -fan.webfwt.TextPanePeer.prototype.text$ = function(self,val) -{ - this.needsRebuild = true; - this.m_text = val; -} - -fan.webfwt.TextPanePeer.prototype.create = function(parentElem, self) -{ - var div = this.emptyDiv(); - with (div.style) - { - background = "white"; - border = "1px solid #9f9f9f"; - overflow = "auto"; - } - var pre = document.createElement("pre"); - with (pre.style) - { - font = fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.$sysFontMonospace); - margin = "0px"; - padding = "6px"; - } - div.appendChild(pre); - parentElem.appendChild(div); - return div; -} - -fan.webfwt.TextPanePeer.prototype.prefSize = function(self, hints) -{ - return fan.fwt.WidgetPeer.prototype.prefSize.call(this, self, hints); -} - -fan.webfwt.TextPanePeer.prototype.sync = function(self) -{ - // sync text - if (this.needsRebuild) - { - var pre = this.elem.firstChild; - while (pre.firstChild) pre.removeChild(pre.firstChild); - pre.appendChild(document.createTextNode(this.m_text)); - this.needsRebuild = false; - this.elem.scrollTop = 0; - this.elem.scrollLeft = 0; - } - - // account for border - var w = this.m_size.m_w - 2; - var h = this.m_size.m_h - 2; - fan.fwt.WidgetPeer.prototype.sync.call(this, self, w, h); -} - -fan.webfwt.TextPanePeer.prototype.scrollToTop = function(self, dur) -{ - if (this.elem == null) return; - - var div = this.elem; - var ms = dur.toMillis(); - - if (div.offsetHeight > div.scrollHeight) return self; - if (ms < 10) { div.scrollTop=0; return self } - - var diff = div.scrollTop; - var dt = ms / 10; - var dy = Math.floor(diff / dt); - - var f = function() - { - if (div.scrollTop <= dy) div.scrollTop = 0; - else { div.scrollTop -= dy; setTimeout(f, 10); } - } - f(); - - return self; -} - -fan.webfwt.TextPanePeer.prototype.scrollToBottom = function(self, dur) -{ - if (this.elem == null) return; - - var div = this.elem; - var ms = dur.toMillis(); - - if (div.offsetHeight > div.scrollHeight) return self; - if (ms < 10) { div.scrollTop=div.scrollHeight; return self; } - - var diff = div.scrollHeight - div.scrollTop; - var dt = ms / 10; - var dy = Math.floor(diff / dt); - var last = -1; - - var f = function() - { - if ((last == div.scrollTop) || (div.scrollHeight - div.scrollTop <= dy)) - { - div.scrollTop = div.scrollHeight; - } - else - { - div.scrollTop += dy; - last = div.scrollTop; - setTimeout(f, 10); - } - } - f(); - - return self; -} - diff --git a/src/webfwt/js/TransitionPanePeer.js b/src/webfwt/js/TransitionPanePeer.js deleted file mode 100644 index 931622d56..000000000 --- a/src/webfwt/js/TransitionPanePeer.js +++ /dev/null @@ -1,154 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 18 Oct 2011 Andy Frank Creation -// - -/** - * TransitionPanePeer. - */ -fan.webfwt.TransitionPanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.TransitionPanePeer.prototype.$ctor = function(self) {} - -/** - * Inject CSS. - */ -fan.fwt.WidgetPeer.addCss( - "div._webfwt_TransitionPane_ {" + - " -webkit-perspective: 1000px;" + - " -moz-perspective: 1000px;" + - " -ms-perspective: 1000px;" + - " perspective: 1000px;" + - "} " + - "div._webfwt_TransitionPane_transition {" + - " position:absolute;" + - " -webkit-transform-style: preserve-3d;" + - " -moz-transform-style: preserve-3d;" + - " -ms-transform-style: preserve-3d;" + - " transform-style: preserve-3d;" + - "} " + - "div._webfwt_TransitionPane_flipFront {" + - " -webkit-backface-visibility: hidden;" + - " -moz-backface-visibility: hidden;" + - " -ms-backface-visibility: hidden;" + - " backface-visibility: hidden;" + - " -webkit-transform: translateZ(1px);" + - " -moz-transform: translateZ(1px);" + - " -ms-transform: translateZ(1px);" + - " transform: translateZ(1px);" + - "} " + - "div._webfwt_TransitionPane_flipBack {" + - " -webkit-backface-visibility: hidden;" + - " -moz-backface-visibility: hidden;" + - " -ms-backface-visibility: hidden;" + - " backface-visibility: hidden;" + - " -webkit-transform: rotateY(180deg) translateZ(1px);" + - " -moz-transform: rotateY(180deg) translateZ(1px);" + - " -ms-transform: rotateY(180deg) translateZ(1px);" + - " transform: rotateY(180deg) translateZ(1px);" + - "} "); - - -fan.webfwt.TransitionPanePeer.prototype.create = function(parentElem, self) -{ - this.m_dur = self.m_dur.toMillis(); // cache duration - this.m_angle = -180; - - var trans = document.createElement("div"); - trans.className = "_webfwt_TransitionPane_transition"; - - var div = this.emptyDiv(); - div.className = "_webfwt_TransitionPane_"; - div.appendChild(trans); - parentElem.appendChild(div); - return trans; -} - -fan.webfwt.TransitionPanePeer.prototype.sync = function(self) -{ - if (this.elem) - { - var div = this.elem.parentNode; - div.style.width = this.m_size.m_w + "px"; - div.style.height = this.m_size.m_h + "px"; - } - fan.fwt.WidgetPeer.prototype.sync.call(this, self); -} - -fan.webfwt.TransitionPanePeer.prototype.transitionTo = function(self, w) -{ - if (self.content() == null) - throw fan.sys.ArgErr.make("TransitionPane: must have content before transitionTo") - - if (self.m_style == "slideUp") this.doSlideUp(self, w); - else if (self.m_style == "flip") this.doFlip(self, w); - else throw fan.sys.ArgErr.make("Invalid style " + self.m_style); -} - -fan.webfwt.TransitionPanePeer.prototype.doSlideUp = function(self, to) -{ - var cur = self.content(); - var dur = this.m_dur; - var w = self.size().m_w; - var h = self.size().m_h; - - self.add(to); - to.bounds$(fan.gfx.Rect.make(0, h, w, h)); - self.relayout(); - - setTimeout(function() - { - var curPeer = cur.peer.elem; - if (curPeer == null) return; // bail if we got unmoutned - fan.fwt.WidgetPeer.setTransition(curPeer, "all " + dur + "ms"); - - var toPeer = to.peer.elem; - fan.fwt.WidgetPeer.setTransition(toPeer, "all " + dur + "ms"); - - curPeer.style.top = (-h) + "px"; - toPeer.style.top = "0px"; - - setTimeout(function() - { - self.content$(null); - fan.fwt.WidgetPeer.setTransition(curPeer, "none"); - curPeer.style.top = "0px"; - fan.fwt.WidgetPeer.setTransition(toPeer, "none"); - self.m_content = to; - self.relayout(); - }, dur); - }, 10); -} - -fan.webfwt.TransitionPanePeer.prototype.doFlip = function(self, w) -{ - // check meta - var a = self.m_meta.get("flip.angle"); - if (a != null) this.m_angle = a; - - var front = self.content().peer.elem; - fan.fwt.WidgetPeer.addClassName(front, "_webfwt_TransitionPane_flipFront"); - - self.add(w); - var back = w.peer.elem; - fan.fwt.WidgetPeer.addClassName(back, "_webfwt_TransitionPane_flipBack"); - w.bounds$(self.content().bounds()); - self.relayout(); - - var trans = this.elem; - fan.fwt.WidgetPeer.setTransition(trans, "all " + this.m_dur + "ms"); - fan.fwt.WidgetPeer.setTransform(trans, "rotateY(" + this.m_angle + "deg)"); - this.m_angle = -this.m_angle; - - setTimeout(function() - { - fan.fwt.WidgetPeer.setTransition(trans, "none"); - fan.fwt.WidgetPeer.setTransform(trans, "none"); - fan.fwt.WidgetPeer.removeClassName(front, "_webfwt_TransitionPane_flipFront"); - fan.fwt.WidgetPeer.removeClassName(back, "_webfwt_TransitionPane_flipBack"); - self.content$(null); - self.m_content = w; - }, this.m_dur); -} diff --git a/src/webfwt/js/TreeListPeer.js b/src/webfwt/js/TreeListPeer.js deleted file mode 100644 index 6b8c4d7dd..000000000 --- a/src/webfwt/js/TreeListPeer.js +++ /dev/null @@ -1,216 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 15 Jun 2011 Andy Frank Creation -// - -/** - * TreeListPeer. - */ -fan.webfwt.TreeListPeer = fan.sys.Obj.$extend(fan.webfwt.WebListPeer); -fan.webfwt.TreeListPeer.prototype.$ctor = function(self) {} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_TreeList_ {" + - " background:#fff;" + - "}" + - "div._webfwt_TreeList_ > div { "+ - " font:" + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.sysFontView()) + ";" + - " padding:4px 8px;" + - " overflow:hidden;" + - " white-space:nowrap;" + - "}" + - "div._webfwt_TreeList_zebra_ > div:nth-child(odd) { "+ - " background:#f1f5fa;" + - "}" + - "div._webfwt_TreeList_ > div > div { "+ - " overflow:hidden;" + - "}" + - "div._webfwt_TreeList_ > div.group { "+ - " background:#eee;" + - " border-top:1px solid #d2d2d2;" + - " border-bottom:1px solid #d2d2d2;" + - " color:#666;" + - " text-transform:uppercase;" + - " text-shadow:#fff 0 1px;" + - " font:" + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.sysFontSmall().toBold()) + ";" + - "}" + - "div._webfwt_TreeList_ > div.group:first-child { "+ - " border-top:none;" + - "}" + - "div._webfwt_TreeList_ > div > img { "+ - " padding-right:6px;" + - " float:left;" + - "}" + - "div._webfwt_TreeList_ > div > span { "+ - " float:right;" + - " font:" + fan.fwt.WidgetPeer.fontToCss(fan.fwt.DesktopPeer.sysFontSmall()) + ";" + - "}" + - "div._webfwt_TreeList_ > div > span.imgOnly { "+ - " float:right;" + - " font-size:2px;" + - "}" + - "div._webfwt_TreeList_ > div > span.def { "+ - " color:#325373;" + - " margin-top:1px;" + - " padding-left:6px;" + - "}" + - "div._webfwt_TreeList_ > div > span.pill { "+ - " background:#4f749a;" + - " color:#fff;" + - " padding:1px 6px;" + - " -moz-border-radius: 15px;" + - " -webkit-border-radius:15px;" + - " border-radius: 15px;" + - " margin-top:0px;" + - " margin-left:6px;" + - "}" + - "div._webfwt_TreeList_ > div.selected {" + - " background:#cbcbcb;" + - " font-weight:bold;" + - "}" + - "div:focus > div._webfwt_TreeList_ > div.selected { " + - " background:#3d80df;" + - " background-image:-webkit-linear-gradient(top, #1d67bc, #5a9ce6 1px, #1d67bc);" + - " background-image:-moz-linear-gradient(top, #1d67bc, #5a9ce6 1px, #1d67bc);" + - " background-image:-ms-linear-gradient(top, #1d67bc, #5a9ce6 1px, #1d67bc);" + - " background-image:linear-gradient(top, #1d67bc, #5a9ce6 1px, #1d67bc);" + - " color:#fff;" + - "}" + - "div:focus > div._webfwt_TreeList_ > div.selected > span.def {" + - " color:#fff;" + - "}" + - "div._webfwt_TreeList_ > div.selected > span.pill {" + - " background:#154f92;" + - "}"); - -// IE seems to have trouble doing text-overflow properly -if (!fan.fwt.DesktopPeer.$isIE) - fan.fwt.WidgetPeer.addCss( - "div._webfwt_TreeList_ > div > div { text-overflow:ellipsis; }"); - -fan.webfwt.TreeListPeer.prototype.setupContainer = function(self, container) -{ -// // cache border color -// this.m_rowBorder = null; -// if (self.m_borderColor != null) -// this.m_rowBorder = "1px solid " + self.m_borderColor.toCss(); - - // add css class - container.className = "_webfwt_WebScrollPane_ _webfwt_WebList_ _webfwt_TreeList_"; - if (self.zebraStripe()) container.className += " _webfwt_TreeList_zebra_"; -// if (self.m_bg != null) fan.fwt.WidgetPeer.setBg(container, self.m_bg); - - // calc icon offset to vertically center text - var size = self.iconSize(); - this.iconOffset = size.m_h > 16 ? Math.floor((size.m_h - 16) / 2) : 0; -} - -fan.webfwt.WebListPeer.prototype.repaintSelection = function(self, indices, selected) -{ - for (var i=0; i 0) row.style.paddingLeft = (8+(depth*12)) + "px"; -// if (this.m_rowBorder != null) row.style.borderBottom = this.m_rowBorder - - div = document.createElement("div") - div.title = text; - div.appendChild(document.createTextNode(text)); - if (font != null) div.style.font = fan.fwt.WidgetPeer.fontToCss(font); - - if (aux != null || auxIcon != null) - { - span = document.createElement("span"); - - var imgAux = null; - if (auxIcon != null) - { - imgAux = document.createElement("img"); - imgAux.src = fan.fwt.WidgetPeer.uriToImageSrc(auxIcon.m_uri); - } - - if (aux != null && auxIcon == null) - { - span.className = self.auxStyle(); - span.appendChild(document.createTextNode(aux)); - } - else if (aux == null && auxIcon != null) - { - span.className = "imgOnly"; - span.appendChild(imgAux); - } - else - { - var spanAux = document.createElement("span"); - spanAux.className = self.auxStyle(); - spanAux.appendChild(document.createTextNode(aux)); - span.appendChild(spanAux); - span.appendChild(imgAux); - } - } - - if (icon != null) - { - var ioff = this.iconOffset; - if (ioff > 0) - { - div.style.paddingTop = ioff + "px"; - if (span != null) span.style.marginTop = (ioff+1) + "px"; - } - - img = document.createElement("img"); - img.src = fan.fwt.WidgetPeer.uriToImageSrc(icon.m_uri); - - var size = self.iconSize(); - img.width = size.m_w; - img.height = size.m_h; - } - - if (self.isHeading(item)) row.className = "group"; - if (span != null) row.appendChild(span); - if (img != null) row.appendChild(img); - row.appendChild(div); - return row; -} - diff --git a/src/webfwt/js/UploaderPeer.js b/src/webfwt/js/UploaderPeer.js deleted file mode 100644 index 990e78972..000000000 --- a/src/webfwt/js/UploaderPeer.js +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 11 Dec 09 Andy Frank Creation -// - -fan.webfwt.UploaderPeer = fan.sys.Obj.$extend(fan.sys.Obj); -fan.webfwt.UploaderPeer.prototype.$ctor = function(self) {} - -fan.webfwt.UploaderPeer.prototype.submit = function(self, id) -{ - var form = document.getElementById(id); - form.submit(); -} - diff --git a/src/webfwt/js/WebBorderPanePeer.js b/src/webfwt/js/WebBorderPanePeer.js deleted file mode 100644 index dbbf4247e..000000000 --- a/src/webfwt/js/WebBorderPanePeer.js +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Oct 10 Andy Frank Creation -// - -/** - * WebBorderPanePeer. - */ -fan.webfwt.WebBorderPanePeer = fan.sys.Obj.$extend(fan.fwt.BorderPanePeer); -fan.webfwt.WebBorderPanePeer.prototype.$ctor = function(self) -{ - fan.fwt.LabelPeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.WebBorderPanePeer.prototype.m_style = null; -fan.webfwt.WebBorderPanePeer.prototype.style = function(self) { return this.m_style; } -fan.webfwt.WebBorderPanePeer.prototype.style$ = function(self, val) -{ - this.m_rebuild = true; - this.m_style = val; -} - -// backdoor hook to override style -fan.webfwt.WebBorderPanePeer.prototype.$style = function(self) -{ - return this.m_style; -} - diff --git a/src/webfwt/js/WebCanvasPeer.js b/src/webfwt/js/WebCanvasPeer.js deleted file mode 100644 index e88b01e18..000000000 --- a/src/webfwt/js/WebCanvasPeer.js +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 28 Sep 2011 Andy Frank Creation -// - -/** - * WebCanvasPeer. - */ -fan.webfwt.WebCanvasPeer = fan.sys.Obj.$extend(fan.fwt.CanvasPeer); -fan.webfwt.WebCanvasPeer.prototype.$ctor = function(self) {} - -fan.webfwt.WebCanvasPeer.prototype.clearOnRepaint = function(self) { return this.m_clearOnRepaint; } -fan.webfwt.WebCanvasPeer.prototype.clearOnRepaint$ = function(self, val) { this.m_clearOnRepaint = val; } -fan.webfwt.WebCanvasPeer.prototype.m_clearOnRepaint = true; diff --git a/src/webfwt/js/WebComboPeer.js b/src/webfwt/js/WebComboPeer.js deleted file mode 100644 index 6dc8b9626..000000000 --- a/src/webfwt/js/WebComboPeer.js +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 4 Dec 2011 Andy Frank Creation -// - -/** - * WebComboPeer. - */ -fan.webfwt.WebComboPeer = fan.sys.Obj.$extend(fan.fwt.ComboPeer); -fan.webfwt.WebComboPeer.prototype.$ctor = function(self) -{ - fan.fwt.ComboPeer.prototype.$ctor.call(this, self); -} - -// backdoor hook to override item text -fan.webfwt.WebComboPeer.prototype.$itemText = function(self, item) -{ - return self.itemText(item); -} diff --git a/src/webfwt/js/WebLabelPeer.js b/src/webfwt/js/WebLabelPeer.js deleted file mode 100644 index 8d95ce6b8..000000000 --- a/src/webfwt/js/WebLabelPeer.js +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 16 Apr 2010 Andy Frank Creation -// 17 Mar 2011 Andy Frank Rename from FLabel to WebLabel -// - -/** - * WebLabelPeer. - */ -fan.webfwt.WebLabelPeer = fan.sys.Obj.$extend(fan.fwt.LabelPeer); -fan.webfwt.WebLabelPeer.prototype.$ctor = function(self) -{ - fan.fwt.LabelPeer.prototype.$ctor.call(this, self); -} - -fan.webfwt.WebLabelPeer.prototype.m_hgap = null; -fan.webfwt.WebLabelPeer.prototype.hgap = function(self) { return this.m_hgap; } -fan.webfwt.WebLabelPeer.prototype.hgap$ = function(self, val) -{ - this.m_rebuild = true; - this.m_hgap = val; -} - -fan.webfwt.WebLabelPeer.prototype.m_softClip = false; -fan.webfwt.WebLabelPeer.prototype.softClip = function(self) { return this.m_softClip; } -fan.webfwt.WebLabelPeer.prototype.softClip$ = function(self, val) -{ - this.m_rebuild = true; - this.m_softClip = val; -} - -fan.webfwt.WebLabelPeer.prototype.m_imageSize = null; -fan.webfwt.WebLabelPeer.prototype.imageSize = function(self) { return this.m_imageSize; } -fan.webfwt.WebLabelPeer.prototype.imageSize$ = function(self, val) -{ - this.m_rebuild = true; - this.m_imageSize = val; -} - -fan.webfwt.WebLabelPeer.prototype.m_style = null; -fan.webfwt.WebLabelPeer.prototype.style = function(self) { return this.m_style; } -fan.webfwt.WebLabelPeer.prototype.style$ = function(self, val) -{ - this.m_rebuild = true; - this.m_style = val; -} - -// backdoor hook to override hgap -fan.webfwt.WebLabelPeer.prototype.$hgap = function(self) -{ - return this.m_hgap; -} - -// backdoor hook to override softClip -fan.webfwt.WebLabelPeer.prototype.$softClip = function(self) -{ - return this.m_softClip; -} - -// backdoor hook to override imageSize -fan.webfwt.WebLabelPeer.prototype.$imageSize = function(self) -{ - return this.m_imageSize; -} - -// backdoor hook to override style -fan.webfwt.WebLabelPeer.prototype.$style = function(self) -{ - return this.m_style; -} - - diff --git a/src/webfwt/js/WebListPeer.js b/src/webfwt/js/WebListPeer.js deleted file mode 100644 index a8af92eb3..000000000 --- a/src/webfwt/js/WebListPeer.js +++ /dev/null @@ -1,418 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 13 Jun 2011 Andy Frank Creation -// - -/** - * WebListPeer. - */ -fan.webfwt.WebListPeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.WebListPeer.prototype.$ctor = function(self) -{ -} - -fan.webfwt.WebListPeer.prototype.m_items = fan.sys.Obj.$type.emptyList(); -fan.webfwt.WebListPeer.prototype.items = function(self) { return this.m_items; } -fan.webfwt.WebListPeer.prototype.items$ = function(self, val) -{ - this.needsLayout = true; - this.m_items = val; - self.selectedIndexes$(fan.sys.List.make(fan.sys.Int.$type)); -} - -fan.webfwt.WebListPeer.prototype.m_scrolly = null; -fan.webfwt.WebListPeer.prototype.scrolly = function(self) -{ - var container = this.container(); - return container ? container.scrollTop : 0; -} -fan.webfwt.WebListPeer.prototype.scrolly$ = function(self, val) -{ - // max value is auto-clipped to viewport - if (val < 0) val = 0; - - var container = this.container() - if (container == null) this.m_scrolly = val; // handle in sync() - else - { - container.scrollTop = val; - this.m_scrolly = null; // make sure we clear out sync hook - } -} - -fan.webfwt.WebListPeer.prototype.create = function(parentElem, self) -{ - this.sel = []; - this.pivot = null; - this.needsLayout = true; - var div = this.emptyDiv(); - div.tabIndex = 0; - parentElem.appendChild(div); - return div; -} - -fan.webfwt.WebListPeer.prototype.rebuild = function(self) -{ - // setup container - var container = document.createElement("div"); - container.className = "_webfwt_WebScrollPane_ _webfwt_WebList_"; - container.style.overflowX = "hidden"; - container.style.overflowY = "auto"; - container.style.cursor = "default"; - this.setupContainer(self, container); - - if (self.selectionEnabled()) - { - var $this = this; - container.onmousedown = function(event) { return $this.handleMouseDown(self, event) } - container.onmouseup = function(event) { $this.handleMouseUp(self, event); } - container.ondblclick = function(event) { self.fireAction(); } - this.elem.onkeydown = function(event) { $this.handleKeyEvent(self, event); } - } - - // add items to container - var size = this.m_items.size(); - for (var i=0; i 0) - { - this.repaintSelection(self, this.sel, false); - this.sel = []; - } - - // if no new selection, bail here - var index = self.m_selectedIndexes; - if (index.isEmpty()) return; - - // set pivot if preselecting - if (this.pivot == null && index.size() == 1) - this.pivot = index.first(); - - // make sure index is in bounds - var container = this.elem.firstChild; - if (container == null) return; - if (container.childNodes.length == 0) return; - - // update new selection - this.sel = []; - for (var i=0; i (cs+ch)) elem.scrollIntoView(false); -} - -///////////////////////////////////////////////////////////////////////// -// Widget -///////////////////////////////////////////////////////////////////////// - -fan.webfwt.WebListPeer.prototype.prefSize = function(self, hints) -{ - var pref = fan.fwt.WidgetPeer.prototype.prefSize.call(this, self, hints); - - var pw = self.m_prefw; if (pw == null) pw = pref.m_w; - var ph = self.m_prefh; if (ph == null) ph = pref.m_h; - return fan.gfx.Size.make(pw, ph) -} - -fan.webfwt.WebListPeer.prototype.onLayout = function(self) {} - -fan.webfwt.WebListPeer.prototype.sync = function(self) -{ - if (this.needsLayout) // && this.m_size.m_w > 0) - { - this.needsLayout = false; - this.rebuild(self); - } - - var container = this.container(); - if (container != null) - { - container.style.width = (this.m_size.m_w-2) + "px"; - container.style.height = (this.m_size.m_h-2) + "px"; - } - - fan.fwt.WidgetPeer.prototype.sync.call(this, self); - - // check if scrolly is armed - if (this.m_scrolly && container != null && this.m_size.m_h > 0) - { - container.scrollTop = this.m_scrolly; - this.m_scrolly = null; - } - - // ensure first item in selection is visible - this.scrollSelectionInView(); -} - -///////////////////////////////////////////////////////////////////////// -// Mouse Events -///////////////////////////////////////////////////////////////////////// - -fan.webfwt.WebListPeer.prototype.handleMouseDown = function(self, event) -{ - self.focus(); - - var container = this.elem.firstChild; - var ix = this.elemToIndex(event.target); - if (ix == null) return; - - // bail if onBefore cancels - var beforeList = this.toIntList([ix]); - if (!self.fireBeforeSelect(beforeList)) return; - - // deselect current selection - this.repaintSelection(self, this.sel, false); - - // update selection - if (!self.m_multi) this.sel = [ix]; - else - { - if (event.ctrlKey || event.metaKey) - { - this.pivot = ix; - this.sel = this.cmdSel(this.sel, ix); - } - else if (event.shiftKey) - { - this.sel = this.shiftSel(this.sel, ix); - } - else - { - this.pivot = ix; - this.sel = [ix]; - } - } - - // repaint new selection - this.repaintSelection(self, this.sel, true); - - // disable selection - event.stopPropagation(); - return false; -} - -fan.webfwt.WebListPeer.prototype.handleMouseUp = function(self, event) -{ - // check if selection has changed - var index = self.m_selectedIndexes; - var same = this.sel.length == index.size(); - for (var i=0; i=0 && i 0) - { - // select previous item - var i = cur-1; - while (check(i)) i--; - if (i >= 0) { this.pivot=i; ix.push(i); } - // TODO: rubber-band keyboard support - // { - // if (!event.shiftKey) { this.pivot=i; ix.push(i); } - // else if (this.pivot == null) { this.pivot=i; ix.push(i); } - // else - // { - // var i = this.pivot; - // var di = cur < this.pivot ? -1 : 1; - // while (i != cur) { info.push(toInfo(index)); ix += di } - // } - // } - } - else if (diff > 0 && cur < this.m_items.size()-1) - { - // select next item - var i = cur+1; - while (check(i)) i++; - if (i < items.size()) { this.pivot=i; ix.push(i); } - } - - // bail if no selection - if (ix.length == 0) return; - - // updates selection - this.repaintSelection(self, this.sel, false); - this.sel = ix; - self.fireSelect(this.toIntList(this.sel)); -} - -///////////////////////////////////////////////////////////////////////// -// Support -///////////////////////////////////////////////////////////////////////// - -fan.webfwt.WebListPeer.prototype.container = function() -{ - if (this.elem == null) return null; - return this.elem.firstChild; -} - -fan.webfwt.WebListPeer.prototype.indexToElem = function(index) -{ - var container = this.container(); - return container.childNodes[index]; -} - -fan.webfwt.WebListPeer.prototype.elemToIndex = function(target) -{ - // short-circuit if background pressed - var container = this.container(); - if (target.className.indexOf("_webfwt_WebList_") != -1) return null; - - // walk up to actual row element - while (target.parentNode.className.indexOf("_webfwt_WebList_") == -1) - target = target.parentNode; - - // match up row to item - for (var i=0; i b) return 1; - return 0; - }); - - return merge; -} - -fan.webfwt.WebListPeer.prototype.shiftSel = function(cur, index) -{ - if (this.pivot == null) - { - this.pivot = index; - return [index]; - } - - var container = this.container(); - var list = []; - var ix = this.pivot; - var di = index < this.pivot ? -1 : 1; - - while (ix != (index+di)) - { - var node = container.childNodes[ix]; - if (node.className.indexOf("group") == -1) list.push(ix); - ix += di; - } - - return list; -} \ No newline at end of file diff --git a/src/webfwt/js/WebScrollPanePeer.js b/src/webfwt/js/WebScrollPanePeer.js deleted file mode 100644 index 3df18e3d7..000000000 --- a/src/webfwt/js/WebScrollPanePeer.js +++ /dev/null @@ -1,144 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 9 Sep 10 Andy Frank Creation -// - -/** - * WebScrollPanePeer. - */ -fan.webfwt.WebScrollPanePeer = fan.sys.Obj.$extend(fan.fwt.PanePeer); -fan.webfwt.WebScrollPanePeer.prototype.$ctor = function(self) -{ - this.hasScrollListener = false; -} - -// css -fan.fwt.WidgetPeer.addCss( - "div._webfwt_WebScrollPane_ { "+ - " border:1px solid #9f9f9f;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar {" + - " width: 10px;" + - " height: 10px;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar:vertical {" + - " border-left: 1px solid #bbb;" + - " background: -webkit-gradient(linear, left top, right top, from(#eee), to(#ddd));" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar:horizontal {" + - " border-top: 1px solid #bbb;" + - " background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ddd));" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-track-piece:vertical {" + - " background: -webkit-gradient(linear, left top, right top, from(#eaeaea), to(#f8f8f8));" + - " background: -webkit-box-shadow (linear, left top, right top, from(#eaeaea), to(#f8f8f8));" + - " margin: 5px 0;" + - " border: 1px solid #bbb;" + - " border-right-color: #ddd;" + - " border-radius: 5px;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-track-piece:horizontal {" + - " background: -webkit-gradient(linear, left top, left bottom, from(#eaeaea), to(#f8f8f8));" + - " background: -webkit-box-shadow (linear, left top, left bottom, from(#eaeaea), to(#f8f8f8));" + - " margin: 0 5px;" + - " border: 1px solid #bbb;" + - " border-bottom-color: #ddd;" + - " border-radius: 5px;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-button {" + - " display:none;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-thumb {" + - " border: 1px solid #848fa6;" + - " border-radius: 5px;" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-thumb:vertical {" + - " background: -webkit-gradient(linear, left top, right top, from(#b5bfcd), to(#8b99b2));" + - "}" + - "div._webfwt_WebScrollPane_::-webkit-scrollbar-thumb:horizontal {" + - " background: -webkit-gradient(linear, left top, left bottom, from(#b5bfcd), to(#8b99b2));" + - "}"); - -fan.webfwt.WebScrollPanePeer.prototype.create = function(parentElem, self) -{ - var overx = "hidden"; - switch (self.m_hpolicy) - { - case fan.webfwt.WebScrollPane.m_on: overx = "scroll"; break; - case fan.webfwt.WebScrollPane.m_auto: overx = "auto"; break; - } - - var overy = "hidden"; - switch (self.m_vpolicy) - { - case fan.webfwt.WebScrollPane.m_on: overy = "scroll"; break; - case fan.webfwt.WebScrollPane.m_auto: overy = "auto"; break; - } - - var div = this.emptyDiv(); - div.className = "_webfwt_WebScrollPane_"; - div.style.background = self.bg().toCss(); - div.style.overflowX = overx; - div.style.overflowY = overy; - if (self.m_border != null) - div.style.border = "1px solid " + self.m_border.toCss(); - parentElem.appendChild(div); - return div; -} - -fan.webfwt.WebScrollPanePeer.prototype.sync = function(self) -{ - // check events - this.checkScrollListener(self); - - // account for border - var w = this.m_size.m_w - 2; - var h = this.m_size.m_h - 2; - fan.fwt.WidgetPeer.prototype.sync.call(this, self, w, h); -} - - -fan.webfwt.WebScrollPanePeer.prototype.checkScrollListener = function(self) -{ - if (this.hasScrollListener) return; // already added - if (self.onScroll().isEmpty()) return; // nothing to add yet - - // attach and mark attached - var peer = this; - var func = function(e) - { - // scroll pos - var sx = peer.scrollX(self); - var sy = peer.scrollY(self); - - // create fwt::Event and invoke handler - var evt = fan.fwt.Event.make(); - evt.m_id = fan.fwt.EventId.m_unknown; - evt.m_pos = fan.gfx.Point.make(sx, sy); - evt.m_widget = self; - - // invoke handlers - var list = self.onScroll().list(); - for (var i=0; i 0) shadow += ","; - shadow += "inset " + self.m_innerShadow.toCss(); - } - - control.style.webkitBoxShadow = shadow; - control.style.MozBoxShadow = shadow; - control.style.boxShadow = shadow; -} - -fan.webfwt.WebTextPeer.prototype.subSync = function(self, control) -{ - var w = this.m_size.m_w; - var h = this.m_size.m_h; - var d = self.m_dropShadow; - if (d != null) - { - h -= d.m_offset.m_y + d.m_blur + d.m_spread; - control.style.height = h + "px"; - } - if (self.m_image != null) - { - var left = self.m_halignImage == fan.gfx.Halign.m_left; - var pad = left ? control.style.paddingLeft : control.style.paddingRight; - - if (pad == "") pad = "2px"; // see TextPeer.css for default - pad = parseInt(pad); - - var bx = w - pad - 16; - control.style.backgroundPosition = bx + "px center"; - } -} - -// backdoor hook to override style -fan.webfwt.WebTextPeer.prototype.$style = function(self) { return self.m_style; } -fan.webfwt.WebTextPeer.prototype.$disabledStyle = function(self) { return self.m_disabledStyle; } -fan.webfwt.WebTextPeer.prototype.$cssClass = function(readonly) -{ - var cls = fan.fwt.TextPeer.prototype.$cssClass.call(this, readonly); - if (this.subClass) cls += " " + this.subClass; - return cls; -} diff --git a/src/webfwt/locale/en.props b/src/webfwt/locale/en.props deleted file mode 100644 index f23f07fc2..000000000 --- a/src/webfwt/locale/en.props +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright (c) 2012, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 3 Feb 2012 Andy Frank Creation -// - -ok.name=OK -cancel.name=Cancel -yes.name=Yes -no.name=No diff --git a/src/webfwt/res/img/arrow-down.png b/src/webfwt/res/img/arrow-down.png deleted file mode 100644 index 131c0e197e99c01f18acf51e7ed479ed25128973..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf65yO?5U+k0H9&*8ZsYH-8HImqC08)Ip{kWAJqKb6Mw<&;$Ub C(KXuu diff --git a/src/webfwt/res/img/arrow-right.png b/src/webfwt/res/img/arrow-right.png deleted file mode 100644 index a1030060a36715fd6280920035aa0dda0c3a415d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf60z6$DLp07O|2W?uZ*(EB@obs2 zt~49Vk&qAfpY@;hk>;%7a`>>>cPp>D9jn5R3u==4nFQuE_#e!j?Qln}W`pLY#KUj9 kGtHcK)H-U&WQdD1q&B=^dUf2`)fVSqW~zI&C(Q6{Jp^CJV?0gtT_)EG>joX$KT_Chz7WLm*>9 z8V61z=Uf<7XsziV1o82GAFP;y(GwI;7wKbw&n5_heVV4rEX&9S9JpxAfpru`Ri&P7OFA-Qp1ezT%X+$0MhJC}1lX66RKjnC)P;JOF53WH-=_%4}>xdOj1U#(U)j^C3jcnpWb zsMTudbUL1l$75;k_xn%vyK@C^jYb2eX`Q*PbZ=0000QgejL2#sl8T&`w2;x#9LZwC(mkmEd1CQkTF5z+y;p` c{wK~dRH@g_ogUV*9cU(lr>mdKI;Vst06%9dB>(^b diff --git a/src/webfwt/res/img/throbber-charcoal.gif b/src/webfwt/res/img/throbber-charcoal.gif deleted file mode 100644 index cdedc7aa939602cfb255f44e1c7036178d8ad1af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1912 zcmbu{VLXh7iL!}|ha_(hDxlQ{$S?UZg(;92li#>t3^Y*G zjZFqBXr+mVhaiDNlTa(I&Ti8n$s$O-th^dXKaSLkI)B|+_FyOG<@Jx>yXVjEeP8$f zygyHTVq8R|o&+TL1AwTgsQCE!yu3V<$+Tt5mgeT>*4EaZo}QB@PYw(WT)1#yY;5et zjT`sw-MfGPJ^(;*7b0BX0Th49VoU}4s)Bs^t0h&%a($`3+EA{~pI1^=SPm5Tg{ez2 z(qlB*C1LYa9E80X!hYIfWE_cZU)m zQ`z1yfI5z-zkl>xF^cWErnpn91Wsq=R|!166kB zwu@EI!S@rW`<38dYN|TePMkD0Iz}8B3YH-P3BN1OD7o8wP77}CW7y+?e_%u*}zdi`t3*xy159KiuaBO{ANH;`K#5mXni-wIwH@(+$nPpw*wR< zg4AC^LCY71f=BfmdTvN|6X%U?tTD)rRK4v758;)qO&|S5#jrhz6 zA@B13!M^bv?Aw&JiN|IwOq%#++ogovit9IN$C+~lSAMRn|9GNiMVVJ!O})})^?FDZ zKZ*MPOEWEp)x(K=2l?I*&I4N~eO*eVekJ8zZqgayS|^o(V=+MDV_kDHAs=#g@JMwy z^-h}e1TqKnFL4%`NU|YT|IsA_ww-%bt>3%=;dWf?UJ)Y%%+W2K@euFv2oGQ-JM3bN#XtZjJzYx6Ww|7AP^Up0ny^gi0-;Yu zRpWuJw7BcV!q8#x}c05&x6>NwP+$s_UBA0R#eP?FiO0I(TL-(v3 zTSvs%sf9bc^R#sK!Ev4z3p}8-JJmB6&!6E!CQsD78D7w96@|!7zj0`Up(Mh>fQm|L zcssY_y7?8h4YsMf>plL>i?w2oT{4G7;`GRYni`$pN-LX-}SZ> zRJ^NdSyH-ZY>A)kvgkPkmb^O>pe_FX^-i-sst=Ra5j##KNBFsPau<^U2>WbzCdsqg zDk>c0ac;b(gEsGtmKcPf7GQ+Mi_-{%0wtc6RFqyMdpO0XO0SYlZ_0hX#v!}8&H|EX z)#~WntRuI%HoTHiQSW!P?Uw%RWM)M-J9C4z;cfVwCTIEx-HV(1l9X+y&ucUeAZa)rnzU?x-&B;U5YjtWDQUnY2gyr>W|ga9R{&iXFc}#s)(T=^IEW%j^%u3G!eC&m6c@eDgonGI^3{xAx8cJPf{%pC0 z4WVe86ncz_UfzamPlwH3FR%8#C_bY;ek79}#ZQo7B#m_q$FqHF7{_}rw{MqAdn^?TGVN^(w7}TqO{+3&F9nJ+R*E<<0&OXdX^es|GZF{4 zEl^%(9lp{U!Tk6YH4YyudgpHEiEi8)M~XPNk&IU z<2VigpuIfr-T(i>=Y2DhH)SO$HOVnigb(Dsi9bi^OfNlh;gy9lX!QL;2?>26z1K#P zV&uBmc3ztB!JQGe3%xin-RaY+qK3d98fkvdQN;t{oK0gq+21S5uC5%{i0Rkv4w<&D zJMjZD7~PJ7Ws}GES&9V@nF^RLDT|DSF@(;5sRA*CvH-&fm&e1b*w01Co_GW)!WWmq zeOZb@C}{*uR%lI>L5yacs>LSc&yub>OO|tgQr{&M!Pxk;eM1c&ROwWXCzb>?PAMLC z1GC6JXDUc(-m@u3aTC6;$74tGFI<-5LO#4LoR#vKh>|j7m0)u&+#r4f3us)g0tH^I zt;E*mux|86(!S&sVn}Jx(E{rR@KAZe3V3OQgh*I9umtZKPs|XRegw&V z*XWil!;da!)+BwsQ-QH9Pg^G5XT1P$nS_y40Tsy z{=wwwR=Ec@H0)=_Eu4eUa{DduV&e41fhwT}-kHt$uA zb}g8vv`P8=DavZKF<526AnGep^efD4R7poT41ZImDN+S_C?KFCwamgWUZJk`!~ zT#=Z`F1h2n%sgVJokp-VKc_!QT=Ag>&W4N}ZVs1IETePLkb?bUKWr#oNjnpyd9k)?!4M?%;92?~PwtjZ=-!&#>4sNe7_}r$O zson-Y-4)nvlJpZQC&U&6uKs?SCVNj09n8wAFu|P76)3h_vPe_N8`*{Q?^VX)r(?M%vvE=b?K;_!f8 z85)&S&2)|t3TrI%&F?Itlg^Dg1pG215&^1RM0`E5g%-D^w{1v;Ej@GFf#$mhQ?td50gdL-SzT{X6={H?<9MQh zTO&IDmziQe=nz0T8Ju01Xm47?mb69O*PU)%;OZFgx!P8>>(A#M=fWq3vBN`3q^FtF zv|HfcX=>^}AYVq9-PJrn@MXK6`Md#U4{x3jGJ<^XDaW#fs!Er#ODIP}1U_W7@EKVI zd^M_Eg2^QQ6DZ*yoe{9k_B%akiPtknp;_KPPaEMp_N?@h(ODHk$K`ainr|-+$frDT zQKU?@eheS0B!m-{o=?N*C;UFVSv* diff --git a/src/webfwt/test/FileUploadTest.fan b/src/webfwt/test/FileUploadTest.fan deleted file mode 100644 index 49088cb68..000000000 --- a/src/webfwt/test/FileUploadTest.fan +++ /dev/null @@ -1,179 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Jul 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** FileUploadTest -** -@Js -internal class FileUploadTest : ContentPane -{ - new make() - { - content = InsetPane(24) - { - GridPane - { - vgap = 24 - GridPane { numCols=2; hgap=24; makeDef, makeDlg }, - makeReset, - makeMulti, - makeMultiPart, - }, - } - } - - private Widget makeDef() - { - BorderPane - { - bg = Color("#eee") - insets = Insets(6) - GridPane - { - f := FileUploader - { - uri = `/upload` - onComplete.add |e| { echo("# $e.data") } - }; - Label { text="Def" }, f, buttons(f), - }, - } - } - - private Widget makeDlg() - { - GridPane - { - numCols = 3 - Button - { - text = "Dialog : Def" - onAction.add - { - FileUploader.dialog(this.window, FileUploader - { - uri = `/upload` - onComplete.add |e| { echo("# $e.data") } - }).open - } - }, - Button - { - text = "Dialog : Multi" - onAction.add - { - FileUploader.dialog(this.window, FileUploader - { - uri = `/upload` - multi = true - onComplete.add |e| { echo("# $e.data") } - }).open - } - }, - Button - { - text = "Dialog : Headers" - onAction.add - { - FileUploader.dialog(this.window, FileUploader - { - uri = `/upload` - headers = ["Test-Header-A": "foo", "Test-Header-B": "bar", "Content-Type": "foo/bar"] - onComplete.add |e| { echo("# $e.data") } - }).open - } - }, - } - } - - private Widget makeReset() - { - BorderPane - { - bg = Color("#eee") - insets = Insets(6) - GridPane - { - f := FileUploader - { - uri = `/upload` - onComplete.add |e| - { - try { - Dialog(window) - { - it.title = "" - it.body = Label { text="Done!" } - it.commands = [Dialog.ok] - it.onClose.add { e.widget->reset } - }.open - } - catch (Err x) { x.trace } - } - }; - Label { text="Reset" }, f, buttons(f), - }, - } - } - - private Widget makeMulti() - { - BorderPane - { - bg = Color("#eee") - insets = Insets(6) - GridPane - { - f := FileUploader - { - uri = `/upload` - multi = true - onComplete.add |e| { echo("# $e.data") } - } - Label { text="Multi" }, f, buttons(f), - }, - } - } - - private Widget makeMultiPart() - { - BorderPane - { - bg = Color("#eee") - insets = Insets(6) - GridPane - { - f := FileUploader - { - uri = `/upload` - useMultiPart = true - onComplete.add |e| { echo("# $e.data") } - }; - Label { text="Form Multi-Part" }, f, buttons(f), - }, - } - } - - private Widget buttons(FileUploader f) - { - InsetPane(0,0,0,270) - { - GridPane - { - halignPane = Halign.right - numCols = 2 - Button { text="Upload"; onAction.add { f.upload }}, - Button { text="Reset"; onAction.add { f.reset }}, - }, - } - } -} \ No newline at end of file diff --git a/src/webfwt/test/ShadowTest.fan b/src/webfwt/test/ShadowTest.fan deleted file mode 100644 index 9a88dc76f..000000000 --- a/src/webfwt/test/ShadowTest.fan +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 12 Jul 2011 Andy Frank Creation -// - -using gfx - -internal class ShadowTest : Test -{ - Void testStr() - { - verifyShadow(Shadow(""), Color.black, 0, 0, 0, 0) - verifyShadow(Shadow("#f00 0 -1"), Color.red, 0, -1, 0, 0) - verifyShadow(Shadow("#f00 1 2 3"), Color.red, 1, 2, 3, 0) - verifyShadow(Shadow("#0f0 1 2 3 4"), Color.green, 1, 2, 3, 4) - - verifyEq(Shadow("#3c3c3c 1 2").toStr, "#3c3c3c 1 2") - verifyEq(Shadow("#fff 0 -1").toStr, "#ffffff 0 -1") - verifyEq(Shadow("#fff 1 2 3").toStr, "#ffffff 1 2 3") - verifyEq(Shadow("#fff 1 2 0 4").toStr, "#ffffff 1 2 0 4") - - verifyEq(Shadow.fromStr("xyz", false), null) - verifyEq(Shadow.fromStr("#000 1 b", false), null) - - verifyErr(ParseErr#) |->| { x := Shadow("1") } - verifyErr(ParseErr#) |->| { x := Shadow("1 b") } - verifyErr(ParseErr#) |->| { x := Shadow("foo 1 1") } - verifyErr(ParseErr#) |->| { x := Shadow("#fff 1 1 0.5") } - verifyErr(ParseErr#) |->| { x := Shadow("#fff 1 2 3 4 5") } - } - - Void testCss() - { - verifyEq(Shadow("").toCss, "0px 0px #000000") - verifyEq(Shadow("#f00 1 1").toCss, "1px 1px #ff0000") - verifyEq(Shadow("#f00 -1 -1 2").toCss, "-1px -1px 2px #ff0000") - verifyEq(Shadow("#f00 -1 -1 2 5").toCss, "-1px -1px 2px 5px #ff0000") - verifyEq(Shadow("#f00 1 1 0 3").toCss, "1px 1px 0px 3px #ff0000") - } - - private Void verifyShadow(Shadow sh, Color c, Int x, Int y, Int b, Int s) - { - verifyEq(sh.color, c) - verifyEq(sh.offset.x, x) - verifyEq(sh.offset.y, y) - verifyEq(sh.blur, b) - verifyEq(sh.spread, s) - - test := Shadow { offset=Point(x,y); blur=b; spread=s; color=c } - verifyEq(sh.toStr, test.toStr) - verifyEq(Shadow.fromStr(sh.toStr), test) - } -} \ No newline at end of file diff --git a/src/webfwt/test/StyledButtonTest.fan b/src/webfwt/test/StyledButtonTest.fan deleted file mode 100644 index b2a7f47dd..000000000 --- a/src/webfwt/test/StyledButtonTest.fan +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 5 Oct 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** StyledButton -** -@Js -internal class StyledButtonTest : ContentPane -{ - new make() - { - content = InsetPane(24) - { - GridPane - { - vgap = 12 - StyledButton { text("Normal"), }, - StyledButton { mode=ButtonMode.toggle; text("Toggle"), }, - StyledButton { mode=ButtonMode.toggle; selected=true; text("Toggle/Sel"), }, - StyledButton { it.enabled=false; text("Disabled"), }, - BorderPane - { - insets = Insets(12) - bg = Color("#444") - GridPane - { - vgap = 12 - StyledButton.makeHud { text("Normal", Color.white), }, - StyledButton.makeHud { mode=ButtonMode.toggle; text("Toggle", Color.white), }, - StyledButton.makeHud { mode=ButtonMode.toggle; selected=true; text("Toggle/Sel", Color.white), }, - StyledButton.makeHud { it.enabled=false; text("Disabled", Color.white), }, - }, - }, - }, - } - } - - private Widget text(Str text, Color fg := Color.black) - { - Label { it.text=text; it.fg=fg } - } -} \ No newline at end of file diff --git a/src/webfwt/test/TestMod.fan b/src/webfwt/test/TestMod.fan deleted file mode 100644 index b156d90f5..000000000 --- a/src/webfwt/test/TestMod.fan +++ /dev/null @@ -1,147 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 27 Jul 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -************************************************************************** -** UiTesterMod -************************************************************************** - -internal const class UiTesterMod : WebMod -{ - override Void onService() - { - switch (req.uri.path.first) - { - case null: onIndex - case "pod": onPod - case "button": onButton - case "list": onList - case "transition": onTransition - case "upload": onUpload - case "scroll": onScroll - default: res.sendErr(404) - } - } - - private Void onIndex() - { - res.headers["Content-Type"] = "text/html; charset=UTF-8" - out := res.out - out.printLine("") - out.html - out.head.title.w("WebFwt UiTester").titleEnd.headEnd - out.body - .h1.w("WebFwt UiTester").h1End - .ul - .li.a(`button`).w("StyledButton").aEnd.liEnd - .li.a(`list`).w("WebList").aEnd.liEnd - .li.a(`transition`).w("TransitionPane").aEnd.liEnd - .li.a(`upload`).w("File Upload").aEnd.liEnd - .li.a(`scroll`).w("WebScrollPane").aEnd.liEnd - .ulEnd - out.bodyEnd - out.htmlEnd - } - - private Void onPod() - { - File file := ("fan://" + req.uri.toStr[5..-1]).toUri.get - if (!file.exists) { res.sendErr(404); return } - FileWeblet(file).onService - } - - private Void onButton() - { - fwt("StyledButton : WebFwt UiTester", "webfwt::StyledButtonTest") - } - - private Void onList() - { - fwt("WebList : WebFwt UiTester", "webfwt::WebListTest") - } - - private Void onTransition() - { - fwt("TransitionPane : WebFwt UiTester", "webfwt::TransitionPaneTest") - } - - private Void onUpload() - { - if (req.method == "GET") - { - fwt("FileUpload : WebFwt UiTester", "webfwt::FileUploadTest") - } - else - { - name := req.headers["FileUpload-filename"] - buf := req.in.readAllBuf - //buf := Buf(); while (req.in.readBuf(buf, 512) != null) { Slot.find("concurrent::Actor.sleep")->call(50ms) } - echo("# headers:") - echo(req.headers.join("\n") |v,n| { "# $n: $v" }) - echo("# uploaded $buf.size bytes") - // echo(buf.readAllStr) - echo("#") - - res.statusCode = 200 - res.headers["Content-Type"] = "text/plain; charset=UTF-8" - res.out.print("loaded!").flush.close - } - } - - private Void onScroll() - { - fwt("WebScrollPane : WebFwt UiTester", "webfwt::WebScrollPaneTest") - } - - private Void fwt(Str title, Str test) - { - podUri := `/pod/` - res.headers["Content-Type"] = "text/html; charset=utf-8" - out := res.out - out.printLine("") - out.html - out.head - out.title.esc(title).titleEnd - out.style.w( - "body { font:10pt Lucida Grande, Arial; } - a { color:#3d80df; } - ").styleEnd - out.includeJs(podUri + `sys/sys.js`) - out.includeJs(podUri + `concurrent/concurrent.js`) - out.includeJs(podUri + `util/util.js`) - out.includeJs(podUri + `web/web.js`) - out.includeJs(podUri + `gfx/gfx.js`) - out.includeJs(podUri + `dom/dom.js`) - out.includeJs(podUri + `fwt/fwt.js`) - out.includeJs(podUri + `webfwt/webfwt.js`) - WebUtil.jsMain(out, "webfwt::UiTesterMain", ["test":test]) - out.headEnd - out.body - out.bodyEnd - out.htmlEnd - } -} - -************************************************************************** -** UiTesterPane -************************************************************************** -@Js -internal class UiTesterMain -{ - Void main() - { - test := Env.cur.vars["test"] - type := Type.find(test) - win := Window() - win.content = type.make - win.open - } -} diff --git a/src/webfwt/test/TransitionPaneTest.fan b/src/webfwt/test/TransitionPaneTest.fan deleted file mode 100644 index a4c9cfd21..000000000 --- a/src/webfwt/test/TransitionPaneTest.fan +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 18 Oct 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** TransitionPaneTest -** -@Js -internal class TransitionPaneTest : ContentPane -{ - new make() - { - content = InsetPane(24) - { - GridPane - { - vgap = 24 - hgap = 24 - sample("style=\"flip\"", "flip"), - sample("style=\"slideUp\"", "slideUp"), - }, - } - } - - Widget sample(Str text, Str style) - { - ConstraintPane - { - minw=300; maxw=300 - minh=300; maxh=300 - p := TransitionPane { it.style=style } - p.content = foo(text, p) - p, - } - } - - Widget foo(Str text, TransitionPane p) - { - BorderPane - { - bg = Color("#eee") - GridPane - { - halignPane = Halign.center - valignPane = Valign.center - Label { it.text=text }, - Button - { - it.text = "Transition" - it.onAction.add |e| { p.transitionTo(bar(text, p)) } - }, - }, - } - } - - Widget bar(Str text, TransitionPane p) - { - BorderPane - { - bg = Color("#666") - GridPane - { - halignPane = Halign.center - valignPane = Valign.center - Label { it.text=text; fg=Color.white }, - Button - { - it.text = "Transition" - it.onAction.add |e| { p.transitionTo(foo(text, p)) } - }, - }, - } - } -} \ No newline at end of file diff --git a/src/webfwt/test/WebListTest.fan b/src/webfwt/test/WebListTest.fan deleted file mode 100644 index d58f329ec..000000000 --- a/src/webfwt/test/WebListTest.fan +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 10 Dec 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** WebListTest -** -@Js -internal class WebListTest : ContentPane -{ - new make() - { - content = InsetPane(12) - { - GridPane - { - vgap = 3 - BorderPane { insets=Insets(12); treeListWhite, }, - BorderPane { bg=Color("#d4dbe3"); insets=Insets(12); treeListPale, }, - BorderPane { bg=Color("#333"); insets=Insets(12); treeListHud, }, - }, - } - } - - Widget treeListWhite() - { - GridPane - { - hgap = 24 - numCols = 4 - - TestList { - items=[ - TestItem { text="Boulevard" }, - TestItem { text="Grove" }, - TestItem { text="Mulberry" }, - TestItem { text="Stuart" } - ] - }, - - TestList { - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="10" }, - TestItem { text="Grove"; icon=iconFolder; aux="7" }, - TestItem { text="Mulberry"; icon=iconFolder; aux="8" }, - TestItem { text="Stuart" ; icon=iconFolder; aux="22" } - ] - }, - - TestList { - //borderColor = Color("#d2d2d2") - style = "pill" - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="2" }, - TestItem { text="Grove"; icon=iconFolder; depth=1; aux="3" }, - TestItem { text="Mulberry"; icon=iconFolder; depth=2 }, - TestItem { text="Stuart" ; icon=iconFolder; depth=3; aux="1"; } - ] - }, - - TestList { - items=[ - TestItem { text="Zone A"; group=true }, - TestItem { text="Boulevard"; icon=iconFolder }, - TestItem { text="Grove"; icon=iconFolder }, - TestItem { text="Zone B"; group=true }, - TestItem { text="Mulberry"; icon=iconFolder }, - TestItem { text="Stuart" ; icon=iconFolder } - ] - }, - } - } - - Widget treeListPale() - { - GridPane - { - hgap = 24 - numCols = 4 - - TestPaleList { - items=[ - TestItem { text="Boulevard" }, - TestItem { text="Grove" }, - TestItem { text="Mulberry" }, - TestItem { text="Stuart" } - ] - }, - - TestPaleList { - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="10" }, - TestItem { text="Grove"; icon=iconFolder; aux="7" }, - TestItem { text="Mulberry"; icon=iconFolder; aux="8" }, - TestItem { text="Stuart" ; icon=iconFolder; aux="22" } - ] - }, - - TestPaleList { - style = "pill" - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="2" }, - TestItem { text="Grove"; icon=iconFolder; depth=1; aux="3" }, - TestItem { text="Mulberry"; icon=iconFolder; depth=2 }, - TestItem { text="Stuart" ; icon=iconFolder; depth=3; aux="1"; } - ] - }, - - TestPaleList { - items=[ - TestItem { text="Zone A"; group=true }, - TestItem { text="Boulevard"; icon=iconFolder }, - TestItem { text="Grove"; icon=iconFolder }, - TestItem { text="Zone B"; group=true }, - TestItem { text="Mulberry"; icon=iconFolder }, - TestItem { text="Stuart" ; icon=iconFolder } - ] - }, - } - } - - Widget treeListHud() - { - GridPane - { - hgap = 24 - numCols = 4 - - TestHudList { - items=[ - TestItem { text="Boulevard" }, - TestItem { text="Grove" }, - TestItem { text="Mulberry" }, - TestItem { text="Stuart" } - ] - }, - - TestHudList { - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="10" }, - TestItem { text="Grove"; icon=iconFolder; aux="7" }, - TestItem { text="Mulberry"; icon=iconFolder; aux="8" }, - TestItem { text="Stuart" ; icon=iconFolder; aux="22" } - ] - }, - - TestHudList { - style = "pill" - //borderColor = Color("#444") - items=[ - TestItem { text="Boulevard"; icon=iconFolder; aux="2" }, - TestItem { text="Grove"; icon=iconFolder; depth=1; aux="3" }, - TestItem { text="Mulberry"; icon=iconFolder; depth=2 }, - TestItem { text="Stuart" ; icon=iconFolder; depth=3; aux="1"; } - ] - }, - - TestHudList { - items=[ - TestItem { text="Zone A"; group=true }, - TestItem { text="Boulevard"; icon=iconFolder }, - TestItem { text="Grove"; icon=iconFolder }, - TestItem { text="Zone B"; group=true }, - TestItem { text="Mulberry"; icon=iconFolder }, - TestItem { text="Stuart" ; icon=iconFolder } - ] - }, - } - } - - static const Image iconFolder := Image(`fan://icons/x16/folder.png`) -} - -@Js -internal class TestList : TreeList -{ - Str? style - override Size prefSize(Hints hints := Hints.defVal) { Size(175,225) } - override Bool isHeading(Obj item) { item->group } - override Str text(Obj item) { item->text } - override Image? icon(Obj item, Bool sel) { item->icon } - override Int depth(Obj item) { item->depth } - override Str? aux(Obj item) { item->aux } - override Str auxStyle() { style ?: super.auxStyle } -} - -@Js -internal class TestPaleList : PaleTreeList -{ - Str? style - override Size prefSize(Hints hints := Hints.defVal) { Size(175,225) } - override Bool isHeading(Obj item) { item->group } - override Str text(Obj item) { item->text } - override Image? icon(Obj item, Bool sel) { item->icon } - override Int depth(Obj item) { item->depth } - override Str? aux(Obj item) { item->aux } - override Str auxStyle() { style ?: super.auxStyle } -} - -@Js -internal class TestHudList : HudList -{ - Str? style - override Size prefSize(Hints hints := Hints.defVal) { Size(175,225) } - override Bool isHeading(Obj item) { item->group } - override Str text(Obj item) { item->text } - override Image? icon(Obj item, Bool sel) { item->icon } - override Int depth(Obj item) { item->depth } - override Str? aux(Obj item) { item->aux } - override Str auxStyle() { style ?: super.auxStyle } -} - -@Js -internal class TestItem -{ - Str? text - Image? icon - Int depth := 0 - Str? aux - Bool group := false -} diff --git a/src/webfwt/test/WebScrollPaneTest.fan b/src/webfwt/test/WebScrollPaneTest.fan deleted file mode 100644 index eba4e6ad6..000000000 --- a/src/webfwt/test/WebScrollPaneTest.fan +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) 2011, Brian Frank and Andy Frank -// Licensed under the Academic Free License version 3.0 -// -// History: -// 10 Dec 2011 Andy Frank Creation -// - -using fwt -using gfx -using web - -** -** WebScrollPaneTest -** -@Js -internal class WebScrollPaneTest : ContentPane -{ - new make() - { - content = InsetPane(24) - { - GridPane - { - numCols = 4 - vgap = 24 - hgap = 24 - // auto/off - sample(Size(200,200), Size(100,100), WebScrollPane.auto, WebScrollPane.off), - sample(Size(200,200), Size(200,200), WebScrollPane.auto, WebScrollPane.off), - sample(Size(200,200), Size(300,300), WebScrollPane.auto, WebScrollPane.off), - sample(Size(200,200), Size(300,100), WebScrollPane.auto, WebScrollPane.off), - - // auto/auto - sample(Size(200,200), Size(100,100), WebScrollPane.auto, WebScrollPane.auto), - sample(Size(200,200), Size(200,200), WebScrollPane.auto, WebScrollPane.auto), - sample(Size(200,200), Size(300,300), WebScrollPane.auto, WebScrollPane.auto), - sample(Size(200,200), Size(300,100), WebScrollPane.auto, WebScrollPane.auto), - - // on/on - sample(Size(200,200), Size(100,100), WebScrollPane.on, WebScrollPane.on), - sample(Size(200,200), Size(200,200), WebScrollPane.on, WebScrollPane.on), - sample(Size(200,200), Size(300,300), WebScrollPane.on, WebScrollPane.on), - sample(Size(200,200), Size(300,100), WebScrollPane.on, WebScrollPane.on), - }, - } - } - - Widget sample(Size container, Size content, Int vpolicy, Int hpolicy) - { - ConstraintPane - { - minw=container.w; maxw=container.w - minh=container.h; maxh=container.h - WebScrollPane - { - it.vpolicy = vpolicy - it.hpolicy = hpolicy - ConstraintPane - { - minw=content.w; maxw=content.w - minh=content.h; maxh=content.h - BorderPane { border=Border("#f00") }, - }, - }, - } - } -}