Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Dynamic resizing question

 [1/4] from: swhite::ci::bloomington::mn::us at: 3-Feb-2006 10:33


Dear REBOL list, After some years and a change of management, I have permission to purchase the SDK and do an official, if small, REBOL project. So I am trying to remember how to use REBOL, am getting started on a test project as a warm-up, and have run into the following question: I am trying to make a little program for several people to use, and one of them is visually impaired, so I want to put a button on the screen that will make everything on the screen bigger (small, medium, large). I have gotten started, and can make the screen, the buttons, and the button text change size. BUT, in the test script below, if I make buttons larger, they start to overlap adjacent buttons because I can't figure out how to make the spacing between the buttons larger. And that is the question. I thought that I would be able to change tab stops, and three lines in the script commented out with ";;test" show that attempt, but the "/tabs" path on a layout seems to be not allowed. Am I doing it wrong, or is there another way? Thank you. The script below, if cut and pasted into a text file, should run and show the situation. ----------- REBOL [ ] ;; This is a test script to show how to change the size of ;; a window, with all the stuff on it, in response to a ;; choice button that gives the choice of "small," "medium," ;; or "large." ;; ;; Comment lines markes with ;;test, when un-commented, will ;; cause the script to fail, and are the source of the ;; current question. ;; Define sizes SIZE-SCREEN-SMALL: 640X480 SIZE-SCREEN-MEDIUM: 800X600 SIZE-SCREEN-LARGE: 1024X768 SIZE-BUTTON-SMALL: 60X20 SIZE-BUTTON-MEDIUM: 100X40 SIZE-BUTTON-LARGE: 140X60 SIZE-TEXT-SMALL: 12 SIZE-TEXT-MEDIUM: 16 SIZE-TEXT-LARGE: 24 SIZE-TABS-SMALL: 70 SIZE-TABS-MEDIUM: 110 SIZE-TABS-LARGE: 150 ;; Set default sizes SIZE-SCREEN: SIZE-SCREEN-SMALL SIZE-BUTTON: SIZE-BUTTON-SMALL SIZE-TEXT: SIZE-TEXT-SMALL SIZE-TABS: SIZE-TABS-SMALL ;; These are functions to set the size variables to ;; small, medium, or large SET-TO-SMALL: does [ SIZE-SCREEN: SIZE-SCREEN-SMALL SIZE-BUTTON: SIZE-BUTTON-SMALL SIZE-TEXT: SIZE-TEXT-SMALL SIZE-TABS: SIZE-TABS-SMALL ] SET-TO-MEDIUM: does [ SIZE-SCREEN: SIZE-SCREEN-MEDIUM SIZE-BUTTON: SIZE-BUTTON-MEDIUM SIZE-TEXT: SIZE-TEXT-MEDIUM SIZE-TABS: SIZE-TABS-MEDIUM ] SET-TO-LARGE: does [ SIZE-SCREEN: SIZE-SCREEN-LARGE SIZE-BUTTON: SIZE-BUTTON-LARGE SIZE-TEXT: SIZE-TEXT-LARGE SIZE-TABS: SIZE-TABS-LARGE ] ;; This is a procedure to apply the settings to the ;; MAIN-WINDOW APPLY-SETTINGS: does [ MAIN-WINDOW/size: SIZE-SCREEN MAIN-CHOICE/size: SIZE-BUTTON MAIN-CHOICE/font/size: SIZE-TEXT MAIN-QUIT/size: SIZE-BUTTON MAIN-QUIT/font/size: SIZE-TEXT ;;test MAIN-WINDOW/tabs: SIZE-TABS ;; error will be on the line above, setting MAIN-WINDOW/tabs ] ;; This is the procedure performed when the choice button ;; is pressed. EX-CHOICE-BUTTON: does [ if = MAIN-CHOICE/text "small" [ SET-TO-SMALL APPLY-SETTINGS view MAIN-WINDOW ] if = MAIN-CHOICE/text "medium" [ SET-TO-MEDIUM APPLY-SETTINGS view MAIN-WINDOW ] if = MAIN-CHOICE/text "large" [ SET-TO-LARGE APPLY-SETTINGS view MAIN-WINDOW ] ] ;; Define the main (only) screen MAIN-WINDOW: layout [ size SIZE-SCREEN ;;test tabs SIZE-TABS origin 10x10 across MAIN-CHOICE: choice SIZE-BUTTON font [size SIZE-TEXT] "small" "medium" "large" [EX-CHOICE-BUTTON] ;;test tab MAIN-QUIT: button SIZE-BUTTON font [size SIZE-TEXT] "Quit" [quit] ] ;; Run the program view MAIN-WINDOW

 [2/4] from: alberto:origen:mx at: 3-Feb-2006 13:21


The word 'tabs is not part of graphic objects (faces) is just a command of the layout dialect If you don't want to regenerate the whole window every time is resized, you can change the 'offset field of the buttons to indicate it's new location inside the main face. something like: MAIN-CHOICE/offset: MAIN-CHOICE-LARGE-OFFSET or whatever. alberto -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

 [3/4] from: volker:nitsch:gma:il at: 3-Feb-2006 21:12


On 2/3/06, Alberto <alberto-origen.com.mx> wrote:
> The word 'tabs is not part of graphic objects (faces) > is just a command of the layout dialect
<<quoted lines omitted: 4>>
> MAIN-CHOICE/offset: MAIN-CHOICE-LARGE-OFFSET > or whatever.
And if regenerating the window is no problem, you can do this: REBOL[title: "launched by sync"] layo: [ style butn button button-sz font-size font-sz butn "normal" [scale 1 view layout layo] butn "big" [scale 2 view layout layo] butn "very big" [scale 4 view layout layo] ] butn-style: get-style 'button scale: func[scale][ button-sz: scale * butn-style/size font-sz: scale * butn-style/font/size ] scale 1 view layout layo
> alberto > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [4/4] from: carl::cybercraft::co::nz at: 4-Feb-2006 10:54


Hi Steven, I think you can't alter the TABS value because it's not stored in the layout object, unlike SIZE. It's just used for the placement of faces when the layout is first created. (That's off the top of my head, so it's just possible I'm wrong about this.) The position of each face is stored in the OFFSET pair of each face, so that's what you'd have to change to move the buttons. Anyway, this got me thinking, and I came up with a function for re-sizing a layout. It needs work though, as more complex styles (such as TEXT-LIST) would need to be gone deeper into to re-size all of the faces within them. However, I think you'd have to do the same with your approach too, so it's just a general problem with some styles. So, for what it's worth, here's the function I came up with. (Sorry it's not commented. Do ask if there's anything you don't understand.) ... REBOL [ ] scale-lo: func [ lo [object!] scale [number!] ][ foreach pane lo/pane [ if none? pane/user-data [ pane/user-data: reduce [ 'size pane/size 'offset pane/offset 'font make pane/font [] ] ] pane/size: pane/user-data/size * scale pane/offset: pane/user-data/offset * scale pane/font: make pane/user-data/font [ size: to-integer pane/user-data/font/size * scale ] ] if none? lo/user-data [ lo/user-data: reduce [ 'size lo/size ] ] lo/size: lo/user-data/size * scale show lo ] test-lo: layout [ across button "Button 1" button "Button 2" return button "Wide Button" 210 return area wrap 100x100 "The rain in Spain falls mainly on the plain." text-list 100x100 "A" "B" "C" "D" "E" "F" return button "Normal" [scale-lo test-lo 1] button "Times 1.5" [scale-lo test-lo 1.5] button "Times 2" [scale-lo test-lo 2] button "Times 3" [scale-lo test-lo 3] ] view test-lo

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted