Page 1 of 2

SPLITTER : how to"resize" Client Area

Posted: Sun Oct 30, 2022 6:14 am
by Jimmy
hi,

i want use SPLITTER

Code: Select all | Expand

      @ 0, (nWidth/2)-10 SPLITTER oSplit ;
      VERTICAL ;
      PREVIOUS CONTROLS oTab_Left ;
      HINDS CONTROLS oTab_Right ;
      LEFT MARGIN   0 ;
      RIGHT MARGIN 80 ;
      SIZE 4, nHeight PIXEL ;
      OF oMain STYLE
both Side have a TFolder() but how to "resize" it when Client Area change Size :?:

... or do i need a Window" on Client Area :?:

Re: SPLITTER : how to"resize" Client Area

Posted: Mon Oct 31, 2022 5:12 am
by Jimmy
hi,

i found Method AdjClient() which "seems" to do the Job

but how to call it :?:

Code: Select all | Expand

      @  0, nWidth/2 SPLITTER oSplit ;
              VERTICAL ;
              PREVIOUS CONTROLS oTab_Left ;
              HINDS CONTROLS oTab_Right ;
              LEFT MARGIN 0 ;
              RIGHT MARGIN 80 ;
              SIZE 4, nHeight PIXEL ;
              OF oMain STYLE

Re: SPLITTER : how to"resize" Client Area

Posted: Mon Oct 31, 2022 7:03 am
by Antonio Linares
Dear Jimmy,

oMain:bResized = { || oMain:oClient:Adjclient() }

Re: SPLITTER : how to"resize" Client Area

Posted: Mon Oct 31, 2022 8:25 am
by Jimmy
hi Antonio,
Antonio Linares wrote:oMain:bResized = { || oMain:oClient:Adjclient() }
ok, thx
but how to resize Child Control "on Area" :?:

have 2 x TFolder() and on its "Area" are some Control
when use SPLITTER i can "see" that "Area" of TFolder() resize but not Control on "Area"

---

what is when "maximize" Windows :?:
it "seems" me that SPLITTER will not "notice" new Size.

Re: SPLITTER : how to"resize" Client Area

Posted: Mon Oct 31, 2022 1:42 pm
by Antonio Linares
Dear Jimmy,

Here you have a working example:

Code: Select all | Expand

#include "FiveWin.ch"
#include "Splitter.ch"

function Main()

   local oWnd, oFld1, oFld2, oSplit 

   DEFINE WINDOW oWnd

   @ 0, 0 FOLDER oFld1 PROMPTS "Left" SIZE 270, 200
   
   @ 0, oWnd:nWidth/2 + 5 FOLDER oFld2 PROMPTS "Right" PIXEL

   @  0, oWnd:nWidth/2 SPLITTER oSplit ;
      VERTICAL ;
      PREVIOUS CONTROLS oFld1 ;
      HINDS CONTROLS oFld2 ;
      LEFT MARGIN 100 ;
      RIGHT MARGIN 0 ;
      SIZE 4, oWnd:nHeight PIXEL ;
      OF oWnd STYLE

   ACTIVATE WINDOW oWnd ;
      ON RESIZE ( oSplit:AdjLeft(), oSplit:AdjRight() )

return nil  
You can also review FWH\samples\classtree.prg for using more than one splitter

Re: SPLITTER : how to"resize" Client Area

Posted: Mon Oct 31, 2022 10:17 pm
by Jimmy
hi Antonio,

thx for Sample

i begin to realize that i need to re-write my "resize" to use "each" Tfolder() Size for Child on it

Re: SPLITTER : how to"resize" Client Area

Posted: Tue Nov 01, 2022 7:10 am
by Jimmy
hi,

i try to "resize" SPLITTER Area and want to know Size of each Area
on each Area i have a Control e.g. BUTTON which "full fit" Area

now i want to "resize" and both BUTTON should be also "resize" to "full fit"

Code: Select all | Expand

PROCEDURE DoResize(oWnd,oSplit)
   ...
   oSplit:AdjLeft()
   oSplit:AdjRight()

// left side
   oCtrol := oSplit:aPrevCtrols[ 1 ]
*   aRect  := GetCoors( oCtrol:hWnd )
*   nWidth  := aRect[4] - aRect[2]
*   nHeight := aRect[3] - aRect[1]

   nWidth  := oCtrol:nWidth
   nHeight := oCtrol:nHeight 

// right side
   oCtrol := oSplit:aHindCtrols[ 1 ]
 
but Data make no Sense ... :(

here Demo Source

Code: Select all | Expand

#include   "FiveWin.ch"
#include   "Splitter.ch"

function Main()
local oWnd, oFld1, oFld2, oSplit
local oBtn1, oBtn2

   DEFINE WINDOW oWnd

   @ 0, 0 FOLDER oFld1 PROMPTS "Left" SIZE 270, 200
   @ 30, 0 BUTTON oBtn1 SIZE oWnd:nHeight-30, oWnd:nWidth/2 PIXEL OF oFld1

   @ 0, oWnd:nWidth/2 + 5 FOLDER oFld2 PROMPTS "Right" PIXEL
   @ 30, 0 BUTTON oBtn2 SIZE oWnd:nHeight-30, oWnd:nWidth/2 PIXEL OF oFld2

   @ 0, oWnd:nWidth/2 SPLITTER oSplit ;
         VERTICAL ;
         PREVIOUS CONTROLS oFld1 ;
         HINDS CONTROLS oFld2 ;
         LEFT MARGIN   100 ;
         RIGHT MARGIN   0 ;
         SIZE 4, oWnd:nHeight PIXEL ;
         OF oWnd STYLE

    ACTIVATE WINDOW oWnd ;
        ON RESIZE DoResize(oWnd,oSplit)

RETURN NIL

PROCEDURE DoResize(oWnd,oSplit)
LOCAL nHeight := oWnd:nHeight
LOCAL nWidth  := oWnd:nWidth
LOCAL oCtrol, aRect

FWLOG "oWnd" ,nWidth,nHeight

   oSplit:AdjLeft()
   oSplit:AdjRight()

   oCtrol := oSplit:aPrevCtrols[ 1 ]
*   aRect  := GetCoors( oCtrol:hWnd )
*   nWidth  := aRect[4] - aRect[2]
*   nHeight := aRect[3] - aRect[1]

   nWidth  := oCtrol:nWidth
   nHeight := oCtrol:nHeight

FWLOG "left" ,nWidth,nHeight,aRect

   oCtrol := oSplit:aHindCtrols[ 1 ]
*   aRect  := GetCoors( oCtrol:hWnd )
*   nWidth  := aRect[4] - aRect[2]
*   nHeight := aRect[3] - aRect[1]

   nWidth  := oCtrol:nWidth
   nHeight := oCtrol:nHeight

FWLOG "Right",nWidth,nHeight,aRect

RETURN
who can point me the Way please

Re: SPLITTER : how to"resize" Client Area

Posted: Tue Nov 01, 2022 10:50 pm
by Jimmy
hi,

try Sample "as it is"

try "maximize" or "resize"
try "move" SPLITTER

---

SPLITTER go from TOP to BUTTOM when "ON RESIZE" is working

when not use "ON RESIZE" you can "see" that Size / Pos is correct

so what i´m doing wrong using SPLITTER :?:

---

Code: Select all | Expand

#include   "FiveWin.ch"
#include   "Splitter.ch"

FUNCTION Main()
local oWnd, oFld1, oFld2, oSplit, nPart
local oBtn1, oBtn2
LOCAL ii, oBtn0, nCol := 0, aButton := {}
LOCAL bAction := { || MsgInfo( "hello" ) }

   DEFINE WINDOW oWnd

   @ 0, 0 FOLDER oFld1 PROMPTS "Left" SIZE 270, oWnd:nHeight-80 PIXEL COLOR CLR_RED,CLR_RED
*  @ 30, 0 BUTTON oBtn1 SIZE oWnd:nHeight-30, oWnd:nWidth/2 PIXEL OF oFld1
   oBtn1 := TButton() :new( 30, 2 , "left", oFld1,, oWnd:nWidth/2 -4, oWnd:nHeight-60,,,, .T. )
   oBtn1:bAction := bAction

   @ 0, oWnd:nWidth/2 + 5 FOLDER oFld2 PROMPTS "Right" SIZE 270, oWnd:nHeight-80 PIXEL COLOR CLR_GREEN,CLR_GREEN
*   @ 30, 0 BUTTON oBtn2 SIZE oWnd:nHeight-30, oWnd:nWidth/2 PIXEL OF oFld2
   oBtn2 := TButton() :new( 30, 2 , "right", oFld2,, oWnd:nWidth/2 -4, oWnd:nHeight-60,,,, .T. )
   oBtn2:bAction := bAction

   @ 0, oWnd:nWidth/2 SPLITTER oSplit ;
         VERTICAL ;
         PREVIOUS CONTROLS oFld1 ;
         HINDS CONTROLS oFld2 ;
         LEFT MARGIN   10 ;
         RIGHT MARGIN   0 ;
         SIZE 8, 8 PIXEL ;
         ON CHANGE DoResize(oWnd,oSplit,oBtn1, oBtn2,aButton) ;
         OF oWnd

   nPart := oWnd:nWidth/12
   FOR ii := 1 TO 12
      oBtn0 := TButton() :new( oWnd:nHeight - 68, nCol, "F"+STRZERO(ii,2), oWnd,, nPart - 4, 20,,,, .T. )
      oBtn0:bAction := bAction

      nCol += nPart
      AADD(aButton,oBtn0)
   NEXT

    ACTIVATE WINDOW oWnd ;
        ON RESIZE DoResize(oWnd,oSplit,oBtn1, oBtn2,aButton) CENTER

*   CENTER

RETURN NIL

Code: Select all | Expand

PROCEDURE DoResize(oWnd,oSplit,oBtn1, oBtn2,aButton)
LOCAL nHeight := oWnd:nHeight
LOCAL nWidth  := oWnd:nWidth
LOCAL nPart   := oWnd:nWidth/12
LOCAL ii, oBtn, nCol := 0
LOCAL oCtrol, aRect

FWLOG "oWnd",nWidth,nHeight
   oSplit:AdjLeft()
   oSplit:AdjRight()

   oCtrol := oSplit:aPrevCtrols[ 1 ]
   nWidth  := oCtrol:nWidth  -4
   nHeight := oCtrol:nHeight -60

   oBtn1:SetSize(nWidth,nHeight)
FWLOG "left",nWidth,nHeight,aRect

   oCtrol := oSplit:aHindCtrols[ 1 ]
   nWidth  := oCtrol:nWidth  -4
   nHeight := oCtrol:nHeight -60

   oBtn2:SetSize(nWidth,nHeight)
FWLOG "Right",nWidth,nHeight,aRect

   FOR ii := 1 TO 12
      aButton[ii]:SetSize(nPart,20)
      aButton[ii]:SetPos(oWnd:nHeight - 68, nCol)
      nCol += nPart
   NEXT
RETURN

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 1:08 pm
by Jimmy
hi,

have figure out how SPLITTER work :)

Code: Select all | Expand

#include   "FiveWin.ch"
#include   "Splitter.ch"

#define ID_TOP       30
#define ID_FXBAR     68

*+--------------------------------------------------------------------
*+
*+    Function Main()
*+
*+--------------------------------------------------------------------
*+

FUNCTION Main()

LOCAL oWnd, oFld1, oFld2, oSplit, nPart
LOCAL nHeight, nWidth
LOCAL oBtn1, oBtn2
LOCAL ii, oBtn0, nCol := 0, aButton := {}
LOCAL bAction := { || MsgInfo( "hello Main" ) }

   DEFINE WINDOW oWnd FROM 0, 0 TO 600, 800 PIXEL

      nWidth := oWnd:nWidth / 2
      nHeight := oWnd:nHeight

      oFld1 := TFolder() :New( 0,          0, { "Grid_left1"  },, oWnd, 1,,, .T., .F., nWidth - 5, nHeight - 70 )
      oBtn1 := TButton() :new( ID_TOP, 2, "left" , oFld1, bAction, nWidth - 6, nHeight - 120,,,, .T. )
      oBtn1:bAction := bAction

      oFld2 := TFolder() :New( 0, nWidth + 5, { "Grid_right1" },, oWnd, 1,,, .T., .F., nWidth - 5, nHeight - 70 )
      oBtn2 := TButton() :new( ID_TOP, 2, "right", oFld2, bAction, nWidth - 6, nHeight - 120,,,, .T. )
      oBtn2:bAction := bAction

      nPart := oWnd:nWidth / 12
      FOR ii := 1 TO 12
         oBtn0 := TButton() :new( nHeight - ID_FXBAR, nCol, "F" + STRZERO( ii, 2 ), oWnd, bAction, nPart - 4, 20,,,, .T. )
         nCol += nPart
         AADD( aButton, oBtn0 )
      NEXT

      @ ID_TOP, nWidth - 10 SPLITTER oSplit ;
              VERTICAL ;
              PREVIOUS CONTROLS oFld1 ;
              HINDS    CONTROLS oFld2 ;
              LEFT MARGIN 1 ;
              RIGHT MARGIN 1 ;
              SIZE 8, nHeight - 98 PIXEL ;
              ON CHANGE DoResize( oWnd, oSplit, oFld1, oFld2, oBtn1, oBtn2, aButton ) ;
              COLOR CLR_BLUE ;
              OF oWnd

#IFDEF __HMG__
   END WINDOW
#ENDIF

   ACTIVATE WINDOW oWnd ;
           ON RESIZE DoResize( oWnd, oSplit, oFld1, oFld2, oBtn1, oBtn2, aButton ) CENTER

RETURN NIL

*+--------------------------------------------------------------------
*+
*+    Procedure DoResize()
*+
*+    Called from ( split1.prg )   2 - function main()
*+                ( tgrid.prg )   2 - procedure main()
*+
*+--------------------------------------------------------------------
*+
PROCEDURE DoResize( oWnd, oSplit, oFld1, oFld2, oBtn1, oBtn2, aButton )

LOCAL nTop       := oWnd:nTop
LOCAL nBottom    := oWnd:nBottom
LOCAL nRight     := oWnd:nRight
LOCAL nLeft      := oWnd:nLeft
LOCAL nHeight    := nBottom - nTop
LOCAL nPart      := oWnd:nWidth / 12
LOCAL nLeftWidth, nRightWidth
LOCAL ii, oBtn, nCol := 0
LOCAL oCtrol

   // ************************ left *************************

   oSplit:AdjLeft()
   oSplit:nTop    := ID_TOP
   oSplit:nHeight := nHeight - ID_TOP - ID_FXBAR

   oCtrol := oSplit:aPrevCtrols[ 1 ]
   nLeftWidth     := oCtrol:nWidth

   IF nLeftWidth > oWnd:nWidth
      nLeftWidth  := oWnd:nWidth - 100
      oSplit:SetPosition( nLeftWidth )
   ENDIF

   oCtrol:nLeft   := 0
   oCtrol:nRight  := nLeftWidth
   oCtrol:nTop    := ID_TOP
   oCtrol:nBottom := nHeight - ID_FXBAR - 130
   oCtrol:SetSize( nLeftWidth, nHeight - ID_FXBAR - 40 )

   oBtn1:SetPos( ID_TOP, 20 )
   oBtn1:SetSize( nLeftWidth - 40, nHeight - ID_FXBAR - 90 )

   // ************************ right *************************

   oSplit:AdjRight()
   oSplit:nTop    := ID_TOP
   oSplit:nHeight := nHeight - ID_TOP - ID_FXBAR

   oCtrol := oSplit:aHindCtrols[ 1 ]
   nRightWidth    := oCtrol:nWidth

   oCtrol:nLeft   := nLeftWidth
   oCtrol:nRight  := nRightWidth
   oCtrol:nTop    := ID_TOP
   oCtrol:nBottom := nHeight - ID_FXBAR - 130
   oCtrol:SetSize( nRightWidth, nHeight - ID_FXBAR - 40 )

   oBtn2:SetPos( ID_TOP, 20 )
   oBtn2:SetSize( nRightWidth - 40, nHeight - ID_FXBAR - 90 )

   // ************************ NEED again *************************

   oFld1:SetPos( ID_TOP, 0 )
   oFld1:SetSize( nLeftWidth, nHeight - ID_FXBAR - 40 )

   // ************************ Fx Buttons *************************

   FOR ii := 1 TO 12
      aButton[ ii ] :SetSize( nPart, 30 )
      aButton[ ii ] :SetPos( oWnd:nHeight - ID_FXBAR, nCol )
      nCol += nPart
   NEXT

   oWnd:Refresh()
RETURN
*+ EOF: SPLIT1.PRG
but it need a Workaround to work as i want

---
IHMO
SPLITTER VERTICAL use "full height" of Window even when attached PREVIOUS / HINDS does not use "full height"
so left Position of PREVIOUS is wrong without Workaround

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 4:07 pm
by Antonio Linares
Dear Jimmy,

many thanks for your great feedback

> but it need a Workaround to work as i want

How should it work ? what is missing ?

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 5:02 pm
by Jimmy
hi Antonio,

SPLITTER is working IMHO on "hole height" (VERTICAL) and not "relative" to attached Object

in Sample attached Object have TOP := 40 and BOTTOM ;= height - 68 so it is "in Middle" of Window
to "see" what i mean disable these 2 Lines under *** NEED again *** and see what happens

Code: Select all | Expand

//     oFld1:  SetPos  ( ID_TOP,   0   )
//     oFld1:  SetSize  ( nLeftWidth, nHeight - ID_FXBAR -   40   )
left FOLDER will be to height ... but i have SET Pos & Size "before" :!:

if press SPLITTER to "move" it will still go to Bottom but i have "limited" to Object "in Middle" of Window

---

Request :
would be nice to get "Percent" to use that Value to "o:SetPosition()" when "maximize"
use a IMAGE to "paint" SPLITTER

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 7:26 pm
by Antonio Linares
Dear Jimmy,

Have you reviewed FWH\samples\classtree.prg ?

I think it is a very good example of working with splitters

Look for splitter in FWH\samples and you will find several examples

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 7:41 pm
by Jimmy
hi Antonio,
Antonio Linares wrote:Have you reviewed FWH\samples\classtree.prg ?
YES
Antonio Linares wrote:I think it is a very good example of working with splitters
Look for splitter in FWH\samples and you will find several examples
NO

left Side goes from TOP to BUTTON what i not do while have 12 x BUTTON on Button above STATUSBAR

please run Sample i have made to show where "my" SPLITTER work NOT from TOP until BOTTOM :!:

p.s. can i put a Toolbar on Bottom using Fivewin :?:

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 7:42 pm
by cnavarro
I don't know if I have understood correctly what you need
Jimmy, is this what you need? The resizing of the controls contained on both sides of the splitter ?
Image

Re: SPLITTER : how to"resize" Client Area

Posted: Thu Nov 03, 2022 8:34 pm
by Jimmy
hi,
cnavarro wrote:I don't know if I have understood correctly what you need
please run Sample i have provide which run fine so far

than edit Source and comment out this 2 lines

Code: Select all | Expand

 // ************************ NEED again *************************   
    //     oFld1:  SetPos  ( ID_TOP,   0   )
    //     oFld1:  SetSize  ( nLeftWidth, nHeight - ID_FXBAR -   40   )
now you can "see" that left Side begin "on TOP" instead to leave Space (for Combobox) before FOLDER begin