Splitter and Resize window

Splitter and Resize window

Postby Silvio.Falconi » Thu Mar 21, 2024 11:13 am

I want that when the end user resizes the oWnd window, the splitter should move to the left

when the window is widened the splitter must go to the right and the second explorer must have the dimensions

as I have drawn them in the figure below

Image


the test

Code: Select all  Expand view

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

#define ID_TOP       60
#define ID_FXBAR     68

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

FUNCTION Main()

LOCAL oWnd, oFld1, oFld2, oSplit, nPart
LOCAL nHeight, nWidth
LOCAL oBtn1, oBtn2, oBtn3, oBtn4,oBtn5, oBtn6, oBtn7, oBtn8,oBar
LOCAL ii, oBtn0, nCol := 0, aButton := {}
LOCAL bAction := { || MsgInfo( "hello Main" ) }
LOCAL nSplit:= 490

local cFolderBmps:="C:\work\fwh\"
local oBrush1,oFontTitle,oFontText



DEFINE BRUSH oBrush1 COLOR CLR_WHITE //RGB( 245,245,235)
   DEFINE FONT oFontTitle  NAME "
Segoe UI Light" SIZE 0, -18  BOLD
   DEFINE FONT oFontText   NAME "
Segoe UI Light" SIZE 0, -12

DEFINE WINDOW oWnd FROM 0, 0 TO 600, 800 PIXEL TITLE "
test splitter"

      DEFINE BUTTONBAR oBar OF oWnd 2013 SIZE 70, 60

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


      oFld1 := TEXplorerBar():New( 0, 0, nSplit, , oWnd)
      oFld1:nTopColor     := RGB( 240,240,240)
      oFld1:nBottomColor  := RGB( 240,240,240)

      oBtn1:=  oFld1:AddPanel("
Name Panel 1", cFolderBmps+"people.bmp"  ,80 )
      oBtn3:=  oFld1:AddPanel("
Name Panel 3", cFolderBmps+"people.bmp"  ,80 )
      oBtn4:=  oFld1:AddPanel("
Name Panel 4", cFolderBmps+"people.bmp"  ,80 )
      oBtn5:=  oFld1:AddPanel("
Name Panel 5", cFolderBmps+"people.bmp" ,80 )

      For n=1 to len(oFld1:aPanels)
       oFld1:aPanels[n]:nRound  := 0
       oFld1:aPanels[n]:aGradient := { { CLR_WHITE, CLR_WHITE }, {CLR_WHITE, CLR_WHITE } }
       oFld1:aPanels[n]:nTitleHeight := 40
       oFld1:aPanels[n]:lCollapsed :=.f.
       oFld1:aPanels[n]:lSpecial = .t.
       oFld1:aPanels[n]:oBrush:=  oBrush1
       oFld1:aPanels[n]:nClrTextSpecial :=RGB(255,165,0)
       oFld1:aPanels[n]:lOverTitle  :=.f.
       oFld1:aPanels[n]:oFont:=  oFontTitle
       oFld1:aPanels[n]:nTopMargin := 1
    next


      oFld2 := TEXplorerBar():New( 0, 0, nWidth - 5, , oWnd)
      oFld2:nTopColor     := RGB( 240,240,240)
      oFld2:nBottomColor  := RGB( 240,240,240)

      oBtn2:=  oFld2:AddPanel("
Name Panel 2", cFolderBmps+"case.bmp"  ,80 )
      oBtn6:=  oFld2:AddPanel("
Name Panel 6", cFolderBmps+"case.bmp"  ,80 )
      oBtn7:=  oFld2:AddPanel("
Name Panel 7", cFolderBmps+"case.bmp"  ,80 )


      For n=1 to len(oFld2:aPanels)
       oFld2:aPanels[n]:nRound  := 0
       oFld2:aPanels[n]:aGradient := { { CLR_WHITE, CLR_WHITE }, {CLR_WHITE, CLR_WHITE } }
       oFld2:aPanels[n]:nTitleHeight := 40
       oFld2:aPanels[n]:lCollapsed :=.f.
       oFld2:aPanels[n]:lSpecial = .t.
       oFld2:aPanels[n]:oBrush:=  oBrush1
       oFld2:aPanels[n]:nClrTextSpecial :=RGB(255,165,0)
       oFld2:aPanels[n]:lOverTitle  :=.f.
       oFld2:aPanels[n]:oFont:=  oFontTitle
       oFld2:aPanels[n]:nTopMargin := 1
    next


      @ ID_TOP,nSplit+2 SPLITTER oSplit ;
              VERTICAL ;
              PREVIOUS CONTROLS oFld1 ;
              HINDS    CONTROLS oFld2 ;
              LEFT MARGIN 1 ;
              RIGHT MARGIN 1 ;
              SIZE 0.5, nHeight - 98 PIXEL ;
              ON CHANGE DoResize( oWnd, oSplit, oFld1, oFld2 ) ;
              COLOR CLR_BLUE ;
              OF oWnd


     oSplit:lStatic:=.t.
     oSplit:AdjLeft()


    oWnd:aMinMaxInfo := { nil, nil, ,, 750,550, , }

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

RETURN NIL


PROCEDURE DoResize( oWnd, oSplit, oFld1, oFld2 )

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 )



   // ************************ 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 )



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

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



   oWnd:Refresh()
RETURN



On Init I have

Image


If I iconize the window and then call the window I have a wrong wnd

Image


and when I put maximized the wnd I have

Image

I wish move the splitter where you see the red line
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests

cron