Page 1 of 1

ON RESIZE "automatic" -> Layout Manager ?

Posted: Fri Dec 20, 2019 8:47 am
by Jimmy
hi,

does somebody have made a "Layout-Manager" for FiveWin RESIZE :?:

for each windows i have to write a function ... so i wrote a "Layout-Manager" for Xbase++
while Concept are for OOP i'm not sure if i can use that Technique with DIALOG Syntax.

after all Child on DIALOG are create i want to get Information of them as "Original" Value.

Code: Select all

ON INIT Layoutmanager(self)
it will init a List (Array) of Child and it's Pos / Size.
this must work recursive if a Child is Parent for other Control

Code: Select all

   aChildGen1 := oParent:Childlist()

   FOR i := 1 TO LEN(aChildGen1)
      oObject := aChildGen1[i]
      aChildGen2 := oObject:Childlist()
      IF LEN(aChildGen2) > 0
         Recursive(oObject)
      ELSE    
         aadd(::aLayout, {oParent,oParent:nHeight,oParent:nWidth,;
                          oObject,oObject:nTop,oObject:nLeft,oObject:nHeight,oObject:nWidth } )
      ENDIF
   NEXT 
under Xbase++ i can ASCAN() for a Object :!:
i also can use o:Hwnd as workaround

Code: Select all

ON RESIZE Layoutmanager:Resize(self)
here "automatic" begin

Code: Select all

INLINE METHOD RESIZE(oIn)
   nDlgObj := oIn
or
   nDlgWnd ;= oIn:Hwnd
 
what i need is actual Size of DIALOG. this i need to calculate "Zoom-Faktor" to Original Size

now i start ASCAN() to get all Control to a Parent DIALOG

Code: Select all

LOCAL nPosi := 1
LOCAL nStart := 1
LOCAL nHeight := oIn:nHeight
LOCAL nWidth := oIn:nWidth
   
   DO WHILE nPosi > 0   
      nPosi := ASCAN(::aLayout, {|e| e[1] = nDlgObj }, nStart )
      IF nPosi > 0
         ::ZoomY := ::aLayout[nPosi][2] / nHeight * 100
         ::ZoomX := ::aLayout[nPosi][3] / nWidth * 100
         oObject := ::aLayout[nPosi][4]
         oObject:SetPos( {::aLayout[nPosi][5]+::ZoomX,::aLayout[nPosi][6]*::ZoomY} )
         oObject:SetSize( {::aLayout[nPosi][7]+::ZoomX,::aLayout[nPosi][8]*::ZoomY} )
         nStart := nPosi +1
      ENDIF
   ENDDO    
   nDlgObj:InvalidRect()
 
under Xbase++ it work with all "Original Windows" Control.
it fail e.g. with XbpBrowse() which "self made" with WC_STATIC (many Child ...)

---

i'm still a FiveWin Newbie so some parts of puzzle are missing like

Childlist() -> get all Child of a DIALOG or WINDOW

to test my Idea :idea:
or is hole Work obsolet while FiveWin have it but i have not found it yet :?:

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Mon Dec 30, 2019 6:44 pm
by Jimmy
hi,

i found "Adjust" in many Sample. is this for automatic "resize" :?:

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Fri Jan 03, 2020 9:46 pm
by Otto
Hello Jimmy,

Would that mean that your DIALOGS and WINDOWS would then be responsive, too?
I mean that the screen is to small one line breaks into two, etc.
Do you think we could adopt a kind of CSS?

Best regards
Otto

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Sat Jan 04, 2020 2:05 am
by Jimmy
Otto wrote: Would that mean that your DIALOGS and WINDOWS would then be responsive, too?
i'm not sure about "Adjust" any more while i can't "see" it run ...

i try to run Sample c:\fwh\samples\testsay.prg but i got Error about "@" :shock:
Compiling 'testsay.prg' and generating preprocessed output to 'testsay.ppo'...
1 error

No code generated.
testsay.prg(30) Error E0030 Syntax error "syntax error at '@'"
* Compile errors *
it is still a Problem with FiveWin when those c:\fwh\samples\ does not work :(
are those files in c:\fwh\samples\ "verified" or not :?:

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Sat Jan 04, 2020 8:52 am
by Otto
Hello Jimmy,
I see ::lAdjust only in the SetText method of the TSay Class.
Best regards
Otto
C:\fwh\source\classes\say.prg

Code: Select all

METHOD SetText( cText ) CLASS TSay

   local hDC, nWidth

   DEFAULT ::lTransparent := .f.

   ::cCaption := If( ::cPicture != nil, Transform( cText, ::cPicture ),;
                     cValToChar( cText ) )

   #ifndef __CLIPPER__
      if ! Empty( ::hWnd ) .and. ::oWnd:oBrush != nil .and. Empty( ::oWnd:oBrush:hBitmap ) .and. ( IsAppThemed() .or. ::lTransparent )
         DrawPBack( ::hWnd, hDC := GetDC( ::hWnd ) )
         ReleaseDC( ::hWnd, hDC )
      endif
   #endif

   if ! Empty( ::hWnd )
      if ! lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), nOr( SS_LEFT, SS_RIGHT, SS_CENTER ) ) .AND. ::lAdjust
         nWidth = GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) ) + 20
         if nWidth > ::nWidth
            ::nWidth = nWidth
         endif
      endif
      SetWindowText( ::hWnd, ::cCaption )
   endif

return nil

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Sat Jan 04, 2020 2:14 pm
by MGA

Re: ON RESIZE "automatic" -> Layout Manager ?

Posted: Sat Jan 04, 2020 9:05 pm
by Jimmy
hi,
thx for Tip.
i have Problem with download Display3.RAR while it need a Account to Twitter/Facebook or Google which i don't use

i got Source now from http://fivewin.com.br/index.php?/topic/ ... ntry262057

but have Problem with HB_FUNC (VMUDAVIDEO)
Error E2227 adjust.prg 773: Extra parameter in call to hb_storni in function HB_FUN_VMUDAVIDEO
Error E2227 adjust.prg 774: Extra parameter in call to hb_storni in function HB_FUN_VMUDAVIDEO
---

as i understood Code you have to choose Resolution for Layout.
what i mean is e.g. "maximize" from "normal" 1280x800 to 1920x1024

what do i need : "Childlist"
i need to know Pos/Size of all Control place into a Dialog/Window

Code: Select all

   ON INIT GetLayOut(This.Window)
  ON RESIZE DoLayout(This.Window)
just Dummy Code

Code: Select all

PUBLIC aLayOut := {}

FUNCTION GetLayout(cIn)
LOCAL aChild := cIn:ChildList()
LOCAL i,iMax := LEN(aChild)
LOCAL oChild, aMore

   FOR i := 1 TO imax
      oChild := aChild[i]
      aMore := oChild:ChildList()
      IF LEN(aMore) > 0
         GetLayout(aChild)
      ELSE
         AADD(aLayout,{oChild, oChild:Pos, oChild:Size}) 
      ENDIF
   NEXT
RETURN .T.  

Code: Select all

FUNCTION DoLayout(cIn)            
LOCAL aChild := cIn:ChildList()
LOCAL i,iMax := LEN(aChild)
LOCAL oChild, aMore
LOCAL xZoom := 0, yZoom := 0

   CalcZoom(cIn,@xZoom, @yZoom) // cIN:NewSize <-> Original Size

   FOR i := 1 TO imax
      oChild := aChild[i]
      nPosi := ASCAN(aLayout,{|e| e[1] = oChild} )
      oChild:SetPos(aLayout[nPosi][2][1]*xZoom,aLayout[nPosi][2][2]*yZoom)
      oChild:SetSize(aLayout[nPosi][3][1]*xZoom,aLayout[nPosi][3][2]*yZoom)
      // also Calc on Font Size    
   NEXT
RETURN .T.  
that Dummy Code is just a small Part which i have under Xbase++
it work well with OOP Code but have to find out how to "translate" it to FiveWin Syntax.

so my Question are how to translate

Code: Select all

   aChild := cIn:ChildList()
how to get "Child" of Dialog / Window :?:

Code: Select all

   nPosi := ASCAN(aLayout,{|e| e[1] = oChild} )
can i ASCAN for a Object under FiveWin :?: