Dialog with a splitter and panels

Dialog with a splitter and panels

Postby Silvio.Falconi » Thu Mar 17, 2022 11:48 am

I created a dialog with two panels, one green and one white. between the two panels there is a splitter. When I move the splitter to the right the white panel does not move and at the same time the green panel remains stationary ie it does not move towards the splitter. The same happens if I move the splitter to the left.

How can I solve? ( I need to use a dialog and not a window)


Image


Test_Source

Code: Select all  Expand view
#include "Fivewin.ch"
#include "constant.ch"
#include "splitter.ch"



// test dialog with two panel and splitter

Function Test()
   local  oDlg,oFont,oBold,oFld
   local  nBottom   := 33
   local  nRight    := 80
   local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
   local  nHeight   := nBottom * DLG_CHARPIX_H
   local oPanelImg,oPanelFolder,oBtnPrint,oBtnClose
   local nSplit:= 200
   local oSplit



   DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -12
      DEFINE DIALOG oDlg  SIZE nWidth, nHeight TRANSPARENT  PIXEL TRUEPIXEL RESIZABLE ;
      TITLE 'test ' COLOR CLR_BLACK,  nRgb( 245,244,234) FONT oFont



     @ 100,10 BUTTON oBtnPrint PROMPT "Confirm" of oDlg SIZE 80,22 ACTION NIL
     @ 100,10 BUTTON oBtnClose PROMPT "Close" of oDlg SIZE 80,22 ACTION oDlg:End()



          oDlg:bResized  := <||
          oRect                := oDlg:GetCliRect()

                oBtnPrint:nLeft    := oRect:nRight - 200
                oBtnPrint:nTop     := oRect:nBottom - 40
                oBtnClose:nLeft    := oRect:nRight - 100
                oBtnClose:nTop     := oRect:nBottom - 40



               if oPanelImg != nil
                  oPanelImg:nTop     := oRect:ntop
                  oPanelImg:nLeft    := oRect:nleft+2
                  oPanelImg:nwidth   := nSplit-2
                  oPanelImg:nBottom   := oBtnPrint:nTop-2
               Endif

                if oPanelFolder != nil
                  oPanelFolder:nTop     := oRect:ntop
                  oPanelFolder:nLeft    := nSplit+2
                  oPanelFolder:nwidth   := oRect:nWidth-205
                  oPanelFolder:nBottom  := oBtnPrint:nTop-2
                Endif






                  if oSplit != nil
                     oSplit:Setsize( oSplit:nWidth, oRect:nBottom -40 )
                     oSplit:Refresh()
                  Endif


  return nil
                       >

 ACTIVATE DIALOG oDlg centered ;
       ON INIT ( oPanelImg:= PanelGreen(oDlg,nSplit),;
                 oPanelFolder:=PanelWhite(oDlg,nSplit),;
                 BuildSplitter(oPanelImg,oPanelFolder,oDlg,oSplit,nSplit,oBtnPrint),;
                 Eval(oDlg:bResized  ) )

    RELEASE FONT oFont, oBold

return nil
//--------------------------------------------------------------------------------------//
 Static function PanelGreen(oDlg,nSplit)
  local oPanel,oBrushGreen
  Local aGradgreen := { Rgb( 225,239,219),Rgb( 225,239,219)}
  DEFINE BRUSH oBrushGreen GRADIENT aGradgreen
     oPanel:=Tpanel():New( 45, 2, oDlg:nBottom, nSplit, oDlg)
     oPanel:SetBrush( oBrushGreen )
     oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     return oPanel
//--------------------------------------------------------------------------------------//
  Static function PanelWhite(oDlg,nSplit)
  local oPanel,oBrushWhite
  Local aGradWhite := { Rgb( 245,245,245),Rgb( 245,245,245)}
  DEFINE BRUSH oBrushWhite GRADIENT aGradWhite
     oPanel:=Tpanel():New( 45, nSplit+2, oDlg:nBottom, oDlg:nWidth-10, oDlg)
     oPanel:SetBrush( oBrushWhite )
     oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     return oPanel
//------------------------------------------------------------------------//
static Function BuildSplitter(oPanelImg,oPanelFolder,oDlg,oSplit,nSplit,oBtnPrint)

    @ 00, nSplit SPLITTER oSplit ;
      VERTICAL ;
      PREVIOUS CONTROLS oPanelImg ;
      HINDS CONTROLS oPanelFolder ;
      LEFT MARGIN 2 ;
      RIGHT MARGIN 2 ;
      SIZE 1, oDlg:nBottom-40  PIXEL ;
      OF oDlg ;
      _3DLOOK ;
      UPDATE STYLE

      oSplit:bchange := { ||ResizeDialog(oSplit,oDlg,oBtnPrint,oPanelImg,oPanelFolder,nSplit) }

        RETURN NIL
//------------------------------------------------------------------------//
Function ResizeDialog(oSplit,oDlg,oBtnPrint,oPanelImg,oPanelFolder,nSplit)
   local   oRect     := oDlg:GetCliRect()
   
            if oSplit != nil
            oSplit:Setsize( oSplit:nWidth, oRect:nHeight-60 )
            oSplit:Refresh()
         Endif

           if oPanelImg != nil
                  oPanelImg:nTop     := oRect:ntop
                  oPanelImg:nLeft    := oRect:nleft+2
                  oPanelImg:nwidth   := nSplit-2
                  oPanelImg:nBottom   := oBtnPrint:nTop-2
               Endif

                if oPanelFolder != nil
                  oPanelFolder:nTop     := oRect:ntop
                  oPanelFolder:nLeft    := nSplit+2
                  oPanelFolder:nwidth   := oRect:nWidth-205
                  oPanelFolder:nBottom  := oBtnPrint:nTop-2
                Endif





     RETURN NIL
 


apparently inserting the creation of the splitter in a function after the creation of the panels could work but when I go to resize the dialog the two panels remain at the same size and are not above the two buttons
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: 7061
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 74 guests

cron