Skip to content

Commit

Permalink
Release 1.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Mar 14, 2016
1 parent d47f1e3 commit c5b7f6c
Show file tree
Hide file tree
Showing 13 changed files with 366 additions and 105 deletions.
35 changes: 27 additions & 8 deletions examples/showcase/showcasecore/showcasecore.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func buildWindowDemo(event gwu.Event) gwu.Comp {
p := gwu.NewPanel()

p.Add(gwu.NewLabel("The Window represents the whole window, the page inside the browser."))
p.AddVSpace(5)
p.AddVSpace(20)
p.Add(gwu.NewLabel("The Window is the top of the component hierarchy. It is an extension of the Panel."))

return p
Expand Down Expand Up @@ -586,6 +586,16 @@ func buildLinkDemo(event gwu.Event) gwu.Comp {
return p
}

func buildSessMonitorDemo(event gwu.Event) gwu.Comp {
p := gwu.NewPanel()

p.Add(gwu.NewLabel("The SessMonitor component monitors and displays the session timeout and network connectivity without interacting with the session."))
p.AddVSpace(20)
p.Add(gwu.NewLabel("An example SessMonitor can be viewed on the right side of the header."))

return p
}

func buildTimerDemo(event gwu.Event) gwu.Comp {
p := gwu.NewPanel()
p.SetCellPadding(3)
Expand Down Expand Up @@ -689,11 +699,15 @@ func buildShowcaseWin(sess gwu.Session) {
sess.SetAttr("hiddenPan", hiddenPan)

header := gwu.NewHorizontalPanel()
header.Style().SetFullWidth().SetBorderBottom2(2, gwu.BrdStyleSolid, "#777777")
l := gwu.NewLabel("Gowut - Showcase of Features")
l.Style().SetFontWeight(gwu.FontWeightBold).SetFontSize("120%")
header.Add(l)
header.Style().SetFullWidth().SetBorderBottom2(2, gwu.BrdStyleSolid, "#cccccc")
title := gwu.NewLink("Gowut - Showcase of Features", win.Name())
title.SetTarget("")
title.Style().SetColor(gwu.ClrBlue).SetFontWeight(gwu.FontWeightBold).SetFontSize("120%").Set("text-decoration", "none")
header.Add(title)
header.AddHConsumer()
header.Add(gwu.NewLabel("Session timeout:"))
header.Add(gwu.NewSessMonitor())
header.AddHSpace(10)
header.Add(gwu.NewLabel("Theme:"))
themes := gwu.NewListBox([]string{"default", "debug"})
themes.AddEHandlerFunc(func(e gwu.Event) {
Expand All @@ -703,6 +717,7 @@ func buildShowcaseWin(sess gwu.Session) {
header.Add(themes)
header.AddHSpace(10)
reset := gwu.NewLink("Reset", "#")
reset.Style().SetColor(gwu.ClrBlue)
reset.SetTarget("")
reset.AddEHandlerFunc(func(e gwu.Event) {
e.RemoveSess()
Expand Down Expand Up @@ -764,12 +779,12 @@ func buildShowcaseWin(sess gwu.Session) {
return demo
}

links.Style().SetFullHeight().SetBorderRight2(2, gwu.BrdStyleSolid, "#777777")
links.Style().SetFullHeight().SetBorderRight2(2, gwu.BrdStyleSolid, "#cccccc")
links.AddVSpace(5)
homeDemo := createDemo("Home", buildHomeDemo)
selectDemo(homeDemo, nil)
links.AddVSpace(5)
l = gwu.NewLabel("Component Palette")
l := gwu.NewLabel("Component Palette")
l.Style().SetFontWeight(gwu.FontWeightBold).SetFontSize("110%")
links.Add(l)
links.AddVSpace(5)
Expand Down Expand Up @@ -801,6 +816,7 @@ func buildShowcaseWin(sess gwu.Session) {
createDemo("Image", buildImageDemo)
createDemo("Label", buildLabelDemo)
createDemo("Link", buildLinkDemo)
createDemo("SessMonitor", buildSessMonitorDemo)
createDemo("Timer", buildTimerDemo)
links.AddVConsumer()
setNoWrap(links)
Expand All @@ -812,7 +828,7 @@ func buildShowcaseWin(sess gwu.Session) {
win.CellFmt(content).Style().SetFullSize()

footer := gwu.NewHorizontalPanel()
footer.Style().SetFullWidth().SetBorderTop2(2, gwu.BrdStyleSolid, "#777777")
footer.Style().SetFullWidth().SetBorderTop2(2, gwu.BrdStyleSolid, "#cccccc")
footer.Add(hiddenPan)
footer.AddHConsumer()
l = gwu.NewLabel("Copyright © 2013-2016 András Belicza. All rights reserved.")
Expand Down Expand Up @@ -849,6 +865,9 @@ func (h SessHandler) Removed(s gwu.Session) {}
func StartServer(appName string) {
// Create GUI server
server := gwu.NewServer(appName, "")
for _, headHtml := range extraHeadHtmls {
server.AddRootHeadHtml(headHtml)
}
server.AddStaticDir("/asdf", "w:/")
server.SetText("Gowut - Showcase of Features")

Expand Down
3 changes: 3 additions & 0 deletions gwu/css.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ body {font-family:Arial}
.gwu-TabBar-Selected {padding-left:5px; padding-right:5px; border:1px solid #8080f8; background:#8080f8; cursor:default}
.gwu-TabPanel {}
.gwu-TabPanel-Content {border:1px solid #8080f8; width:100%; height:100%}
.gwu-SessMonitor {}
.gwu-SessMonitor-Expired, .gwu-SessMonitor-Error {color:red}
`)

staticCss[resNameStaticCss(ThemeDebug)] = []byte(string(staticCss[resNameStaticCss(ThemeDefault)]) +
Expand Down
9 changes: 5 additions & 4 deletions gwu/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ Containers to group and lay out components:
Input components to get data from users:
CheckBox
ListBox (it's either a drop-down list or a multi-line/multi-select list box)
TextBox (it's either a one-line text box or a multi-line text area)
ListBox (it's either a drop-down list or a multi-line/multi-select list box)
TextBox (it's either a one-line text box or a multi-line text area)
PasswBox
RadioButton
SwitchButton
Expand All @@ -230,6 +230,7 @@ Other components:
Image
Label
Link
SessMonitor
Timer
Expand Down Expand Up @@ -397,7 +398,7 @@ package gwu

// Gowut version information.
const (
GowutVersion = "1.0.0" // Gowut version (major.minor.maintenance[dev])
GowutReleaseDate = "2016-03-08 CET" // Gowut release date
GowutVersion = "1.1.0" // Gowut version: major.minor.maintenance[-dev]
GowutReleaseDate = "2016-03-14 CET" // Gowut release date
GowutRelDateLayout = "2006-01-02 MST" // Gowut release date layout (for time.Parse())
)
4 changes: 2 additions & 2 deletions gwu/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const (
KeyWin = 91

KeyNumpad0 = 96
KeyNumPad9 = 105
KeyNumpad9 = 105
KeyNumpadMul = 106
KeyNumpadPlus = 107
KeyNumpadMinus = 109
Expand Down Expand Up @@ -279,7 +279,7 @@ type Event interface {
// forkEvent forks a new Event from this one.
// The new event will have a parent pointing to us.
// Accessing/changing the session and defining post-event actions in the forked
// event work like if they would be done on this event.
// event works as if they would be done on this event.
forkEvent(etype EventType, src Comp) Event
}

Expand Down
6 changes: 3 additions & 3 deletions gwu/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package gwu
package gwu_test

import (
"code/google/com/p/gowut/gwu"
"github.com/icza/gowut/gwu"
)

// Example code determining which button was clicked.
Expand All @@ -32,7 +32,7 @@ func ExampleButton() {
// Example code determining what kind of key is involved.
func ExampleTextBox() {
b := gwu.NewTextBox("")
tb.AddSyncOnETypes(gwu.ETypeKeyUp) // This is here so we will see up-to-date value in the event handler
b.AddSyncOnETypes(gwu.ETypeKeyUp) // This is here so we will see up-to-date value in the event handler
b.AddEHandlerFunc(func(e gwu.Event) {
if e.ModKey(gwu.ModKeyShift) {
// SHIFT is pressed
Expand Down
80 changes: 59 additions & 21 deletions gwu/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ func init() {
function createXmlHttp() {
if (window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari
return xmlhttp=new XMLHttpRequest();
return new XMLHttpRequest();
else // IE6, IE5
return xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
return new ActiveXObject("Microsoft.XMLHTTP");
}
// Send event
function se(event, etype, compId, compValue) {
var xmlhttp = createXmlHttp();
var xhr = createXmlHttp();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
procEresp(xmlhttp);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200)
procEresp(xhr);
}
xmlhttp.open("POST", _pathEvent, true); // asynch call
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.open("POST", _pathEvent, true); // asynch call
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
var data="";
Expand Down Expand Up @@ -112,11 +112,11 @@ function se(event, etype, compId, compValue) {
data += "&" + _pKeyCode + "=" + (event.which ? event.which : event.keyCode);
}
xmlhttp.send(data);
xhr.send(data);
}
function procEresp(xmlhttp) {
var actions = xmlhttp.responseText.split(";");
function procEresp(xhr) {
var actions = xhr.responseText.split(";");
if (actions.length == 0) {
window.alert("No response received!");
Expand Down Expand Up @@ -154,13 +154,13 @@ function rerenderComp(compId) {
if (!e) // Component removed or not visible (e.g. on inactive tab of TabPanel)
return;
var xmlhttp = createXmlHttp();
var xhr = createXmlHttp();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
// Remember focused comp which might be replaced here:
var focusedCompId = document.activeElement.id;
e.outerHTML = xmlhttp.responseText;
e.outerHTML = xhr.responseText;
focusComp(focusedCompId);
// Inserted JS code is not executed automatically, do it manually:
Expand All @@ -172,10 +172,10 @@ function rerenderComp(compId) {
}
}
xmlhttp.open("POST", _pathRenderComp, false); // synch call (if async, browser specific DOM rendering errors may arise)
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.open("POST", _pathRenderComp, false); // synch call (if async, browser specific DOM rendering errors may arise)
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(_pCompId + "=" + compId);
xhr.send(_pCompId + "=" + compId);
}
// Get selected indices (of an HTML select)
Expand Down Expand Up @@ -245,11 +245,11 @@ function addonbeforeunload(func) {
var timers = new Object();
function setupTimer(compId, etype, timeout, repeat, active, reset) {
function setupTimer(compId, js, timeout, repeat, active, reset) {
var timer = timers[compId];
if (timer != null) {
var changed = timer.timeout != timeout || timer.repeat != repeat || timer.reset != reset;
var changed = timer.js != js || timer.timeout != timeout || timer.repeat != repeat || timer.reset != reset;
if (!active || changed) {
if (timer.repeat)
clearInterval(timer.id);
Expand All @@ -265,18 +265,56 @@ function setupTimer(compId, etype, timeout, repeat, active, reset) {
// Create new timer
timers[compId] = timer = new Object();
timer.js = js;
timer.timeout = timeout;
timer.repeat = repeat;
timer.reset = reset;
// Start the timer
var js = "se(null," + etype + "," + compId + ");";
if (timer.repeat)
timer.id = setInterval(js, timeout);
else
timer.id = setTimeout(js, timeout);
}
function checkSession(compId) {
var e = document.getElementById(compId);
if (!e) // Component removed or not visible (e.g. on inactive tab of TabPanel)
return;
var xhr = createXmlHttp();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var timeoutSec = parseFloat(xhr.responseText);
if (timeoutSec < 60)
e.classList.add("gwu-SessMonitor-Expired");
else
e.classList.remove("gwu-SessMonitor-Expired");
var cnvtr = window[e.getAttribute("gwuJsFuncName")];
e.children[0].innerText = typeof cnvtr === 'function' ? cnvtr(timeoutSec) : convertSessTimeout(timeoutSec);
}
}
xhr.open("GET", _pathSessCheck, false); // synch call (else we can't catch connection error)
try {
xhr.send();
e.classList.remove("gwu-SessMonitor-Error");
} catch (err) {
e.classList.add("gwu-SessMonitor-Error");
e.children[0].innerText = "CONN ERR";
}
}
function convertSessTimeout(sec) {
if (sec <= 0)
return "Expired!";
else if (sec < 60)
return "<1 min";
else
return "~" + Math.round(sec / 60) + " min";
}
// INITIALIZATION
addonload(function() {
Expand Down
Loading

0 comments on commit c5b7f6c

Please sign in to comment.