Alaska Software Inc. - XbpPushButton() alignment error
Username: Password:
AuthorTopic: XbpPushButton() alignment error
Carlos A Beling XbpPushButton() alignment error
on Fri, 15 Jan 2021 18:24:32 -0300
Hi:
good night.
In the attached sample it can to be see that the position where 
SetAppWindow() is rendered in AppDeskTop() does not match with its 
creation position.
Also the XbpPushbutton() can not to be aligned correctly with the 
XbpSle() bottom position.
Please if it is possible, how can it to be fixed?

Fraternally
Beling


! Push.png
! Test.zip
Jim LeeRe: XbpPushButton() alignment error
on Fri, 15 Jan 2021 23:36:53 +0100
hi,

i dont understand why you want to use API Function to "set Position" ...

   oSle:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oXbp, oPush)}
   ...
   oPush := oPushOnDesktop():new(NIL, NIL, NIL, {16, 25}):create()

btw. API Fundtion work with 0,0 at "Top left"
Carlos A Beling Re: XbpPushButton() alignment error
on Sat, 16 Jan 2021 12:19:32 -0300
Hi Jim.
Good Day.
Many Thanks.
I am using the API function only for obtain the screen coordinates of 
the Xbp where I want to position the pushbutton. The actual position is 
get using the function GetPos2Show_().

I have a very large app ported from Clipper to Xbase++ in text mode 
(XbpCrt). Please see the attach "! TxtScr.png". The pushbutton is moved 
from one Get() to the other.

In the visual mode I need to do the same thing using the screen 
coordinates because the pushbutton can to go beyond the Xbp:setParent() 
width and the pushbutton may to be shown partially.
I made changes in the original Test.prg for to show this.

The problem:
1) the screen coordinates does not match with the visual position of the 
app window (please see the attach "! GuiScr.png")
2) using the screen coordinates the pushbutton is shown unaligned in 
relation to the Xbp. In the function ShowPushDown_() located in the 
Text.prg you can see it inspecting the vars.

Fraternally
Beling


On 15/01/2021 19:36, Jim Lee wrote:
> hi,
> 
> i don´t understand why you want to use API Function to "set Position" ...
> 
>     oSle:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oXbp, oPush)}
>     ...
>     oPush := oPushOnDesktop():new(NIL, NIL, NIL, {16, 25}):create()
> 
> btw. API Fundtion work with 0,0 at "Top left
> 
>


! TxtScr.png
! GuiScr.png
! Test.zip
Jim LeeRe: XbpPushButton() alignment error
on Tue, 19 Jan 2021 08:07:20 +0100
hi,

i have look at your Demo Source and dont understand why you need API ...

simple Way : why not use 2 x Button ?

OOP Way : the Xbase++ OOP Way is to use Childlist() to get Position

oSle1:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oSle1,oPush,oDlg)}
oSle2:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oSle2,oPush,oDlg)}

oSle2 is on DrawingArea while oSle1 have a XbpStatic as Parent so it need a 
recursive Function

FUNCTION ShowPushDown_(oSle,oPush,oDlg,aChild,aNew )
LOCAL aPos
LOCAL aSize
LOCAL i,iMax,aMore

   IF EMPTY(aChild)
      aChild := oDlg:DrawingArea:Childlist()
      aNew  := {0,0}
   ENDIF

   iMax := LEN(aChild)
   FOR i := 1 TO imax
      IF aChild[i]:isDerivedFrom("Xbpsle")
         IF aChild[i] = oSle    is it right SLE
            aPos  := oSle:Currentpos()
            aSize := oSle:CurrentSize()
            oPush:setPos({aNew[1]+aPos[1]+aSize[1]+10,aNew[2]+aPos[2]})
            oPush:show()
            EXIT
         ENDIF
      ELSE
         aMore := aChild[i]:Childlist()
         IF LEN(aMore) > 0
            aNew := aChild[i]:Currentpos()
            ShowPushDown_(oSle,oPush,oDlg,aMore,aNew)
            aNew := {0,0}
         ENDIF
      ENDIF
   NEXT
RETURN NIL

---

i recommend to use "simple" Way and use only o:DrawingArea instead of new 
Parent in Childlist()




XB_TEST.ZIP
Carlos A Beling Re: XbpPushButton() alignment error
on Tue, 19 Jan 2021 18:45:38 -0300
Hi Jim:
good evening.
Many thanks.
The API is used for to retrieve the screen cordinates of the Xbp where I 
want to position the pushButton, independing on the XbpSle:setParent(), 
even that the pushbutton's area wents out of it. This way I always will 
see the pushbutton and can correct its position.
The worst problem is that the position returned by the API does not 
match with the main window's position creation (ie: the XbpDialog's 
position is {0, 31} and the API returns {10, -3}).

I added in the test.zip one program that uses the code that you 
suggested. Please, if you do not mind, compare the two solutions for to 
see what I'd like to do.

Fraternally
Beling



On 19/01/2021 04:07, Jim Lee wrote:
> hi,
> 
> i have look at your Demo Source and don´t understand why you need API ...
> 
> simple Way : why not use 2 x Button ?
> 
> OOP Way : the Xbase++ OOP Way is to use Childlist() to get Position
> 
> oSle1:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oSle1,oPush,oDlg)}
> oSle2:enter  := {|aPos, uNil,  oXbp| ShowPushDown_(oSle2,oPush,oDlg)}
> 
> oSle2 is on DrawingArea while oSle1 have a XbpStatic as Parent so it need a
> recursive Function
> 
> FUNCTION ShowPushDown_(oSle,oPush,oDlg,aChild,aNew )
> LOCAL aPos
> LOCAL aSize
> LOCAL i,iMax,aMore
> 
>     IF EMPTY(aChild)
>        aChild := oDlg:DrawingArea:Childlist()
>        aNew  := {0,0}
>     ENDIF
> 
>     iMax := LEN(aChild)
>     FOR i := 1 TO imax
>        IF aChild[i]:isDerivedFrom("Xbpsle")
>           IF aChild[i] = oSle    is it right SLE
>              aPos  := oSle:Currentpos()
>              aSize := oSle:CurrentSize()
>              oPush:setPos({aNew[1]+aPos[1]+aSize[1]+10,aNew[2]+aPos[2]})
>              oPush:show()
>              EXIT
>           ENDIF
>        ELSE
>           aMore := aChild[i]:Childlist()
>           IF LEN(aMore) > 0
>              aNew := aChild[i]:Currentpos()
>              ShowPushDown_(oSle,oPush,oDlg,aMore,aNew)
>              aNew := {0,0}
>           ENDIF
>        ENDIF
>     NEXT
> RETURN NIL
> 
> ---
> 
> i recommend to use "simple" Way and use only o:DrawingArea instead of new
> Parent in Childlist()
> 
>


! Test.zip
Jose Antonio Diego KerejeRe: XbpPushButton() alignment error
on Wed, 20 Jan 2021 00:20:49 +0100
Hi,

I wouldn't do it this way, but if it's about positioning the button, you can 
do it this way (note that AppDesktop (): currentSize () returns a static 
size).

Regards. Diego


Test.prg
Carlos A Beling Re: XbpPushButton() alignment error
on Wed, 20 Jan 2021 13:09:54 -0300
Hi Diego:
good day.
Many thanks.
It worked fine.

Fraternally
Beling

On 19/01/2021 20:20, Jose Antonio Diego Kereje wrote:
> Hi,
> 
> I wouldn't do it this way, but if it's about positioning the button, you 
> can do it this way (note that AppDesktop (): currentSize () returns a 
> static size).
> 
> Regards. Diego