TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby Silvio » Thu Jul 30, 2009 5:19 pm

I want insert on a dialog 3 tabs and only on first and second a want insert a panel with a scroll (Tscrwnd class) while on third tab I want insert a Empty dialog
How I must make it ?
I must create two panels one for each tabs ?

I made a test but not run ok and I see a black color into

thanks in advance




Code: Select all  Expand view  RUN
#include "FiveWin.ch"



#define LIGHTORANGE1 nRGB( 250, 227, 143 )
#define DARKCYAN     nRGB( 125, 165, 224 )


static oScrWnd,otab,odlg

Function main()

Local oDlg
Local OTab
Local oPanel,oPanel1
Local nSplit := 50
Local oScrWnd


DEFINE DIALOG  oDlg  SIZE 800,600

oPanel:= TPanel():New(40,10,200,400,oDlg)
      // oPanel:nClrPane :=   LIGHTORANGE1

//oPanel1:= TPanel():New(40,nSplit+5,oDlg:nBottom,oDlg:nwidth,oDlg)

  @ oPanel:nBottom, 10 TABS oTab   ;
        SIZE oPanel:nWidth(), 12 PIXEL OF oDlg

          oTab:aPrompts ={ "&One", "&Two", "T&hree" }
          oTab:noption:=2

Activate Dialog oDlg ;
on init (oScrWnd:=TScrWnd():New( oPanel,1,40,1,70),test(otab))

return nil


Function test (otab)

if oTab:noption = 1
   
    @ 10,1 say " panel & tab 1 " of otab
elseif oTab:noption = 2
@ 10,1 say " panel & tab 2 " of otab

ENDIF

RETURN NIL











#ifndef TRUE
   #define TRUE              .T.
   #define FALSE             .F.
#endif

#define D_WIDTH           4
#define D_HEIGHT          13

CLASS TScrWnd   FROM TCONTROL

   DATA oMAx
   DATA nVPos,nHPos

   METHOD New( oMAx,nV1,nV2,nH1,nH2 ) CONSTRUCTOR
   METHOD SetScroll( nV1,nV2,nH1,nH2 )
   //-*------------------------------------------------------------
   METHOD VScroll()
   METHOD VScrollThumb()
   METHOD VScrollTrack()
   METHOD VScrollPgDown()
   METHOD VScrollPgUp()
   //-*-----------------------------
   METHOD HScroll()
   METHOD HScrollThumb()
   METHOD HScrollTrack()
   METHOD HScrollPgDown()
   METHOD HScrollPgUp()

ENDCLASS

METHOD New( oMAx,nV1,nV2,nH1,nH2 ) CLASS TScrWnd
   ::nVPos := 0
   ::nHPos := 0
   ::oMAx := oMAx
   DEFINE SCROLLBAR ::oMAx:oVScroll VERTICAL OF ::oMAx
   DEFINE SCROLLBAR ::oMAx:oHScroll HORIZONTAL OF ::oMAx
   ::SetScroll( nV1,nV2,nH1,nH2 )
   ::oMAx:bMouseWheel = { | nKey, nDelta, nXPos, nYPos |If( nDelta < 0, ::oMAx:oVScroll:GoDown(), ::oMAx:oVScroll:GoUp() ) }
RETURN Self


METHOD SetScroll( nV1,nV2,nH1,nH2 ) CLASS TScrWnd
LOCAL aCoors1:={},aCoors2:={}
   //--------------------------------------------------
   //-* Vertical Scroll Bar
//   ? ::oMAx:oVSCroll=NIL
   if ::oMAx:oVScroll != NIL
//    ? nV1,nV2
      ::oMAx:oVScroll:SetRange( nV1,nV2 )
      ::nVPos := ::oMAx:oVScroll:GetPos()
      ::oMAx:oVScroll:bGoDown   := {|| ::VScroll() }
      ::oMAx:oVScroll:bGoUp     := {|| ::VScroll() }
      ::oMAx:oVScroll:bPageUp   := {|| ::VScrollPgUp() }
      ::oMAx:oVScroll:bPageDown := {|| ::VScrollPgDown() }
      ::oMAx:oVScroll:bGoTop    := {|| ::VScroll() }
      ::oMAx:oVScroll:bGoBottom := {|| ::VScroll() }
      ::oMAx:oVScroll:nPgStep   := 10
      //::oMAx:oVScroll:lReDraw := TRUE
      ::oMAx:oVScroll:bPos      := {|nPos| ::VScrollThumb(nPos) }
      ::oMAx:oVScroll:bTrack    := {|nPos| ::VScrollTrack(nPos) }
   endif
   //--------------------------------------------------
   //-* Horizontal Scroll Bar
   if ::oMAx:oHScroll != NIL
      ::oMAx:oHScroll:SetRange( nH1,nH2 )
      ::nHPos := ::oMAx:oHScroll:GetPos()
      ::oMAx:oHScroll:bGoDown   := {|| ::HScroll() }
      ::oMAx:oHScroll:bGoUp     := {|| ::HScroll() }
      ::oMAx:oHScroll:bPageUp   := {|| ::HScrollPgUp() }
      ::oMAx:oHScroll:bPageDown := {|| ::HScrollPgDown() }
      ::oMAx:oHScroll:bGoTop    := {|| ::HScroll() }
      ::oMAx:oHScroll:bGoBottom := {|| ::HScroll() }
      ::oMAx:oHScroll:nPgStep   := 10
      //::oMAx:oHScroll:lReDraw := TRUE
      ::oMAx:oHScroll:bPos      := {|nPos| ::HScrollThumb(nPos) }
      ::oMAx:oHScroll:bTrack    := {|nPos| ::HScrollTrack(nPos) }
   endif
   //::oMAx:bKeyChar := {|nKey,nFlags| ScrollKey(nKey) }
   //--------------------------------------------------
RETURN( NIL )

//STATIC FUNCTION ScrollKey(nKey)
   //MsgInfo( "Key : "+str(nKey,10) )
   //if nKey == K_ENTER
   //   goMainDlg:End()
   //   lRetVal := TRUE
   //endif
//RETURN( NIL )

//=================================================================
//-* Vertical Scroll Bar
METHOD VScroll() CLASS TScrWnd
LOCAL nNewPos
   if ::nVPos >= ::oMAx:oVScroll:nMin   ;
      .and. ::nVPos <= ::oMAx:oVScroll:nMax
      nNewPos := ::oMAx:oVScroll:GetPos()
      SysRefresh()

      ScrollWindow( ::oMAx:hWnd, 0,  ;
         (  ::nVPos-nNewPos )*D_HEIGHT,    ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nVPos := nNewPos
   endif
RETURN( NIL )

METHOD VScrollThumb(nNewPos) CLASS TScrWnd
   if ::nVPos >= ::oMAx:oVScroll:nMin   ;
      .and. ::nVPos <= ::oMAx:oVScroll:nMax
      ::oMAx:oVScroll:SetPos(nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd, 0,  ;
         (::nVPos - nNewPos )*D_HEIGHT,    ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nVPos := nNewPos
   endif
RETURN( NIL )

METHOD VScrollTrack(nNewPos) CLASS TScrWnd
   if ::nVPos >= ::oMAx:oVScroll:nMin   ;
      .and. ::nVPos <= ::oMAx:oVScroll:nMax
      ::oMAx:oVScroll:SetPos(nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd, 0,  ;
         (::nVPos - nNewPos )*D_HEIGHT,    ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nVPos := nNewPos
   endif
RETURN( NIL )

METHOD VScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
   if ::nVPos < ::oMAx:oVScroll:nMax
      nNewPos := ::nVPos + ::oMAx:oVScroll:nPgStep
      nNewPos := iif(nNewPos > ::oMAx:oVScroll:nMax, ::oMAx:oVScroll:nMax, nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd, 0,  ;
         ( ::nVPos - nNewPos )*D_HEIGHT,    ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nVPos := nNewPos
   endif
RETURN( NIL )

METHOD VScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
   if ::nVPos > ::oMAx:oVScroll:nMin
      nNewPos := ::nVPos - ::oMAx:oVScroll:nPgStep
      nNewPos := iif(nNewPos < ::oMAx:oVScroll:nMin,::oMAx:oVScroll:nMin,nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd, 0,  ;
         ( ::nVPos - nNewPos )*D_HEIGHT,    ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nVPos := nNewPos
   endif
RETURN( NIL )

//=================================================================
//-* Horizontal Scroll Bar
METHOD HScroll() CLASS TScrWnd
LOCAL nNewPos
   if ::nHPos >= ::oMAx:oHScroll:nMin   ;
      .and. ::nHPos <= ::oMAx:oHScroll:nMax
      nNewPos := ::oMAx:oHScroll:GetPos()
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd,           ;
         (::nHPos - nNewPos )*D_WIDTH,0,   ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nHPos := nNewPos
   endif
RETURN( NIL )

METHOD HScrollThumb(nNewPos) CLASS TScrWnd
   if ::nHPos >= ::oMAx:oHScroll:nMin   ;
      .and. ::nHPos <= ::oMAx:oHScroll:nMax
      ::oMAx:oHScroll:SetPos(nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd,           ;
         (::nHPos - nNewPos )*D_WIDTH,0,   ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nHPos := nNewPos
   endif
RETURN( NIL )

METHOD HScrollTrack(nNewPos) CLASS TScrWnd
   if ::nHPos >= ::oMAx:oHScroll:nMin   ;
      .and. ::nHPos <= ::oMAx:oHScroll:nMax
      ::oMAx:oHScroll:SetPos(nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd,           ;
         (::nHPos - nNewPos )*D_WIDTH,0,   ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nHPos := nNewPos
   endif
RETURN( NIL )

METHOD HScrollPgDown() CLASS TScrWnd
LOCAL nNewPos
   if ::nHPos < ::oMAx:oHScroll:nMax
      nNewPos := ::nHPos + ::oMAx:oHScroll:nPgStep
      nNewPos := iif(nNewPos > ::oMAx:oHScroll:nMax, ::oMAx:oHScroll:nMax, nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd,           ;
         ( ::nHPos - nNewPos )*D_WIDTH,0,  ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nHPos := nNewPos
   endif
RETURN( NIL )

METHOD HScrollPgUp() CLASS TScrWnd
LOCAL nNewPos
   if ::nHPos > ::oMAx:oHScroll:nMin
      nNewPos := ::nHPos - ::oMAx:oHScroll:nPgStep
      nNewPos := iif(nNewPos < ::oMAx:oHScroll:nMin,::oMAx:oHScroll:nMin,nNewPos)
      SysRefresh()
      ScrollWindow( ::oMAx:hWnd,           ;
         ( ::nHPos - nNewPos )*D_WIDTH,0,  ;
         0 , GetClientRect(::oMAx:hWnd) )
      ::nHPos := nNewPos
   endif
RETURN( NIL )
 
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby fafi » Sat Aug 01, 2009 12:16 am

Hi Guys..!!
Greeting from Indonesia

This is working sample :
Code: Select all  Expand view  RUN

#include "FiveWin.ch"

#define LIGHTORANGE1 nRGB( 250, 227, 143 )
#define DARKCYAN     nRGB( 125, 165, 224 )


static oScrWnd,otab,odlg,oPanel,lFirst,oSay1,oSay2,oGet,cGet,oBrush,oBrush1

Function main()

Local nSplit := 50


cGet := "FAFI is GOOD MAN"
DEFINE BRUSH oBrush COLOR LIGHTORANGE1

DEFINE BRUSH oBrush1 COLOR DARKCYAN

DEFINE DIALOG  oDlg  SIZE 800,600 STYLE nOR( WS_CAPTION )

oPanel:= TPanel():New(40,10,200,400,oDlg)

     
lFirst := .t.



  @ oPanel:nBottom+2, 10 TABS oTab   ;
        SIZE oPanel:nWidth(), 12 PIXEL OF oDlg action Cek(oTab)

          oTab:aPrompts ={ "&One", "&Two", "T&hree","e&Xit" }
          oTab:noption:=2

         

Activate Dialog oDlg ;
on init (oScrWnd:=TScrWnd():New( oPanel,1,40,1,70),Cek(oTab))

return nil

static function Cek(oTab)

if lFirst
   oPanel:SetBrush(oBrush)
   oPanel:Refresh()

    @ 10,1 say  oSay1 prompt " panel & tab 1 " of oPanel COLOR CLR_BLACK,LIGHTORANGE1
    @ 10,1 say  oSay2 prompt " panel & tab 2 " of oPanel COLOR CLR_BLACK,DARKCYAN
   
    @ 20,100 get oGet var cGet size 100,20 of oPanel pixel
   
    oPanel:Refresh()
   
    lFirst := .f.
endif

if oTab:noption = 1
   oSay2:Hide()
    oSay1:Show()
    oPanel:SetBrush(oBrush)
    oPanel:Refresh()
elseif oTab:noption = 2
    oSay1:Hide()
    oSay2:Show()
    oPanel:SetBrush(oBrush1)
    oPanel:Refresh()
elseif oTab:noption = 3
    oSay1:Hide()
    oSay2:Hide()
elseif oTab:noption = 4
    oDlg:End() 
ENDIF


return nil
 


Best Regards
Fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby James Bott » Sat Aug 01, 2009 3:59 pm

Silvio,

As I said in my last email you still need to add this line to get the tabs working.

oPanel:oBottom:= oTab

Then you can show/hide any dialogs or browses when the tabs are clicked.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby Silvio » Sat Aug 01, 2009 4:47 pm

not run ok
because on a first panel-tab i must insert the umbrellas, on the second i must insert colored box, and to another only says.
when i select the tabs the firt time run ,then it make error on tab DEF CONTROL .
on first tab i use a function where i draw all umbrellas perhaps it make error because it make another cicle do while with dbf.
I'd like insert all in a dialog but for now i think i must create two dialogs because one dialog and 3 tab with 3 tpanel into not run ok.
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby James Bott » Sat Aug 01, 2009 6:19 pm

Silvio,

>on first tab i use a function where i draw all umbrellas perhaps it make error because it make another cicle do while with dbf.

I assume you mean you are drawing on the panel not the tab.

When you click on another tab, you have to hide what is already on the panel, then display something else. It is easier to put a dialog on the panel then draw on that since then you only have to hide the dialog, then display another one.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby Silvio » Wed Aug 05, 2009 12:15 pm

LET ME ERROR ON TPANEL
DEF CONTROL
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby James Bott » Thu Aug 06, 2009 12:48 am

Silvio,

Did you get the tabs working?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby Silvio » Thu Aug 06, 2009 12:21 pm

do U remember the umbrellas ?
On first tab but on a tpanel I call a function make_umbrellas (), and on second tab I call another functio make_sectors().
Good, the firsy function is on two parts one where i search orders into dbf from dDataTo dData and show umbrellas, the second part i change only the bitmaps . the second function draw a grid on monitor to insert bitmaps to insert colored sectors.
On first functio i use two dbf and on second one dbf.
When I click on first tab it make the lap on first function and draw the umbrellas but it is too slow, then i click on second tab and it make a call to second function.
ok?
Good, now i want click on first tab and it make error DEF CONTROL ON TPANEL
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: TO ANTONIO AND ALL : TABS, PANELs WITH SCROLLS

Postby James Bott » Thu Aug 06, 2009 2:41 pm

OK, so you have the tabs working.

It sounds like you are still trying to draw everything on the same panel. As I suggested, it would be better to draw the tab1 items on a dialog (which is on the panel) and the tab2 items on a different dialog. So, when you click on tab1 you hide dialog2 and show dialog1 and when you click on tab2, you do the opposite.

Redrawing everything each time the user switches panels is going to be much slower (provided you could even get it working without error).

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 12 guests

cron