This is a blog about Rebol, it's a fantastic free programming language, it permits easily to create complete software with few lines of code. It's cross-platform, so if you write it on Windows, it will work on Linux and Mac, and vice-versa. You can produce also wonderful GUI with just 3 lines of code!
Monday, 14 January 2013
Relative position of windows
You can impose the relative position of multiple windows, so if user move a window, the others will follow up.
Look the following example:
You can move the main window and the sub window will follow the main one, remaining at the relative positions.
Here is the source:
Title: "Linked Layout Demo"
Author: "Gregg Irwin"
Shows how to "link" layouts so when a main window moves, the
others stay in the same relative position to it.
] ; We need to set title to "" or REBOL will put it on the seconary ; windows--those with no title bar--as text. We need a title in ; the header for the library though. system/script/title:"" moved: true evt-func:func [face event][ if event/face = main-lay [ ;if event/type <> 'time [print event/type] switch event/type [ close [shutdown]
offset [moved: true]
resize [moved: true]
time [ if moved [ ; The -4x4 offset accounts for REBOL *not* accounting for ; border widths. lay-2/offset:-4x4+ main-lay/offset +topair!reduce [0 main-lay/size/y] lay-3/offset:-4x4+ main-lay/offset +topair!reduce [main-lay/size/x - lay-3/size/x main-lay/size/y ] lay-2/changes:lay-3/changes:'offset show [lay-2 lay-3] moved: false
] ifnotfind system/view/screen-face/feel/event-funcs :evt-func [insert-event-func:evt-func ] shutdown:does [unview/all] main-lay:layout [
h1 "main window" timer: sensor rate 0:0:1
] lay-2:layout [size 150x200 h2 "Sub-window 1"] lay-3:layout [size 200x150 h2 "Sub-winow 2"] view/new/options/offset main-lay [no-border resize] 100x100 view/new/options/offset lay-2 [no-title no-border resize] 100x200 view/new/options/offset lay-3 [no-title no-border resize] 300x200 do-events quit