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

World: r3wp

[!RebGUI] A lightweight alternative to VID

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
[6897x3]
display "" [
button 10x10
	do [face/image: my-image face/effect: 'fit]
]
Is there a way for 'display to just return the layout without viewing?
 a: ctx-rebgui/layout/only [button 10x10]
Graham
31-Oct-2007
[6900]
what's the code for the layout backdrop?
Ashley
31-Oct-2007
[6901x2]
 Is there any way to circumvent this for items that need a specific 
 pixel size, in my case a picture?

 image defaults to size -1x-1 which means *not* specifying a size 
 will default it to the image size.


 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?
 This should get you going:

	display "" [
		button [face/parent-face/size: 320x240 show face/parent-face]
	]


Note that in this case the size *is* in pixels as you are modifying 
a face object directly (as opposed to specifying a wudget's *unit* 
size). Hope that helps.
code for the layout backdrop?
 As above:

	display "" [
		button 10x10
		do [face/image: my-image face/effect: 'fit]
	]

or:

	display "" [
		button 10x10
		do [face/image: load %my-image.png face/effect: 'fit]
	]
Graham
31-Oct-2007
[6903x2]
Ok, thanks
Isn't there a dirty? flag in Vid to check to see if an area widget 
has been altered?
Graham
5-Nov-2007
[6905x2]
Ashley, we talked about this before.  I  am looking for a way to 
spell check in a popup or static window attached to the area that 
is being checked, and to double click on the choice, have it replace 
the highlighted text, and then move on to the next text which is 
then highlighted.  I got it working except for the part of highlighting 
the next word that is suspect.  It highlights and then immediately 
loses the highlight .. perhaps something to do with the double click 
and focus system?
So, you lose the context in which you are spell checking the current 
word
Ashley
5-Nov-2007
[6907]
I remember looking at this and concluding that ctx-edit.r would have 
to be changed rather dramatically to allow this ... it has to do 
with the order in which set-focus and show are called. Several minor 
hacks I experimented with (mainly in set-focus) just didn't cut it. 
I put it in the "too hard" basket but may revisit this now that the 
long-running (for me at least) pick-list bug has been fixed; and 
I also have a few users asking about this as well.
btiffin
5-Nov-2007
[6908]
I'd 'here here' on that one.  I've been mucking with a RebGUI based 
editor and getting a Find/Replace dialog working has been an excercise 
in hackery that I'm not a huge fan of.  (Much chasing of tail and 
subverting of code that I have too much respect for to allow the 
hackery.)
JohanAR
6-Nov-2007
[6909]
Any easy and good looking way to get a return key press (in a text 
field) to trigger an ok-button?
btiffin
6-Nov-2007
[6910]
Johan; Try


display "test" [f1: field [b1/action/on-click b1 none] b1: button 
"Ok" [print "The action"]]


You may need to check with on-key if you want to restrict it to just 
"Enter", I'm not real sure what activities cause the action for fields 
to fire.  (Could be focus/unfocus...have to experiment)  and note 
this will not "click" the button, just evaluate it's on-click action 
code.  This advice is just in-the-meanwhile.  Ashley will no doubt 
have thee easy and good looking solution.  :)
Graham
6-Nov-2007
[6911]
Just wondering if it's better to allow one to copy text from an alert 
.. often they're error messages, and users like to copy them and 
email them.