After about (Few (very few)) days of vacation, I returned to work harder and to prove it, I show that state is the development of LiveWiki I promised to do. Using JS2JS, I am now developing a set of widgets for web browsers. This first version is very simple, but it has enough to see the full picture: Smalltalk code is written and run in Web browsers (after conversion ST> JS). You can download the current version SqueakSource .
This is a method SWTExampleApplication class that creates a simple (and boring) text.
created
addWidget: (
| level: 2 contents: 'Simple texts' ). root |
SWTText
'some plain text. bla, bla, bla, bla, bla.'
).
| root addWidget: ( SWTText contents: 'text in red' ). root lastWidget color: S2SColor red . root addWidget: ( SWTText contents: 'text in blue / green' ). root lastWidget color: S2SColor blue; backgroundColor: S2SColor green . root addBreak . The method is then shown as event management. Is clearly the use of Smalltalk blocks (which are mapped to functions of JS): SWTExampleApplication>> createButtons root addHorizontalRule . root addWidget: ( SWTHeader level: 2 contents: 'Buttons' ). root addWidget: ( SWTButton caption: 'inspect event' onClick: [ : event [ : event |
event
| asString ]. button onClick: [: event S2SColor blue ; backgroundColor: S2SColor blue muchLighter . button onFocus: [: event S2SColor red ; backgroundColor: S2SColor red muchLighter ]. button onBlur: [: event blue; backgroundColor: S2SColor blue muchLighter ]. If there is something interesting about this first version is that I'm playing with the widgets "Edit In Place" (Edit In Place) which I use to live LiveWiki modification. This is the method that creates some texts "EditInPlace" and also created a button to create more editable text. SWTExampleApplication>> createEditableTexts ( SWTHeader level: 2 contents: 'Edit-In-Place texts' ). root addWidget: ( SWTButton caption: 'add a new edit-in-place text' onClick: [ : event ( SWTEditInPlaceText contents: 'One edit-in-place text, click on me to edit' ). root addBreak . root addWidget: ( SWTEditInPlaceText contents: 'Another edit-in-place text (with background color), double click on me to edit' ). root lastWidget editOnDblClick ; backgroundColor: S2SColor blue muchLighter . root addBreak . root addWidget: ( SWTEditInPlaceText contents: 'Just another edit-in-place text (with background color), move mouse over me to edit' ). root lastWidget editOnMouseOver ; backgroundColor: S2SColor red muchLighter . root addBreak . root addWidget: ( SWTEditInPlaceText contents: 'And just another edit-in-place text (with background color), move mouse over me to edit' ). root lastWidget editOnMouseOver ; backgroundColor: S2SColor green muchLighter . Root addBreak . Bagos For always (they do not want to install anything on their Squeaks) I got a 100% autonomous HTML that includes all the JavaScript code generated from Smalltalk (126Kb). The next steps in development, is to integrate widgets with Asteroid (Comet Implementation for Squeak) to implement an Observer Pattern (aka a MVC ) distributed between Squeak and Internet browsers .
Subscribe to:
Post Comments (Atom)
|
0 comments:
Post a Comment