Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: A Rebol application with multiple GUIs (or Views)
Pages: [1] Print
Author Topic: A Rebol application with multiple GUIs (or Views)  (Read 782 times)
jfdutcher
Jr. Member
**
Offline Offline

Posts: 95


View Profile
A Rebol application with multiple GUIs (or Views)
« on: February 27, 2007, 08:14:02 PM »

I have historically used CGI and HTML to dialog with a user via a GUI interface.

In these cases each new 'screen' or 'view' or 'interface' was a separate HTML page
or a separate script which created a separate page.

I'm starting down the same road with rebol....whenever I need a new 'view' or GUI I pass some args and 'do'  another Rebol script which has in it another new 'view' etc.

Is this  a satisfactory approach....or do those who know what they are about try and have many views in one script.....'showing' and 'hiding' them as needed...and kind of winding up with a whole application in a script  ?? 
Logged
Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: A Rebol application with multiple GUIs (or Views)
« Reply #1 on: February 28, 2007, 12:52:33 AM »

The latter I think.
Logged

notchent
Newbie
*
Offline Offline

Posts: 40


View Profile WWW
Re: A Rebol application with multiple GUIs (or Views)
« Reply #2 on: February 28, 2007, 07:43:53 AM »

I like to keep everything in one script.  Use a conditional evaluation (if, switch, etc.) to check the value submitted to the script, and then print the appropriate forms based on what's been submitted:

    selection: decode-cgi system/options/cgi/query-string
    if selection/2 = (value from first form)  [...print a page base on that value ...]
    if selection/2 = (value from second form)  [...print a page base on that value ...]
    if selection/2 <> none [ ...print an error page... ]
    [ ...print your initial page... ]

Take a look at http://musiclessonz.com/rebol.html#section-6.5 (the second to last example in that section has an example of this).

- Nick Antonaccio
Logged

Anton
Jr. Member
**
Offline Offline

Posts: 65

Rebol veteran


View Profile WWW
Re: A Rebol application with multiple GUIs (or Views)
« Reply #3 on: March 01, 2007, 03:39:01 AM »

Hi, it's a bit unclear to me what you want to do.
Do you want to convert an existing cgi+html set of dialogs to rebol ?
ie. Is it a requirement that users running your program from the web and running it directly from their OS desktop should see as similar a set of views as possible ?

Or, are you just wondering what the best way to make a GUI in an application is ?
I can try to answer this last question.
Rebol/View can open one or multiple windows simultaneously. These appear as normal windows in the OS desktop.

Open a single window:

    view layout [button "hello"] ; waits for events - returns when window closed

Open a single window, another way:

    view/new layout [button "hello"] ; open a window without waiting for events
    do-events ; starts waiting for events - returns when all windows are closed

Open two windows:

    view/new window1: layout [text "This is window #1"]
    view/new window2: layout/offset [field "This is window #2"] 100x200
    do-events ; wait for events - returns when all windows are closed

Open one window and when it is closed, open a second:

    view window1: layout [text "This is window #1"]
    view window2: layout/offset [field "This is window #2"] 100x200

Open a main window which can open a "child" window:

    view layout [
        text "This is the main window"
        button "open child" [
            view/new center-face layout [text "I am the child window"]
        ]
    ]

So, in the above BUTTON's action block, using VIEW with the /NEW refinement avoids waiting for events a second time, as the wait loop is already running. (The button's action block is only done because the wait loop sends mouse click events to the button's feel, which then does the action block. Hence, WAIT is doing the action, and there is no need to WAIT again.)

It's also possible to use buttons to select different panels:

    details-panel: layout [
        title "details"
        check-line "apples"
        check-line "oranges"
    ]
       
    prefs-panel: layout [
        title "prefs"
        across
        label 100 "username:" field return
        label 100 "password:" field hide return
    ]

    view layout [
        button "details" [
            my-panel/pane: details-panel/pane
            show my-panel
        ]
        button "prefs" [
            my-panel/pane: prefs-panel/pane
            show my-panel
        ]
        return
        my-panel: box (2x2 + max prefs-panel/size details-panel/size) edge [size: 1x1 color: black] []
    ]

p.s. To understand the difference between VIEW and VIEW/NEW, check the source of the VIEW function:

    >> source view
Logged
Pages: [1] Print 
Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: A Rebol application with multiple GUIs (or Views)
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 29, 2008, 02:27:47 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2234 Posts in 582 Topics by 1745 Members
Latest Member: vectlycle

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc