COULD U HELP ME PLEASE ?
I explain you how I thinked it
I thinked to divide all into 4 areas : top_left, Left, center_right_top, center.
on top_left we insert a title
on Left we insert the list of Hours ( from 00:00 to 24:00)
center_right_top we insert the calendar ( a week,or a mounth, or 3days)
center we insert the graphics
all parts are as a panel control but only on the area center i can move and click the mouse and draw the graphics
we called them : oTitle,oDays,oHours,oGraph
the oHours can be ltime1, ltime15, ltime30, ltime45 - sample 00:00 , 00:15, 00:30, 00:45 -
the oHours is static ( I used an arra to create it) but we can use easy a xbrowse to show it
the test
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "Constant.ch"
#include 'xbrowse.ch'
#include "Splitter.ch"
#DEFINE TRUE .T.
#DEFINE FALSE .F.
#define HSTEP 20
#define VSTEP 25
#define GRIDROW 50
#define GRIDCOL 50
#define TA_LEFT 0
#define TA_RIGHT 2
#define TA_CENTER 6
REQUEST DBFCDX, DBFFPT
external ordkeyno, ordkeycount,ordcreate
STATIC oWnd,oTitle,oDays,oHours,oGraph
STATIC oFont
STATIC oSplit1,oSplit2
STATIC nHoriz1, nHoriz2
STATIC ltime1, ltime15, ltime30, ltime45
STATIC oPenL,oPenR
STATIC oPen1,oPen2,oPen3,oPen4
STATIC nGridCol := GRIDCOL
STATIC nGridRow := GRIDROW
Function test()
nVertic := 0
nHoriz1 := 0
nHoriz2 := 0
RddSetDefault( "DBFCDX" )
SetHandleCount( 128 )
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-8 BOLD
DEFINE WINDOW oWnd TITLE "NEW FW CALENDAR"
DEFINE BUTTONBAR obar 3D OF oWnd SIZE 42,42 2007
SET MESSAGE OF oWnd TO "New FW Calendar " KEYBOARD CLOCK DATE NOINSET 2007
// type of timeline
ltime15:=.f.
ltime30:=.f.
ltime45:=.f.
//TITLE
oTitle:=TCalendarOffice():New(40,0,200,28,oWnd,FALSE)
oTitle:bPainted := {|| Title() }
//Days
oDays:=TCalendarOffice():New(40,100,400,40,oWnd,FALSE)
oDays:bPainted := {|| Week() }
//TIME
oHours:=TCalendarOffice():New(65,0,100,300,oWnd,FALSE)
oHours:bPainted := {|| Hours() }
// GRAPHICS // ONLY FOR THIS i USE THE MOUSE DRAW
oGraph:=TCalendarOffice():New(65,100,400,300,oWnd,TRUE)
oGraph:bPainted := {|| Graphics() }
oGraph:nGridCol := GRIDCOL
oGraph:nGridRow := GRIDROW
@ 65,0 SPLITTER oSplit1 WINDOW oWnd ;
HORIZONTAL ;
PREVIOUS CONTROLS oTitle ;
HINDS CONTROLS oHours ;
SIZE 200,0 PIXEL
@ 65,205 SPLITTER oSplit2 WINDOW oWnd ;
HORIZONTAL ;
PREVIOUS CONTROLS oDays ;
HINDS CONTROLS oGraph ;
SIZE 400,0 PIXEL
oSplit1:lStatic := .t. ; oSplit1:Hide()
oSplit2:lStatic := .t. ; oSplit2:Hide()
@ 0, 100 SPLITTER oSplit WINDOW oWnd ;
VERTICAL ;
PREVIOUS CONTROLS oTitle, oSplit1, oHours ;
HINDS CONTROLS oDays, oSplit2, oGraph ;
LEFT MARGIN 50 ;
RIGHT MARGIN 70 ;
SIZE 1, 336 PIXEL ;
3DLOOK
nVertic := 0
nHoriz1 := 0
nHoriz2 := 0
DEFINE SCROLLBAR oHours:oHScroll OF oHours ;
HORIZONTAL ;
RANGE 0, 200/HSTEP ;
PAGESTEP 5;
ON UP ( nHoriz1 += HSTEP, HScroll1() ) ;
ON DOWN ( nHoriz1 -= HSTEP, HScroll1() ) ;
ON PAGEUP ( nHoriz1 += 5*HSTEP, HScroll1() ) ;
ON PAGEDOWN ( nHoriz1 -= 5*HSTEP, HScroll1() ) ;
ON THUMBPOS ( nHoriz1 -= ( nPos-oHours:oHScroll:GetPos() )*HSTEP, ;
oHours:oHScroll:SetPos(nPos), ;
HScroll1() )
DEFINE SCROLLBAR oGraph:oHScroll OF oGraph ;
HORIZONTAL ;
RANGE 0, 3600/HSTEP ;
PAGESTEP 5;
ON UP ( nHoriz2 += HSTEP, HScroll2() ) ;
ON DOWN ( nHoriz2 -= HSTEP, HScroll2() ) ;
ON PAGEUP ( nHoriz2 += 5*HSTEP, HScroll2() ) ;
ON PAGEDOWN ( nHoriz2 -= 5*HSTEP, HScroll2() ) ;
ON THUMBPOS ( nHoriz2 -= ( nPos-oGraph:oHScroll:GetPos() )*HSTEP, ;
oGraph:oHScroll:SetPos(nPos), ;
HScroll2() )
DEFINE SCROLLBAR oGraph:oVScroll OF oGraph ;
VERTICAL ;
RANGE 0, 400/VSTEP ;
PAGESTEP 5;
ON UP ( nVertic += VSTEP, VScroll() ) ;
ON DOWN ( nVertic -= VSTEP, VScroll() ) ;
ON PAGEUP ( nVertic += 5*VSTEP, VScroll() ) ;
ON PAGEDOWN ( nVertic -= 5*VSTEP, VScroll() ) ;
ON THUMBPOS ( nVertic -= ( nPos-oGraph:oVScroll:GetPos() )*VSTEP, ;
oGraph:oVScroll:SetPos(nPos), ;
VScroll() )
ACTIVATE WINDOW oWnd MAXIMIZED;
ON PAINT (oSplit:AdjClient(), oSplit1:AdjLeft(), oSplit2:AdjRight())
SET RESOURCES TO
SET LOOK3D OFF
RELEASE FONT oFont
RETURN nil
//----------------------------------------------------------------------------//
Function Title()
oTitle:Say( 10, 2+nHoriz1, "Times", , , oFont, .T., .T. )
oTitle:Line( 0, 35+nHoriz1, 36, 35+nHoriz1 )
RETURN NIL
//----------------------------------------------------------------------------//
FUNCTION Week()
local n, m
local nHeight := (oWnd:nHeight - 20 ) / 7
local nWidth := oSplit2:nLong / 6
local cDay
LOCAL nColonna :=GRIDCOL
LOCAL dData, cCol
dData:=(date())+1
nGridCol := oSplit2:nLong / 6
nColonna := nGridCol
for n = 0 to 6
cDay := oemtoansi(CDoW( dData + ( n - 1 ) ) + " " +;
PADL( DAY( dData + ( n - 1 ) ), 2, "0" ) + " " + cmonth( dData + ( n - 1 )) + " " )
cCol:= ( n * nWidth ) + ( nWidth / 2 )
oDays:Say ( 1, cCol, cDay, , , , .T., .T., TA_CENTER )
oDays:Line( 0, nColonna, 120, nColonna, oPen2 )
nColonna += nGridCol
next
RETURN nil
//----------------------------------------------------------------------------//
FUNCTION Hours()
LOCAL nLinea := 0
Local aOre := {}
FOR nOre = 0 TO 23
AADD( aOre, STRZERO( nOre, 2 ) + ".00" ) //time 1 Hour
IF ltime15
AADD( aOre, STRZERO( nOre, 2 ) + ".15" )
endif
IF ltime30
AADD( aOre, STRZERO( nOre, 2 ) + ".30" )
endif
IF ltime45
AADD( aOre, STRZERO( nOre, 2 ) + ".45" )
endif
NEXT
// write the HOURS
For n= 1 to Len(aOre)
oHours:Say( nLinea+nVertic+15, 18+nHoriz1+15, aOre[n], , , oFont, .T., .T., TA_CENTER )
nLinea += GRIDROW
oHours:Line( nLinea+nVertic, 0+nHoriz1, nLinea+nVertic, 361+nHoriz1 )
next
RETURN nil
//----------------------------------------------------------------------------//
FUNCTION Graphics()
LOCAL nStartGraph, nEndGraph
LOCAL nReg := RECNO()
Local dDate := Date() - Day( Date() ) + 1
Local nRow := 0 // Gridrow
LOCAL nColumn := nGridCol //GRIDCOL
LOCAL nLinea := 0
LOCAL nColumnaInicio, nColumnaFinal
LOCal nRowInit
Local nRowEnd
LOCAL nGraphRow := 0
// HORIZZONTAL LINES
DO WHILE nRow < oSplit:nLong
oGraph:Line( nRow ,0, nRow, oWnd:nWidth, oPen3 )
nRow += GRIDROW
ENDDO
// VERTICAL LINES
DO WHILE nColumn <= oSplit2:nLong
oGraph:Line( 0, nColumn, oWnd:nHeight, nColumn, oPen2 )
nColumn += nGridCol //GRIDCOL
ENDDO
/* GO TOP
DO WHILE .NOT.EOF()
nColonnaInit := ( Calendar->day - dDate ) * 16
nColonnaEnd := ( Calendar->day - dDate + 1 ) * 16
IF calendar->Type=1
oGraph:RecordBox( nrow, nColonnaInit, nRow+14, nColonnaEnd, oPenR ,nReg)
ELSEIF calendar->Type=2
oGraph:RecordBox( nrow, nColonnaInit, nRow+14, nColonnaEnd, oPenL ,nReg)
ENDIF
SKIP 1
nrow += 22
ENDDO
GOTO nReg
*/
RETURN nil
//----------------------------------------------------------------------------//
FUNCTION HScroll1()
LOCAL hWnd
LOCAL aRect
STATIC nH1 := 0
IF nHoriz1<-200 .OR. nHoriz1>0
nHoriz1 := nH1
RETURN nil
ENDIF
hWnd := oTitle:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, nHoriz1-nH1, 0, aRect, aRect )
hWnd := oHours:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, nHoriz1-nH1, 0, aRect, aRect )
oTitle:REFRESH()
oHours:REFRESH()
nH1 := nHoriz1
RETURN nil
FUNCTION HScroll2()
LOCAL hWnd
LOCAL aRect
STATIC nH2 := 0
IF nHoriz2<-3600 .OR. nHoriz2>0
nHoriz2 := nH2
RETURN nil
ENDIF
hWnd := oDays:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, nHoriz2-nH2, 0, aRect, aRect )
hWnd := oGraph:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, nHoriz2-nH2, 0, aRect, aRect )
oDays:REFRESH()
oGraph:REFRESH()
nH2 := nHoriz2
RETURN nil
* --------------------------------
FUNCTION VScroll()
LOCAL hWnd
LOCAL aRect
STATIC nV := 0
IF nVertic<-400 .OR. nVertic>0
nVertic := nV
RETURN nil
ENDIF
hWnd := oHours:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, 0, nVertic-nV, aRect, aRect )
hWnd := oGraph:hWnd
aRect := GetClientRect( hWnd )
ScrollWindow( hWnd, 0, nVertic-nV, aRect, aRect )
nV := nVertic
RETURN nil
//----------------------------------------------------------------------------//
FUNCTION create_dbf()
local astruc := { { "day", "d", 8, 0 },;
{ "starttime" , "C", 5, 0 },;
{ "endtime" , "C", 5, 0 },;
{ "subject" , "C", 50, 0 },;
{ "type" , "N", 1, 0 },;
{ "body" , "M", 10, 0 } }
cAlias := "Calendar"
if !file( "calendar.dbf")
dbcreate( cAlias, aStruc, "DBFCDX", .t., cAlias )
(cAlias)->( OrdCreate( cAlias, "day", "day" ) )
(cAlias)->( OrdCreate( cAlias, "starttime", "starttime" ) )
else
dbuseArea( .t., "DBFCDX", cAlias, cAlias, .t. )
(cAlias)->( OrdCreate( cAlias, "day", "day" ) )
(cAlias)->( OrdCreate( cAlias, "starttime", "starttime" ) )
endif
(cAlias)->( OrdListAdd( cAlias ) )
Return Nil
//----------------------------------------------------------------------------//