root/tour.r

Revision 117, 17.6 kB (checked in by ashley, 6 weeks ago)

Fixed remaining look & feel issues
Updated RebDOC.r and tour.r

Line 
1REBOL [
2        Title:          "RebGUI widget tour"
3        Owner:          "Ashley G. Trüter"
4        Purpose:        "Demonstrates all stable RebGUI widgets in action."
5        History: {
6                14      Renamed Picture category to Graphic
7                        Added pie-chart under 'Graphic'
8                16      do %rebgui-ctx.r before %rebgui.r
9                        Removed word / path parenthesis that are no longer needed
10                17      Removed compose/deep/only
11                        Removed several inline () from data blocks
12                25      Reinstated include
13                40      Added colors/button
14                        Build# now appears in title
15                48      Added input-grid and panel to demo
16                49      Added spinner widget
17                51      Replaced appearance settings with request-ui
18                52      Minor testing changes
19                53      New button changes
20                60      Fixes for new default button size
21                62      Added menu widget and request-menu
22                63      Added link widget
23                65      Cleaned up comments
24                        Removed input-grid and recoded splash call
25                68      Fixed drop-list/tuple problems
26                69      Added symbol & calendar & tooltip widgets
27                71      Minor update to requestor example code
28                72      Added request-spellcheck
29                74      Updated timer action
30                75      Widget Ref uses new examine func
31                76      Rewrote func-help
32                78      Added chat widget
33                83      Added request-progress
34                86      Spelling error corrected (Graham)
35                95      Added request-char
36                107     Added tree widget and 'up and 'down symbols
37                108     Added scroll-panel
38                        Added sheet
39                110     Removed "Functions" tab (now incorporated into RebDOC)
40                112     Added heading and pill
41                117     Moved configure to bottom of screen
42                        Added call to RebDOC
43        }
44]
45
46do %rebgui.r
47
48;       show splash screen
49
50splash %images/logo.png
51
52;       compose pie-chart data
53
54pie-data: compose [
55        "Red" red 1
56        "Red-Green" (red + green) 1
57        "Green" green 1
58        "Green-Blue" (green + blue) 1
59        "Blue" blue 1
60        "Blue-Red" (blue + red) 1
61]
62
63;       wrap display in a func so it can be called by request-ui
64
65do show-tour: make function! [] [
66
67display rejoin ["Widget Tour (build#" ctx-rebgui/build ")"] [
68        image %images/logo.png tip "RebGUI logo"
69        return
70        tab-panel #HW data [
71                "Static" [
72                        text "These widgets don't directly react to mouse events."
73                        return
74                        tab-panel #LVHW data [
75                                "Title-Group" [
76                                        tight
77                                        tg: title-group %images/setup.png #LHW data "RebGUI Widget Tour" {This script demonstrates groups of RebGUI widgets, each in a separate tab preceded by a brief explanation. The explanatory text is followed by a tab-panel showing each widget in alphabetical order.^/^/If you want to experiment with the look & feel of RebGUI then click the button marked as such above these tabs, make your changes, then click "Save" to see them take effect. Note that clicking "Save" will create a file named %ui.dat which will be loaded whenever you run RebGUI.}
78                                ]
79                                "Bar" [
80                                        text "Some text above a bar."
81                                        return
82                                        bar
83                                        return
84                                        text "Some text below a bar."
85                                ]
86                                "Box" [
87                                        box 20x20 red #HW
88                                        box 20x20 green #HWX
89                                        return
90                                        box 20x20 blue #WY
91                                        box 20x20 yellow #WXY
92                                ]
93                                "Chat" [
94                                        ex-chat: chat 150x50 #HW options [limit 10] data [
95                                                "Graham" leaf "A chat widget would be good." red 14-Apr-2007/12:42:55
96                                                "Ashley" purple "Something like AltME?" none 15-May-2007/9:23:04
97                                                "Graham" leaf "Yes, and it must have:^/^/Multi-line support." none 15-May-2007/10:33:42
98                                                "Ashley" purple "And:^/^/^-Tabs?" none 15-May-2007/11:01:34
99                                                "Ashley" purple "I'll see what I can do." yello 15-May-2007/11:05:20
100                                        ]
101                                        return
102                                        group-box "Controls" #Y data [
103                                                button-size 25
104                                                button "Submit"                 [ex-chat/append-message "Demo" none ex-chat-area/text none to date! reform [now/date now/time]]
105                                                ex-chat-area: area #V 75x6 "Type your message here."
106                                                after 1
107                                                button "Set User color" [ex-chat/set-user-color ex-chat/rows blue]
108                                                button "Set Msg text"   [ex-chat/set-message-text ex-chat/rows form now/time/precise]
109                                                button "Set Msg color"  [ex-chat/set-message-color ex-chat/rows yello]
110                                        ]
111                                ]
112                                "Heading" [
113                                        heading "This is a heading."
114                                        return
115                                        text "Heading is derived from text, but twice the size."
116                                ]
117                                "Label" [
118                                        label "This is a label."
119                                        return
120                                        text "Label is derived from text, but bold."
121                                ]
122                                "Pill" [
123                                        pill 20x20 red #HW
124                                        pill 20x20 green #HWX
125                                        return
126                                        pill 20x20 blue #WY
127                                        pill 20x20 yellow #WXY
128                                ]
129                                "Progress" [
130                                        after 1
131                                        text "This is a progress bar."
132                                        ex-progress: progress
133                                        text "This slider lets you set it."
134                                        slider 50x5 options [ratio .05] [set-data ex-progress face/data]
135                                ]
136                                "Text" [
137                                        text-size 40
138                                        after 2
139                                        text "text"
140                                        text "This is some text."
141                                        text "text text-color blue"
142                                        text "This is some blue text." text-color blue
143                                        text "text bold"
144                                        text "This is some bold text." bold
145                                        text "text italic"
146                                        text "This is some italic text." italic
147                                        text "text underline"
148                                        text "This is some underline text." underline
149                                ]
150                                "Tooltip" [
151                                        tooltip 40x-1 {This is a "static" tooltip, probably not very useful outside of its intended [dynamic] role; but might be handy for displays where a constant reminder/help bubble is required.}
152                                ]
153                        ]
154                ]
155                "Field" [
156                        text "These widgets use the edit/feel to process keystrokes."
157                        return
158                        tab-panel #LVHW data [
159                                "Area" [
160                                        text "Click in the area below then press Ctrl+S to spellcheck it."
161                                        return
162                                        area #L "Tge big bad wolf.^/Heere is a secownd line of text."
163                                        return
164                                        text "You may want to install a dictionary from here:"
165                                        link "www.dobeash.com/RebGUI/dictionary/"
166                                        return
167                                        text 80 #L "The dictionary file needs to be unzipped and placed in the %dictionary/ directory, and the %locale.dat file must have its 'language set to the same name."
168                                ]
169                                "Field" [
170                                        after 1
171                                        field "Some text."
172                                        field "Some more text."
173                                        text "Edit the above text then use Ctrl-Z and / or Esc to restore it."
174                                ]
175                                "Password" [
176                                        after 1
177                                        field "Some text." font [size: to integer! ctx-rebgui/sizes/font * 1.5 name: font-fixed]
178                                        password "Some text."
179                                        password "Some text."
180                                ]
181                                "Spinner" [
182                                        text "Top arrow to increment, bottom arrow to decrement."
183                                        return
184                                        after 2
185                                        text 20 "Default"       spinner
186                                        text 20 "Money"         spinner options [$0 $10 $1] data $5
187                                        text 20 "Decimal"       spinner options [0.0 1.0 .1]
188                                        text 20 "Char"          spinner options [#"A" #"Z" 1]
189                                        text 20 "Time"          spinner options [9:00 18:00 0:30]
190                                        tooltip 100 "Note that you can also use the mouse scroll-wheel to increment/decrement. Doing this while Ctrl is held will increment/decrement to the max/min value."
191                                ]
192                        ]
193                ]
194                "Click" [
195                        text "These widgets react to a mouse click."
196                        return
197                        tab-panel #LVHW data [
198                                "Arrow" [
199                                        arrow data 'up
200                                        arrow data 'down
201                                        arrow data 'left
202                                        arrow data 'right
203                                        return
204                                        arrow 25 data 'up
205                                        arrow 25 data 'down
206                                        arrow 25 data 'left
207                                        arrow 25 data 'right
208                                ]
209                                "Button" [
210                                        button "Info" options [info]
211                                        button "Red" red text-color white
212                                        button "Green" green
213                                        button "Blue" blue text-color white
214                                        button "Yellow" yellow
215                                        button "White" white
216                                        return
217                                        button 75x25 "Big Button" #HW
218                                ]
219                                "Link" [
220                                        text-size 25
221                                        after 2
222                                        text "Default link"     link
223                                        text "URL"                      link http://www.dobeash.com
224                                        text "Text & URL"       link "RebGUI" http://www.dobeash.com/rebgui
225                                ]
226                                "Slider" [
227                                        space 0x0
228                                        ex-slider: box 25x25 red
229                                        pad 25
230                                        slider 5x50 data .5 [ex-slider/size/y: max ctx-rebgui/sizes/cell to integer! face/data * face/size/y show ex-slider]
231                                        return
232                                        slider 50x5 data .5 options [arrows] [ex-slider/size/x: max ctx-rebgui/sizes/cell to integer! face/data * face/size/x show ex-slider]
233                                ]
234                                "Symbol" [
235                                        text "These symbols use the Webdings font, otherwise default ASCII character graphics."
236                                        return
237                                        symbol data 'start
238                                        symbol data 'rewind
239                                        symbol data 'left
240                                        symbol data 'pause
241                                        symbol data 'stop
242                                        symbol data 'record
243                                        symbol data 'right
244                                        symbol data 'forward
245                                        symbol data 'end
246                                        symbol data 'up
247                                        symbol data 'down
248                                        return
249                                        symbol 10 data 'start
250                                        symbol 10 data 'rewind
251                                        symbol 10 data 'left
252                                        symbol 10 data 'pause
253                                        symbol 10 data 'stop
254                                        symbol 10 data 'record
255                                        symbol 10 data 'right
256                                        symbol 10 data 'forward
257                                        symbol 10 data 'end
258                                        symbol 10 data 'up
259                                        symbol 10 #HW data 'down
260                                        return
261                                        text "The symbol widget also accepts text and scales it to the height of the widget."
262                                        return
263                                        symbol -1 "Some text"
264                                        return
265                                        symbol -1x10 "Some text"
266                                        return
267                                ]
268                        ]
269                ]
270                "List" [
271                        text "These widgets show column(s) of values from which row(s) can be selected."
272                        return
273                        tab-panel #LVHW data [
274                                "Calendar" [
275                                        calendar [set-text ex-status face/data]
276                                        text 40x-1 #L "The calendar widget is also used by the request-date function."
277                                ]
278                                "Drop-List" [
279                                        drop-list "Black" data ["Red" "Green" "Blue"] [set-color ex-drop-list get to word! face/text]
280                                        ex-drop-list: box 20x20 black
281                                ]
282                                "Edit-List" [
283                                        edit-list "Black" data ["Red" "Green" "Blue"] [set-color ex-edit-list attempt [get to word! face/text]]
284                                        ex-edit-list: box 20x20 black
285                                ]
286                                "Sheet" [
287                                        ex-sheet: sheet data [A1 1 A2 2 A3 "=A1 + A2"] options [size 4x4]
288                                        return
289                                        button "Load" [ex-sheet/load-data to block! ex-sheet-field/text]
290                                        button "Save" [ex-sheet/save-data set-text ex-sheet-field mold/only ex-sheet/data]
291                                        ex-sheet-field: field 50 {A1 2 B1 2 C1 "=A1 + B1"}
292                                ]
293                                "Table" [
294                                        ex-table: table 60x40 #HW options ["ID" right .3 "Number" left .4 "Char" center .3] data [
295                                                1 "One"         a
296                                                2 "Two"         b
297                                                3 "Three"       c
298                                                4 "Four"        d
299                                                5 "Five"        e
300                                                6 "Six"         f
301                                                7 "Seven"       g
302                                                8 "Eight"       h
303                                                9 "Nine"        i
304                                                10 "Ten"        j
305                                        ]
306                                        text 40 #LX {Note: Clicking on a column label will sort that column, while dragging a divider will resize the columns before and after it.}
307                                        return
308                                        button "Single" #Y [
309                                                either find ex-table/options 'multi [
310                                                        remove find ex-table/options 'multi
311                                                ][
312                                                        insert tail ex-table/options 'multi
313                                                ]
314                                                face/text: pick ["Multi" "Single"] either find ex-table/options 'multi [true] [false]
315                                                show face
316                                        ]
317                                        button "Add Row" #Y [
318                                                insert tail ex-table/data reduce [random 100 form now/time random #"Z"]
319                                                ex-table/redraw
320                                        ]
321                                ]
322                                "Text-List" [
323                                        label 15 "Month"
324                                        ex-text-list-text: text 50
325                                        return
326                                        label 15 "Months"
327                                        ex-text-list: text-list 60x40 #HW data system/locale/months [
328                                                set-text ex-text-list-text face/selected
329                                        ]
330                                        text 40 #LX {Note: "Single" allows one row at a time to be selected, whilst "Multi" supports multi-row selection via Ctrl+click, Shift+click and Ctrl+A keystrokes.}
331                                        return
332                                        button "Single" #Y [
333                                                either find ex-text-list/options 'multi [
334                                                        remove find ex-text-list/options 'multi
335                                                ][
336                                                        insert tail ex-text-list/options 'multi
337                                                ]
338                                                face/text: pick ["Multi" "Single"] either find ex-text-list/options 'multi [true] [false]
339                                                show face
340                                        ]
341                                        button "Add Row" #Y [
342                                                insert tail ex-text-list/data form now/time/precise
343                                                ex-text-list/redraw
344                                        ]
345                                ]
346                                "Tree" [
347                                        text 50 "This tree returns face/text when clicked."
348                                        text 50 "This tree has options [expand] and returns face/data when clicked."
349                                        return
350                                        tree 50x25 data ["Pets" ["Cat" "Dog"] "Numbers" [1 2 3]] [
351                                                set-text ex-tree-text face/text
352                                        ]
353                                        scroll-panel 50x25 data [
354                                                tree data ["Pets" ["Cat" "Dog"] "Numbers" [1 2 3]] options [resize expand] [
355                                                        set-text ex-tree-text mold face/data
356                                                ]
357                                        ]
358                                        return
359                                        ex-tree-text: text 100
360                                ]
361                        ]
362                ]
363                "State" [
364                        text "These widgets have two (on & off) or three (true, false & none) states."
365                        return
366                        tab-panel #LVHW data [
367                                "Check" [
368                                        after 1
369                                        check "A check option" data true
370                                        check "with options [info]" options [info] data false
371                                        text "Note: A tristate widget toggled by left and right mouse clicks."
372                                ]
373                                "Check-Group" [
374                                        text "Vertical alignment"
375                                        return
376                                        check-group 30 data ["Item 1" true "Item 2" false "Item 3" none]
377                                        return
378                                        text 40 "Horizontal alignment"
379                                        check-group 60x5 data ["Item 1" true "Item 2" false "Item 3" none]
380                                        return
381                                        text 40 "with options [info]"
382                                        check-group 60x5 options [info] data ["Item 1" true "Item 2" false "Item 3" none]
383                                ]
384                                "LED" [
385                                        ex-led: led "A simple LED"
386                                        return
387                                        button "True"   [set-data ex-led true]
388                                        button "False"  [set-data ex-led false]
389                                        button "None"   [set-data ex-led none]
390                                ]
391                                "LED-Group" [
392                                        text "Vertical alignment"
393                                        return
394                                        led-group 30 data ["Item 1" true "Item 2" false "Item 3" none]
395                                        return
396                                        text "Horizontal alignment"
397                                        return
398                                        ex-led-group: led-group 60x5 data ["Item 1" true "Item 2" false "Item 3" none]
399                                        return
400                                        button 20 "Random" [
401                                                repeat i 3 [
402                                                        poke ex-led-group/data i random/only reduce [true false none]
403                                                ]
404                                                show ex-led-group
405                                        ]
406                                ]
407                                "Radio-Group" [
408                                        after 1
409                                        text "Vertical alignment"
410                                        radio-group 30 data ["Item 1" "Item 2" "Item 3"]
411                                        text "Horizontal alignment"
412                                        radio-group 60x5 data [none "Item 1" "Item 2" "Item 3"]
413                                        text "Horizontal alignment (with default)"
414                                        r: radio-group 60x5 data [1 "Item 1" "Item 2" "Item 3"]
415                                        button "Random" [r/select-item random 3]
416                                ]
417                        ]
418                ]
419                "Graphic" [
420                        text "These widgets display one or more images."
421                        return
422                        tab-panel #LVHW data [
423                                "Anim" [
424                                        anim data [%images/go-previous.png %images/go-next.png]
425                                ]
426                                "Image" [
427                                        image %images/setup.png
428                                        image 50x50 %images/go-next.png
429                                ]
430                                "Pie-Chart" [
431                                        text 40 "Note that the pie-chart is scalable, change window size to see this."
432                                        tab-panel #HW data [
433                                                "no-label"      [pie-chart 60x60 #HW options [no-label] data pie-data]
434                                                "Default"       [pie-chart 60x60 #HW data pie-data]
435                                                "start"         [pie-chart 60x60 #HW options [start -30] data pie-data]
436                                                "explode"       [pie-chart 60x60 #HW options [start -30 explode 10] data pie-data]
437                                        ]
438                                ]
439                        ]
440                ]
441                "Grouping" [
442                        text "These widgets are used to group other widgets."
443                        return
444                        tab-panel #LVHW data [
445                                "Group-Box" [
446                                        group-box "A group of widgets" #W data [
447                                                after 2
448                                                text 20 #W "Gender"
449                                                drop-list 30 #W "Male" data ["Male" "Female"]
450                                                text 20 "Name"
451                                                field #W 30
452                                                text 20 "Password"
453                                                password #W 30 "RebGUI"
454                                        ]
455                                ]
456                                "Menu" [
457                                        tight
458                                        after 1
459                                        menu #LW data [
460                                                "Color" [
461                                                        "Red"           [ex-menu/font/color: red                show ex-menu]
462                                                        "Green"         [ex-menu/font/color: green              show ex-menu]
463                                                        "Blue"          [ex-menu/font/color: blue               show ex-menu]
464                                                        "Black"         [ex-menu/font/color: black              show ex-menu]
465                                                ]
466                                                "Align" [
467                                                        "Left"          [ex-menu/font/align: 'left              show ex-menu]
468                                                        "Center"        [ex-menu/font/align: 'center    show ex-menu]
469                                                        "Right"         [ex-menu/font/align: 'right             show ex-menu]
470                                                ]
471                                                "Style" [
472                                                        "Normal"        [ex-menu/font/style: none               show ex-menu]
473                                                        "Bold"          [ex-menu/font/style: 'bold              show ex-menu]
474                                                        "Italic"        [ex-menu/font/style: 'italic    show ex-menu]
475                                                        "Underline"     [ex-menu/font/style: 'underline show ex-menu]
476                                                ]
477                                        ]
478                                        ex-menu: text #LVHW white "Sample" 100x40 font [align: 'center valign: 'middle size: 36]
479                                ]
480                                "Panel" [
481                                        panel #W sky data [
482                                                after 2
483                                                text 20 #W "Gender"
484                                                drop-list 30 #W "Male" data ["Male" "Female"]
485                                                text 20 "Name"
486                                                field #W 30
487                                                text 20 "Password"
488                                                password #W 30 "RebGUI"
489                                        ]
490                                ]
491                                "Scroll-Panel"  [
492                                        scroll-panel data [sheet]
493                                        scroll-panel data [image %images/logo.png]
494                                ]
495                                "Splitter"      [
496                                        space 0x0
497                                        text 41x15 tan "Some text above a splitter."
498                                        return
499                                        splitter 41x1
500                                        return
501                                        text 41x15 tan "Some text below a splitter."
502                                        at 43x0
503                                        text 20x31 wheat "Some text before a splitter."
504                                        splitter 1x31
505                                        text 20x31 wheat "Some text after a splitter."
506                                ]
507                                "Tab-Panel"     [
508                                        tab-panel #HW data [
509                                                "Static" [text (form now/time/precise)]
510                                                action [
511                                                        face/color: get random/only system/locale/colors
512                                                        face/pane/1/text: form now/time/precise
513                                                ]
514                                                "Dynamic" [text 40]
515                                        ]
516                                ]
517                                "Tool-Bar" [
518                                        tight
519                                        tool-bar #LW data [
520                                                "Open"          %images/document-open.png       [
521                                                        if var: request-file/only [set-text ex-status to-local-file var]
522                                                ]
523                                                "Save"          %images/document-save.png       [set-text ex-status "Save"]
524                                                "Print"         %images/document-print.png      [set-text ex-status "Print"]
525                                                pad 2 none
526                                                "Home"          %images/go-first.png            [set-text ex-status "Home"]
527                                                "Back"          %images/go-previous.png         [set-text ex-status "Back"]
528                                                "Forward"       %images/go-next.png                     [set-text ex-status "Forward"]
529                                                "End"           %images/go-last.png                     [set-text ex-status "End"]
530                                        ]
531                                ]
532                        ]
533                ]
534        ]
535        reverse
536        button #XY "Close" [quit]
537        button #XY 25 "RebDOC" [unview/all do %RebDOC.r]
538        button #XY 25 "Look & Feel" [if request-ui [unview/all show-tour]]
539        ex-status: text black 95 #WY data ["|" "/" "--" "\"] font [color: green] rate 1 feel [
540                engage: make function! [face act event] [
541                        all [event/type = 'time face/action/on-click face]
542                ]
543        ][
544                set-text face reform [
545                        either ctx-rebgui/edit/insert? ["INS"]["OVR"]
546                        to integer! system/stats / 1024
547                        "KB's used ..."
548                        first face/data
549                ]
550                face/data: next face/data
551                if tail? face/data [face/data: head face/data]
552                recycle
553        ] tip "RebGUI stats"
554]
555
556]
557
558do-events
Note: See TracBrowser for help on using the browser.