FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Pickdate
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Tue Jul 29, 2008 08:14 AM

Here you have the PRG (with some more changes) and the EXE:

http://www.mediafire.com/?t0mymexcjje

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Tue Jul 29, 2008 08:18 AM
A little obvious typo:

   METHOD  PreviousYear() INLINE ::nYear--, ::Refresh()
   METHOD  NextYear() INLINE ::nYear++, ::Refresh()
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Tue Jul 29, 2008 08:36 AM
Some gradients to make it nicer :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Tue Jul 29, 2008 08:39 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Pickdate
Posted: Tue Jul 29, 2008 08:56 AM

Antonio,

thank you very much.
Now I will try to get the functionality I had (MOVEMOUSE) into the new class design.
Regards,
Otto

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Tue Jul 29, 2008 09:27 AM

Otto,

What do you need mousemove for ?

If you want to change a dates range, maybe we could use right click, or similar.

The easier you make it for the final user, the better.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Pickdate
Posted: Tue Jul 29, 2008 11:02 AM
Antonio, here is what I want to do.

Regards,
Otto

http://www.atzwanger.com/sniptv/calender/calender.html
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Pickdate
Posted: Tue Jul 29, 2008 03:30 PM

I think Otto want the user can select from a date to another with the mouse , the movement must colorize the box where there are the numbers of the days

When the user not press the click the mouse the procedure must return how many day he selected from date a to date b

Right, Otto ?

Best Regards, Saludos



Falconi Silvio
Posts: 632
Joined: Thu Jan 19, 2006 10:45 AM
Pickdate
Posted: Wed Jul 30, 2008 06:34 PM
Antonio and Otto would you mind the possibility to include and aPrompt and aBmp in the tPickData class.

Saludos



Andrés González desde Mallorca
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Pickdate
Posted: Wed Jul 30, 2008 06:39 PM

Dear Andres,
before the mousemose movement is max important
then we can think to insert bitmaps or ctext

Best Regards, Saludos



Falconi Silvio
Posts: 632
Joined: Thu Jan 19, 2006 10:45 AM
Pickdate
Posted: Wed Jul 30, 2008 06:46 PM

Thanks Sylvio, just an idea.

Saludos



Andrés González desde Mallorca
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Pickdate
Posted: Wed Jul 30, 2008 09:12 PM
Hello Antonio,

I tried to insert mousemove in the control class design.
I works but performance is bad. The class I had performs much better.
Is this normal that a control is slower or did I made a mistake by inserting the mouse move method.
Would you be so kind to check the code. Thanks in advance.
Otto







#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd, oPickDate

   DEFINE WINDOW oWnd TITLE "Calendar"

   oPickDate := TPickDate():New( 10, 10,,, oWnd )

   oWnd:oClient = oPickDate

   ACTIVATE WINDOW oWnd MAXIMIZED

return nil

//----------------------------------------------------------------------------//

CLASS TPickDate FROM TControl

   DATA    dStart, dEnd,lMove
   DATA    ClickRow,  hBru
   DATA    ClickCol
   DATA    nYear, syTemp

   CLASSDATA lRegistered AS LOGICAL

   METHOD  New( nTop, nLeft, nWidth, nHeight, oWnd, nYear, nClrFore, nClrBack )
   METHOD  Paint()
   METHOD  Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
   METHOD  LButtonDown( nRow, nCol, nFlags )
   METHOD  LButtonUp( nRow, nCol, nFlags )

   METHOD  PreviousYear() INLINE ::nYear--, ::Refresh()
   METHOD  NextYear() INLINE ::nYear++, ::Refresh()
   METHOD  EraseBkGnd( hDC ) INLINE 0

   METHOD  MouseMove( nRow, nCol, nKeyFlags )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, nWidth, nHeight, oWnd, nYear, nClrFore, nClrBack ) CLASS TPickDate

   DEFAULT nWidth    := 800,;
      nHeight   := 300,;
      nLeft     := 0,;
      nTop      := 0,;
      nYear     := Year( Date() ),;
      oWnd      := GetWndDefault()

   ::lMove      :=.f.

   ::nTop       = nTop
   ::nLeft      = nLeft
   ::nBottom    = nTop + nHeight - 1
   ::nRight     = nLeft + nWidth - 1
   ::nYear      = Year( Date() )
   ::oWnd       = oWnd
   ::nClrText   = nClrFore
   ::nClrPane   = nClrBack
   ::nStyle     = nOr( WS_CHILD, WS_VISIBLE, WS_TABSTOP, WS_BORDER )
   ::syTemp:=0
   ::hBru        := CreateSolidBrush( RGB(255,0,0) )


   ::ClickRow  := 0
   ::ClickCol  := 0
   ::nHeight   := 0
   ::nWidth    := 0


   DEFINE FONT ::oFont NAME "Tahoma" SIZE 0, -12

   #ifdef __XPP__
   DEFAULT ::lRegistered := .F.
   #endif

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )

   if ! Empty( oWnd:hWnd )
      ::Create()
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
   endif

return self

//----------------------------------------------------------------------------//

METHOD Paint() CLASS TPickDate

   //  local aInfo := ::DispBegin(), nRowStep, nColStep, n, dDate
   local hDC := ::hDC, cDay, oBrush, nDay, oFont := ::oFont

   FillRect( hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )

   DEFINE BRUSH oBrush COLOR nRGB( 183, 249, 185 ) // Sundays column green brush

   nRowStep = ::nHeight / 13

   //GradientFill( hDC, 0, 0, ::nHeight, ::nWidth, { { 1, nRGB( 128, 217, 255 ), nRGB( 54, 147, 255 ) } } )

   for n = 1 to 12
      ::Line( n * nRowStep, 0, n * nRowStep, ::nWidth - 1 )
      ::Say( n * nRowStep + ( nRowStep / 2 ) - ( oFont:nHeight / 2 ), 3, cMonth( CToD( Str( n, 2 ) + "/01/" + ;
         Str( Year( Date() ), 4 ) ) ),,, oFont, .T., .T. )
   next

   dDate = CToD( "06/01/" + Str( ::nYear, 4 ) )
   nColStep = ( ::nWidth - 60 ) / 37

   //   GradientFill( hDC, 0, 0, nRowStep - 1, ::nWidth, { { 1, nRGB( 128, 217, 255 ), nRGB( 54, 147, 255 ) } } )

   ::Say( ( nRowStep / 2 ) - ( oFont:nHeight / 2 ),;
      ( ( 60 + nColStep ) / 2 ) - ( GetTextWidth( hDC, Str( ::nYear, 4 ), ::oFont:hFont ) / 2 ),;
      Str( ::nYear, 4 ),,, oFont, .T., .T. )


   for n = 1 to 36 step 7
      FillRect( hDC, { 0, 60 + ( nColStep * n ), ::nHeight - 1, 60 + ( nColStep * ( n + 1 ) ) }, oBrush:hBrush )
   next

   IF ::lMove=.t.

      FillRect(hDC, {::ClickRow,;
         ::ClickCol,;
         ::ClickRow + ( ::nHeight / 13 ),;
         ::syTemp}, ::hBru )
   ENDIF

   for n = 1 to 36
      ::Line( 0, 60 + ( nColStep * n ), ::nHeight - 1, 60 + ( nColStep * n ) )
      cDay = SubStr( CDoW( dDate ), 1, 2 )
      ::Say( nRowStep * 0.4,;
         60 + ( nColStep * n ) + ( nColStep / 2 ) - ( GetTextWidth( hDC, cDay, oFont:hFont ) / 2 ) + 1,;
         cDay, 0, If( DoW( dDate++ ) == 1, nRGB( 128, 233, 176 ),), oFont, .T., .T. )
   next

   for n = 1 to 12
      dDate = CToD( Str( n ) + "/01/" + Str( ::nYear, 4 ) )
      nDay = DoW( dDate )
      while Month( dDate ) == n
         cDay = AllTrim( Str( Day( dDate ) ) )
         ::Say( n * nRowStep + ( nRowStep * 0.4 ),;
            60 + ( nColStep * nDay++ ) + ( nColStep / 2 ) - ( GetTextWidth( hDC, cDay, oFont:hFont ) / 2 ) + 1,;
            cDay, 0, If( ! Empty( ::dStart ) .and. dDate >= ::dStart .and. dDate <= ::dEnd, nRGB( 178, 204, 235 ),;
            If( DoW( dDate ) == 1, nRGB( 128, 233, 176 ),) ), oFont, .T. )
         dDate++
      end
   next

   //  ::DispEnd( aInfo )

   oBrush:End()

return 0

//----------------------------------------------------------------------------//

METHOD LButtonDown( nRow, nCol, nFlags ) CLASS TPickDate

   local nMonth := Int( nRow / ( ::nHeight / 13 ) )
   local nDay   := Int( ( nCol - 60 ) / ( ( ::nWidth - 60 ) / 37 ) ) - ;
      DoW( CToD( Str( nMonth ) + "/01/" + Str( ::nYear, 4 ) ) ) + 1
   local dDate  := CToD( AllTrim( Str( nMonth ) ) + "/" + AllTrim( Str( nDay ) ) + "/" + Str( ::nYear, 4 ) )

   ::lMove:=.t.

   ::ClickRow   := Int( nRow / ( ::nHeight / 13 ) )    * ( ::nHeight / 13 )
   ::ClickCol   := Int( ( nCol - 60 ) / ( ( ::nWidth - 60 ) / 37 ) ) * ( ( ::nWidth - 60 ) / 37 )  + 60

return nil

//-----------------------------------------------------------------//

METHOD LButtonUp( nRow, nCol, nFlags ) CLASS TPickDate
   ::lMove:=.f.
return nil

//-----------------------------------------------------------------//

METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TPickDate

   if ::lMove = .t.

      ::syTemp := Int( ( nCol - 60 ) / ( ( ::nWidth - 60 ) / 37 ) ) * ( ( ::nWidth - 60 ) / 37 )  + 60   + ( ( ::nWidth - 60 ) / 37 )
      ::Paint()

      ::refresh()

   endif

   // ::Say(  nRow+10 ,nCol,str( ::nYear, 4 ),,,::oFont, .T., .T. )


return nil
*/
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pickdate
Posted: Wed Jul 30, 2008 11:02 PM

Otto,

You only have to call ::Refresh() and not ::Paint().

::Refresh() will request a paint.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Pickdate
Posted: Wed Jul 30, 2008 11:39 PM

Otto,

Although calls to Paint() and Refresh() will work they are going to be slow. For speed, what you want to do is redraw only the old highlight (as unhighlighted) and the new highlighted area--not the entire screen. Right now you are redrawing the entire screen twice for each mouse movement.

For ideas how a similar MouseMove() works, take a look at TWBrowse(). Note that it inherits from TControl which inherits from TWindow, so take a look at the MouseMove() methods in those classes also. I am not saying that your MouseMove method should work the same as TWBrowse's, but you can see how it processes the information and when it calls the parent class.

Note also that your MouseMove() method should return 0 not nil.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Pickdate
Posted: Thu Jul 31, 2008 05:45 AM

Hello Antonio, hello James,

I eliminated the call for Paint method.
But with not much success. The painting of the days is very slow.
I turned off double buffering. You can see how the rows get painted.

In my wrapped class design the painting is optimal . Please see the video or try the exe.

I can’t find out the problem in the new code.

James you are right with you advice to repaint only the changes. But that is much more work.
And as the whole repainting in my initial project works so well I don’t think it is necessary.

Regards,
Otto