Previous Thread
Next Thread
Print Thread
New LEO Featrue? #28668 12 Feb 09 10:09 AM
Joined: Nov 2006
Posts: 2,223
S
Stephen Funkhouser Offline OP
Member
OP Offline
Member
S
Joined: Nov 2006
Posts: 2,223
Hi Jorge,

I sent you an email about a possible LEO update earlier this morning, it would have been 2pm your time. I just wanted make sure that you actually got the email.


Stephen Funkhouser
Diversified Data Solutions
Re: New LEO Featrue? #28669 13 Feb 09 04:34 AM
Joined: Jun 2001
Posts: 3,406
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,406
Hi, Stephen

The issue under discussion is:
------------------------------------------------
Would it be possible to add a field'state() array to the .gen file that get used by the handle'controls routine for SBXINP controls. You could set the defaults to whatever they are setup as in the properties panel in LEO.

The reason I ask is there are a lot of times when I need to have a dialog with a lot of sbxinp fields start in DISPLAY_MODE with one in EDIT_MODE. This is generally so that the editable field is a File Key selection. Once the key is selected I'll put that control in DISPLAY_MODE and all the others in EDIT_MODE. It seems that it would be much cleaner to do this if the program knows what the state of the SBXINP control should be and then just call refresh'controls().
---------------------------------------


I think the images below illustrate the scenario, that is, fields changing their sates depending on some condition, correct?

[Linked Image]
[Linked Image]

[Linked Image]
[Linked Image]

In the above example, the three marked fields start enabled and, depending on the 2nd field they are disabled, or not.
The control of the field state is prepared in Leo allowing to fully control the field state in the main program, to do that:

[Linked Image]
[Linked Image]

Ticking the "REFRESH control" checkbox for each of the fields we want to control (i.e. change state, refresh value) inform LEO to ceate DEFINES using their "Name", like:
! control # for fields requiring individual REFRESH actions
define cursos_PROJ'ID = -102
define cursos_PRGFIN = -104
define cursos_TAB'CLI = -106
define cursos_ARFOR = -109
define cursos_EFORM = -111
define cursos_EDICAO = -113

With this, if I need to refresh one particular field (eg: PRGFIN) regarding its value, just need to do:
call cursos_refresh'controls(cursos_PRGFIN, cursos_PRGFIN)

If I want to control the state depending on a condition, I use the "_fld'pre" procedure that, for the above example looks like this:
Code
 
PROCEDURE cursos_fld'pre(op as b1,fname$ as s24,do'nothing as b1)
++pragma auto_extern

STRSIZ 24                                                    ! needed for the SWITCH evaluation


       if op=DISPLAY_MODE then		       ! only on display
          SWITCH fname$
          CASE "curso.prfin"
               op = state.prgfin
               exit
          CASE "sccrnovo.tab'curso"
               op = state'tipologia
               exit
          CASE "sccrnovo.tab'cli"
               op = state'cliente
               exit
          DEFAULT
               exit
          ENDSWITCH
       else
          if modo'actual$=MODE_VIEW then
             do'nothing = 1
          else
             SWITCH fname$
             DEFAULT
                  exit
             ENDSWITCH
          endif
       endif

       xputarg 1,op
       xputarg 2,fname$
       xputarg 3,do'nothing
ENDPROCEDURE
 
The logic above do this:
When _refresh'controls() is processed in DISPLAY_MODE (like in the initial load dialog), the three fiels will have the state defined in the corresponding state variables (eg: EDIT_MODE, DISABLE_MODE, DISPLAY_MODE; all those defined in LEO) that you can set as you want in the main program.

In my example, when in MODE_VIEW (not editing), I want to not allow ANY field to be entered so, setting "do'nothing = 1" does the job.


Surely what is described above is more than what you asked for and, maybe even don't completely answer your needs, but my goal here is to show that, the logic to enable/disable/refresh fields is already available in LEO, and now it's just a matter to adjust it.

I don't know if you knew already this technique and, besides that, it doesn't cover what you want or, you never tried it.
Please let me know what is your case, and I'll adjust whatever is needed.

Thank you


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: New LEO Featrue? #28670 13 Feb 09 11:04 AM
Joined: Nov 2006
Posts: 2,223
S
Stephen Funkhouser Offline OP
Member
OP Offline
Member
S
Joined: Nov 2006
Posts: 2,223
I need to be able to set the SBXINP MODE's before the dialog is created, and it seems like this should be standardized to work like it does for AUI_CONTROL's. If you add an array for field_state'value$() then you could use this as the default states in refresh'controls() instead of DISPLAY_MODE. This way the program would always know what the states of each control are supposed to be.

I have used the method that you posted here, but it's more cumbersome to use than the array would be. You would also be able to set the states in the generated code just like LEO does for AUI_CONTROL's.

It also seems like it would be easier for other's to use LEO if this were standardized.


Stephen Funkhouser
Diversified Data Solutions
Re: New LEO Featrue? #28671 13 Feb 09 04:17 PM
Joined: Jun 2001
Posts: 3,406
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,406
Ok Stephen, if you are enough brave to give a try to the "la minute" new feature, update to the new non-documentated version :rolleyes:

To keep untouched any previous Leo generated program, I added two new options in the combo list for the SBXINP field:
"state control (start normal)"
"state control (start disabled)"

All the fields you want to control via the state array must be defined with one of these two options, which will generate the following code in the GEN file:

(in this example, I'll use fld1 and fld2 where the first one start normal and the second start disabled)
Code
! control # for fields defined in the state infld array
define amostra_ST_FLD1 = 1
define amostra_ST_FLD2 = 2
...
map1 mydlg'infld'state'value(2),b,1
       mydlg'infld'state'value(1) = INFOP_DISPLAY
       mydlg'infld'state'value(2) = DISABLE_MODE
...

FUNCTION FN'amostra_handle'controls(op as b1, fxid as b2)

...

          SWITCH fname$
          CASE "mygen.data"
                nexitcode = FN'mydlg_inp_data(op'input, mydlg'data$)
                exit
          CASE "mygen.hora"
                nexitcode = FN'mydlg_inp_hora(op'input, mydlg'hora$)
                exit
          CASE "mygen.numero"
                nexitcode = FN'mydlg_inp_numero(op'input, mydlg'numero$)
                exit
          CASE "mygen.via"
                nexitcode = FN'mydlg_inp_via(op'input, mydlg'via$, lista'vias$)
                exit
          CASE "mygen.fld1"
                call FN'mydlg_inp_fld1(mydlg'infld'state'value(1), mydlg'cli'nome$)
                nexitcode = 7
                exit
          CASE "mygen.contacto"
                nexitcode = FN'mydlg_inp_contacto(op'input, mydlg'contacto$)
                exit
          CASE "mygen.modelo"
                call FN'mydlg_inp_modelo(mydlg'infld'state'value(2), mydlg'modelo$)
                nexitcode = 7
                exit

...

ENDFUNCTION
I just included more fields than the two state fields in the SWITCH statement to show that, the 1 and 2 index in the state array don't correspond to their sequence on the dialog.

Hopefully this enough clear, and even more hopefully this is what you want, but if not, just let me know what you need more.


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: New LEO Featrue? #28672 13 Feb 09 04:26 PM
Joined: Jun 2001
Posts: 3,406
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,406
I forgot to add what you need to do in the main program to control these fields, besides you probably know it very well once it was you who have this (excellent) idea.

Follows a sample where, clicking in a button, toggles fld1 between ENABLE / DISABLE

Code
SWITCH exitcode
CASE VK_TOGGLE 
	if mydlg'infld'state'value(mydlg_ST_FLD1)=INFOP_DISPLAY then
	   mydlg'infld'state'value(mydlg_ST_FLD1) = DISABLE_MODE
	else
	   mydlg'infld'state'value(mydlg_ST_FLD1) = INFOP_DISPLAY
	endif
	call mydlg_refresh'controls(mydlg_FLD1, mydlg_FLD)
ENDSWITCH
Note the slight difference between the defines:
mydlg_FLD1
mydlg_ST_FLD1
The former is 1 regarding the sequence in the state array; the last is -105 regarding the Tab sequence and it's this one that makes possible to directly refresh a control without loop over all the other fields in the refresh'controls()


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: New LEO Featrue? #28673 13 Feb 09 04:29 PM
Joined: Jun 2001
Posts: 3,406
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,406
By the way, and still about defines, if you have a field which label is a button, automatically you have an additional define for the button, using the previous example it would be:
mydlg_BT_FLD1 = 305
(field + 200)


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: New LEO Featrue? #28674 13 Feb 09 05:11 PM
Joined: Nov 2006
Posts: 2,223
S
Stephen Funkhouser Offline OP
Member
OP Offline
Member
S
Joined: Nov 2006
Posts: 2,223
Okay, well I'll give this a try tonight and let you know how it goes.

Thanks for being so responsive on this.


Stephen Funkhouser
Diversified Data Solutions
Re: New LEO Featrue? #28675 13 Feb 09 07:04 PM
Joined: Nov 2006
Posts: 2,223
S
Stephen Funkhouser Offline OP
Member
OP Offline
Member
S
Joined: Nov 2006
Posts: 2,223
I was brave enough to give this a try, and it works exactly like I hoped it would.

Thank you very much Jorge!


Stephen Funkhouser
Diversified Data Solutions

Powered by UBB.threads™ PHP Forum Software 7.7.3