r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!RebGUI] A lightweight alternative to VID

Graham
6-Oct-2007
[6848]
so, how to trigger the action?
Ashley
6-Oct-2007
[6849]
It should just work, I'll take a look at it later today.
Graham
6-Oct-2007
[6850x3]
table/set-row does a trigger on the action
so, there is some inconsistency
/select-row ?
Ashley
6-Oct-2007
[6853]
The action in that case is a by-product of the primary purpose ... 
select a row. select-item (radio-group) does tha same. I can't recall 
whether there's a select-state for check though.
Graham
6-Oct-2007
[6854]
I guess I should not put complicated code inside the action block 
... and just factor it all out.
Ashley
6-Oct-2007
[6855]
Depends, you can call action functions directly, as in:

	s: button "Save" [...]
	button "Do A then save" [... s/action/on-click s]
	button "Do B then save" [... s/action/on-click s]
Graham
7-Oct-2007
[6856x2]
rebol []

do %rebgui.r

pu: does [ display/parent "" [

 table 20x20 options [ multi "item" left .9 ] data [ "a" "b" "c" ] 
 return
	button "close" [ unview/only face/parent-face ] 
]]

display "test" [
	text "Try multi selecting with control" return
	button "test" [ pu ]
]

do-events
multi-select fails the second time round.
Ashley
7-Oct-2007
[6858x2]
Build#100 uploaded with fix to above problem.
The "set focus" problem cannot be fixed given the order of calls 
to 'show within the widget. The check trigger issue can be addressed 
with code similar to that given above for the save button sample.
Graham
8-Oct-2007
[6860x2]
Yep, fixed.
Is there a way to program a drop/edit-list to drop the list without 
having to click on it?
btiffin
8-Oct-2007
[6862]
Ashley;  Congrats on hiiting the RebGUI century mark.  Deserving 
of kudos.   Hip hip hooray!  :)
Ashley
8-Oct-2007
[6863]
Thanks.

Graham, how about something like:

	display "test" [
		d: drop-list data [1 2 3]
		button [d/pane/action/on-click d/pane]
	]
Graham
8-Oct-2007
[6864]
that works :)
Graham
11-Oct-2007
[6865]
Ashely, any way to get the caret appear at the click point of an 
area instead of always defaulting to the end of the text??
Ashley
11-Oct-2007
[6866]
Hmm, I'm sure it never used to do that ... I think a bug has been 
introduced along the way. Need to fix that one.
Graham
11-Oct-2007
[6867x2]
it has done this for as long as I can remember
Is there a way to tell a table to sort on a particular column?
Ashley
11-Oct-2007
[6869]
Sure.

display "" [

 t: table 60x40 #HW options ["ID" right .3 "Number" left .4 "Char" 
 center .3] data [
		1 "One"		a
		2 "Two"		b
		3 "Three"	c
		4 "Four"	d
		5 "Five"	e
		6 "Six"		f
		7 "Seven"	g
		8 "Eight"	h
		9 "Nine"	i
		10 "Ten"	j
	]
	button "ID" [t/pane/2/feel/engage t/pane/2 'down none]
	button "Number" [t/pane/4/feel/engage t/pane/4 'down none]
]

Not pretty, but it works.
Graham
11-Oct-2007
[6870x2]
what about refreshing the table data and keeping the existing sort 
in place?
I think if you use t/redraw it always defaults to no sort
Ashley
11-Oct-2007
[6872]
Build#101 uploaded with fix to caret problem. All widgets defined 
in behaviors/caret now focus on event/offset and only default to 
tail if focus change was not caused by a mouse click (i.e. tab or 
a manual set-focus).
Graham
18-Oct-2007
[6873]
Can area widgets take a background image?
Ashley
18-Oct-2007
[6874]
Most widgets, including area, can:

	b: load %a.png
	display "" [
		field %a.png effect [fit]
		area b effect [aspect]
	]
Graham
19-Oct-2007
[6875]
I should have guessed !
Louis
22-Oct-2007
[6876]
In the following script I would like to be able to click on a row 
of the table to populate the data entry fields, so that I can edit 
the data for the record displayed in that row. How do I do that? 
 

rebol []
do %sqlite.r
do %rebgui.r
unless value? 'ctx-rebgui [

    either exists? %rebgui-ctx.r [do %rebgui-ctx.r] [do %rebgui.r]
]
set-colors
tab-size: 120x55

fonts: reduce [font-sans-serif font-fixed font-serif "Courier New"]
if not exists? %id.txt [write %id.txt 1]
either not exists? %indodex.db [
    CONNECT/create %indodex.db

    SQL "create table base (ID, Title, Nama, Alamat, Kota, Propinsi, 
    Telefon, Handfon, Fax, Email, URL, Tgl_Nikah, Nota)"

    SQL "create table birthdays (ID, Nama, Jenis, Hubungan, Tgl_Lahir, 
    Agama, Nota)"
][
    CONNECT/flat %indodex.db
]

do show-cc: make function! [] [
set-colors
(i: to-integer read %id.txt)
label-width: 19
f-width: 59
display "IndoDex Ver. 1.0.1" compose/only [
            button-size 16x8
            margin 1x1
            space 1x1
            ;image %roladex.jpg 
            ;return
            label 7 "ID:" id: text (to-string i) 7
            pad 17
            ;label 13 "Nama:" 

            title: drop-list 30 #W "Pak" data ["Pak" "Ibu" "Sdr." "Sdri." "Drs." 
            "Dr." "Tuan" "Nyonya" "Nona" "Pdt."] 17x5
            nama: field f-width
            label label-width "Telefon:" 
            telefon: field f-width
            label label-width "Handfon:" 
            handfon: field f-width
            return
            pad 31
            label label-width "Fax:" 
            fax: fax: field f-width
            label label-width "E-Mail:" 
            email: field f-width
            label label-width "URL:" 
            url: field f-width
            return
            pad 31
            label label-width "Alamat:" 
            alamat: field f-width
            label label-width "Kota:"
            kota: field f-width
            label label-width "Propinsi:"
            propinsi: field f-width
            return
            pad 31
            label label-width "TglNikah:" 
            tgl_nikah: field f-width
            label label-width "Nota:" 
            nota: field 139
            return
            return

            t: table options ["ID" left .03 "Title" left .04 "Nama" left .2 "Telefon" 
            left .16 "Handfon" left .14 "Fax" left .14 "E-mail" left .15 "URL" 
            left .15] data (sql "select id, title, nama, telefon, handfon, fax, 
            email, url from base") 270x150 
            return
            button "Add" [
                either all [nama/text <> "" nama/text <> none][

                    SQL reduce ["insert into base values (?, ?, ?, ?, ?, ?, ?, ?, ?, 
                    ?, ?, ?, ?)" id/text title/text nama/text alamat/text kota/text propinsi/text 
                    telefon/text handfon/text fax/text email/text URL/text tgl_nikah/text 
                    nota/text]

                    insert t/data SQL "select id title nama alamat kota propinsi telefon 
                    handfon fax email URL tgl_nikah nota from base"

                    ;a: sql/flat "select id/text title/text nama/text alamat/text kota/text 
                    propinsi/text telefon/text handfon/text fax/text email/text URL/text 
                    tgl_nikah/text nota/text from base"
                    ;sql reduce [insert table/data a]
                    id/text: form i: i + 1
                    save %id.txt i
                    clear-text nama
                    clear-text alamat
                    clear-text kota
                    clear-text propinsi
                    clear-text telefon
                    clear-text handfon
                    clear-text fax
                    clear-text email
                    clear-text url
                    clear-text tgl_nikah
                    clear-text nota
                    ;show id
                    t/redraw
                    return
                ][
                    alert {Cannot save if "Nama" field is empty.}
                ]
            ]
            button "Update" []
            button "GUI Info" [

                print [id/text " " title/text " " nama/text " " alamat/text newline]
            ]
            button "DB Info" [
                print [TABLES newline]
                SQLite/col-info?: true
                newline
                print [SQL "select * from base" newline]
                print [SQLite/columns newline]
                print [ROWS "base" newline]
            ]
            button "Halt" [
                halt
            ]
            button "Quit" [
                quit
            ]
]
]
do-events
Graham
22-Oct-2007
[6877]
check out t/selected
Louis
23-Oct-2007
[6878]
Thanks, Graham. I'll check.
Graham
25-Oct-2007
[6879x5]
I'm putting in some background text as an image as a prompt to users, 
but it would be nice to clear the background image as soon as the 
user click types anything like those search fields in browsers
like this   field effect (to-image layout/tight [ backdrop white 
text "enter search term" ] font-color 230.230.230 ) [ aspect ]
I'm sure there's a native rebgui way of doing this rather than using 
'layout !
(to-image layout/tight [ backdrop white text "enter search term" 
 font-color 230.230.230 ] )
and have it restored when we clear the field
Ashley
25-Oct-2007
[6884]
How about:


 field %a.png effect [fit] on-focus [face/image: none true] on-unfocus 
 [face/image: load %a.png true]
Graham
25-Oct-2007
[6885]
Looks logical - I'll give it a go.
Graham
26-Oct-2007
[6886]
It's getting a bit awkward now .. I have to set the image at startup, 
restore it on an unfocus event, and then restore it again if I clear 
the field.

I think I need to store the image in the field itself .. perhaps 
as a new type of field widget
JohanAR
30-Oct-2007
[6887]
How come things I create end up four times the size I specify?
button "Test" 10x10 maroon [print face/size]
prints 40x40 when I click it...
btiffin
30-Oct-2007
[6888]
Johan;  RebGUI doesn't use pixels (well it does, but ...)  It uses 
a unit-size that can be set with the request-ui function.

See http://www.dobeash.com/RebGUI/user-guide.html#section-3.3for 
some details.
JohanAR
30-Oct-2007
[6889x2]
Sounds reasonable :) Is there any way to circumvent this for items 
that need a specific pixel size, in my case a picture?
And a related question.. Is it possible to resize the window when 
my picture is changed, so that the new picture doesn't get resized 
to the previous one's size?
btiffin
30-Oct-2007
[6891]
Well, RebGUI allows for widget design but that can seem complicated 
at first.  Another method is judicious use of the span attributes 
and surrounding widgets with box elements set up like elastic widgets 
that will take/give all the space during a resize.


Or wait till Ashley reads this and responds as he always has the 
best and simplest advice.  :)
Graham
30-Oct-2007
[6892x2]
Is there a way for 'display to just return the layout without viewing 
?
like display/only ...
btiffin
30-Oct-2007
[6894]
Umm...check ctx-rebgui/layout  but the source for display does some 
other nifty things other than just create the face.
Graham
30-Oct-2007
[6895x2]
Is there a way to set a backdrop to a display?
I tried setting lo/pane/1/image but that sets the image to the first 
widget in the layout
Ashley
31-Oct-2007
[6897]
display "" [