CONST lheures=36
CONST hheader=20
CONST leftmargin=4
CONST topmargin=4
CONST bottommargin=0.25
CONST hnotes=2
CONST printmargin=0.04
$RESOURCE im_calend AS "p:\documents\fun\carnet\source\data\calend.bmp"
CONST magnet=0.11
CONST bordure=8
CONST bordureicone=24
CONST minwidth=40
CONST minheight=17
CONST bleu=&hdd6612
DIM x0 AS INTEGER : DIM y0 AS INTEGER
DEFINT nouvelev=0
DEFINT movingev=0
DEFINT doingredim=0
DEFINT canredimH=0 : DEFINT canredimV=0
DEFINT uboundED=0
DECLARE SUB selectnone
DECLARE SUB mousedownz (Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
DECLARE SUB mousemovez (Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
DECLARE SUB mouseupz (Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
DECLARE SUB clicflechegauche : DECLARE SUB clicflechedroite : DECLARE SUB cliccalendr
DECLARE SUB zcadreMove
DECLARE SUB drawz
DIM etiqjour(nbjours) AS QLABEL, etiqheure(nbheures) AS QLABEL
CREATE WeekPanel AS QPANEL
PARENT=Tab
left=4 : top=28
width=panelwidth: height=panelheight
COLOR=colorfond
borderstyle=0 : bevelouter=0 : bevelinner=0
CREATE zcadre AS QPANEL
Left = leftmargin+lheures
Top = topmargin+hheader
width=nbjours*ljour+3
height=hheure*(nbheures+hnotes+bottommargin)
bevelouter=bvnone
borderstyle=0
bevelinner=0
COLOR=&hddf4f4
font=appsmallfont
CREATE z AS QCANVAS
left=0 : top=0
width=nbjours*ljour
height=hheure*(nbheures+hnotes+bottommargin)
onpaint=drawz
onmousedown=mousedownz
onmouseup=mouseupz
onmousemove=mousemovez
END CREATE
END CREATE
CREATE heures AS QPANEL
left=leftmargin
top=topmargin
height=hheure*nbheures+hheader+1
width=lheures
COLOR=colorHeader
bevelouter=bvnone
borderstyle=1
CREATE fondboutons AS QPANEL
left=0:top=0
width=32:height=17
COLOR=&hbbbbbb
bevelouter=bvnone
borderstyle=0
CREATE flechegauche AS QCOOLBTN
bmphandle=im_flecheg
left=16 : top=0
width=16 : height=16
flat=true
onclick=clicflechegauche
END CREATE
CREATE calend AS QCOOLBTN
bmphandle=im_calend
left=0:top=0
width=17 : height=17
flat=true
onclick=cliccalendr
END CREATE
END CREATE
END CREATE
CREATE header AS QPANEL
left=leftmargin+lheures-2
top=topmargin
width=nbjours*ljour+3
height=hheader
bevelouter=bvnone
borderstyle=1
COLOR=colorHeader
CREATE fondboutond AS QPANEL
left=header.width-20
top=0 : width=20 : height=18
COLOR=&hbbbbbb
bevelouter=bvnone
borderstyle=0
CREATE flechedroite AS QCOOLBTN
bmphandle=im_fleched
left=0 : top=0
width=16 : height=16
flat=true
onclick=clicflechedroite
END CREATE
END CREATE
END CREATE
END CREATE
DECLARE FUNCTION ExtractIcon LIB "shell32.dll" ALIAS "ExtractIconA" (hInst AS LONG,lpszExeFileName AS STRING,nIconIndex AS LONG) AS LONG
DECLARE FUNCTION DestroyIcon LIB "user32" ALIAS "DestroyIcon" (hIcon AS LONG) AS LONG
DECLARE FUNCTION DrawIcon LIB "user32" ALIAS "DrawIcon" (hdc AS LONG,x AS LONG,y AS LONG,hIcon AS LONG) AS LONG
SUB framerect(qc AS QCANVAS, c AS INTEGER)
qc.rectangle(0,0,qc.width,qc.height,c)
END SUB
SUB frameedrect(sender AS QCANVAS)
framecolor=IIF(sender.tag=currentev, bleu, 0)
framerect(sender,framecolor)
END SUB
SUB hideallevents
FOR i=1 TO nbevent
edcadre(i).visible=False
NEXT
END SUB
FUNCTION min (a,b) AS INTEGER
IF a>b THEN
min=b
ELSE
min=a
END IF
END FUNCTION
FUNCTION max (a,b) AS INTEGER
IF a<b THEN
max=b
ELSE
max=a
END IF
END FUNCTION
FUNCTION nthfield(s AS STRING,i AS INTEGER) AS DOUBLE
nthfield=FIELD$(s," ",i)
END FUNCTION
DIM fantome(0) AS QPANEL
DIM fantomeframe AS QCANVAS
DEFINT nbfantomes=0
SUB fantomeredim(x AS INTEGER, y AS INTEGER)
IF (ROUND(x+ljour*magnet) MOD ljour)<ljour*(magnet+magnet) THEN x=ROUND(x/ljour)*ljour
y=ROUND(y*quartdheure/hheure)*hheure/quartdheure
gauche=min(x0,X):gauche=max(gauche,0)
haut=min(y0,Y):haut=max(haut,0)
largeur=max(X,x0)-gauche
hauteur=max(Y,y0)-haut
largeur=min(largeur,zcadre.width-gauche-3)
hauteur=min(hauteur,zcadre.height-haut)
fantome(nbfantomes).left=gauche
fantome(nbfantomes).top=haut
fantome(nbfantomes).width=largeur
fantome(nbfantomes).height=hauteur
fantomeframe.width=largeur : fantomeframe.height=hauteur
END SUB
SUB framefantome
framerect(fantomeframe,bleu)
END SUB
SUB drawz
DIM lejour AS STRING, datestr AS STRING
FOR i=1 TO nbheures-1
z.line(0,i*hheure,z.width,i*hheure,&h008888)
NEXT
FOR i=0 TO nbheures-1
z.line(0,(i+0.5)*hheure,z.width,(i+0.5)*hheure,&hcccccc)
NEXT
FOR i=1 TO nbjours-1
z.fillrect(i*ljour-2,0,i*ljour+2,z.height,colorHeader)
NEXT
FOR i=1 TO nbjours
lejour=advancedays(lundi,i-1)
datestr=datetext(lejour)
IF form.textwidth(datestr)>ljour*0.95 THEN datestr=shortdatetext(lejour)
etiqjour(i).CAPTION=" "+datestr
etiqjour(i).PARENT=header
etiqjour(i).left=(i-1)*ljour+2
NEXT
z.fillrect(0,nbheures*hheure,z.width,(nbheures+bottommargin)*hheure,colorHeader)
z.rectangle(0,0,z.width,z.height,&h808080)
END SUB
SUB mousedownz (Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
DIM mycursorh AS LONG, cursorcode AS LONG
IF canredimH+canredimV=0 THEN GOTO creation
SELECT CASE canredimH+canredimV
CASE 0 : zcadre.cursor=crCross : cursorcode=32515
CASE 1,2 : zcadre.cursor=crSizeNS : cursorcode=32645
CASE 4,8 : zcadre.cursor=crSizeWE : cursorcode=32644
CASE 5,10 : zcadre.cursor=crSizeNWSE : cursorcode=32642
CASE 6,9 : zcadre.cursor=crSizeNESW : cursorcode=32643
END SELECT
mycursorh=loadcursor(0,cursorcode)
setcursor(mycursorh)
doingredim=1
DO
x=MOUSEX : y=MOUSEY
IF (ROUND(x+ljour*magnet) MOD ljour)<ljour*(magnet+magnet) THEN x=ROUND(x/ljour)*ljour
y=ROUND(y*quartdheure/hheure)*hheure/quartdheure
x=max(x,0) : y=max(y,0)
SELECT CASE canredimH
CASE 4
largeur=edcadre(currentev).left+edcadre(currentev).width-x
IF largeur>minwidth THEN
delta=largeur-edcadre(currentev).width
edcadre(currentev).left=x
edcadre(currentev).width=largeur
edrect(currentev).width=largeur
ed(currentev).width=ed(currentev).width+delta
END IF
CASE 8
IF x-edcadre(currentev).left>minwidth THEN
delta=x-(edcadre(currentev).left+edcadre(currentev).width)
edcadre(currentev).width=x-edcadre(currentev).left
edrect(currentev).width=x-edcadre(currentev).left
ed(currentev).width=ed(currentev).width+delta
END IF
END SELECT
SELECT CASE canredimV
CASE 1
hauteur=edcadre(currentev).top+edcadre(currentev).height-y
IF hauteur>minheight THEN
delta=hauteur-edcadre(currentev).height
edcadre(currentev).top=y
edcadre(currentev).height=hauteur
edrect(currentev).height=hauteur
ed(currentev).height=ed(currentev).height+delta
END IF
CASE 2
IF y-edcadre(currentev).top>minheight THEN
delta=y-(edcadre(currentev).top+edcadre(currentev).height)
edcadre(currentev).height=y-edcadre(currentev).top
edrect(currentev).height=y-edcadre(currentev).top
ed(currentev).height=ed(currentev).height+delta
END IF
END SELECT
DOEVENTS
LOOP UNTIL doingredim=0
canredimH=0 : canredimV=0
EXIT SUB
creation :
mycursorh=loadcursor(0,32515)
setcursor(mycursorh)
x0=X
y0=Y
IF (ROUND(x0+ljour*magnet) MOD ljour)<ljour*(magnet+magnet) THEN x0=ROUND(x0/ljour)*ljour
y0=ROUND(y0*quartdheure/hheure)*hheure/quartdheure
nbfantomes++
REDIM fantome(nbfantomes) AS QPANEL
fantome(nbfantomes).PARENT=zcadre
fantome(nbfantomes).left=0
fantome(nbfantomes).top=0
fantome(nbfantomes).width=0
fantome(nbfantomes).height=0
fantome(nbfantomes).borderstyle=0
fantome(nbfantomes).COLOR=&hffffff
fantome(nbfantomes).visible=true
fantomeframe.PARENT=fantome(nbfantomes)
fantomeframe.left=0:fantomeframe.top=0:fantomeframe.width=0:fantomeframe.height=0
fantomeframe.onpaint=framefantome
nouvelev=1
DO
x=MOUSEX:y=MOUSEY
fantomeredim(x,y)
DOEVENTS
LOOP UNTIL nouvelev=0
END SUB
SUB mousemovez(X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
IF doingredim<>0 THEN EXIT SUB
canredimV=0 : canredimH=0
IF nouvelev=1 THEN EXIT SUB
IF currentev=0 THEN zcadre.cursor=crCross : EXIT SUB
IF ABS(MOUSEY-edcadre(currentev).top)<=3 THEN canredimV=1
IF ABS(MOUSEY-edcadre(currentev).top-edcadre(currentev).height)<=3 THEN canredimV=2
IF (MOUSEX<edcadre(currentev).left-3)OR(MOUSEX>edcadre(currentev).left+edcadre(currentev).width+3) THEN canredimV=0
IF ABS(MOUSEX-edcadre(currentev).left)<=3 THEN canredimH=4
IF ABS(MOUSEX-edcadre(currentev).left-edcadre(currentev).width)<=3 THEN canredimH=8
IF (MOUSEY<edcadre(currentev).top-3)OR(MOUSEY>edcadre(currentev).top+edcadre(currentev).height+3) THEN canredimH=0
SELECT CASE canredimH+canredimV
CASE 0 : zcadre.cursor=crCross
CASE 1,2 : zcadre.cursor=crSizeNS
CASE 4,8 : zcadre.cursor=crSizeWE
CASE 5,10 : zcadre.cursor=crSizeNWSE
CASE 6,9 : zcadre.cursor=crSizeNESW
END SELECT
END SUB
DECLARE SUB bringtofront (i AS INTEGER)
DECLARE SUB createev(gauche AS INTEGER,lehaut AS INTEGER,large AS INTEGER,hauteur AS INTEGER,letexte AS STRING,iconname AS STRING)
SUB mouseupz (Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
IF doingredim<>0 THEN
doingredim=0
EXIT SUB
END IF
IF nouvelev=0 THEN EXIT SUB
nouvelev=0
fantomeredim(x,y)
IF fantome(nbfantomes).width+fantome(nbfantomes).height=0 THEN
autolarge=IIF(x0<=(nbjours-1)*ljour,ljour,nbjours*ljour-x0)
autohaut=IIF(y0<(nbheures+bottommargin+hnotes-1)*hheure,hheure,(nbheures+bottommargin+hnotes)*hheure-y0-1)
fantome(nbfantomes).width=autolarge
fantome(nbfantomes).height=autohaut
END IF
IF (fantome(nbfantomes).width<minwidth)OR(fantome(nbfantomes).height<minheight) THEN
fantome(nbfantomes).visible=0
selectnone
EXIT SUB
END IF
createev(fantome(nbfantomes).left,fantome(nbfantomes).top,fantome(nbfantomes).width,fantome(nbfantomes).height,"","")
fantome(nbfantomes).visible=False
bringtofront(nbevent)
END SUB
SUB clickedcadre(Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QCANVAS)
mycursorh=loadcursor(0,32512)
setcursor(mycursorh)
mx0=MOUSEX:my0=MOUSEY
IF currentev=sender.tag THEN
sameevent=true
ELSE
sameevent=false
bringtofront(Sender.tag)
END IF
movingev=1
x0=edcadre(currentev).left : y0=edcadre(currentev).top
maxx=zcadre.width-edcadre(currentev).width-3
maxy=zcadre.height-edcadre(currentev).height
mx0=MOUSEX:my0=MOUSEY
DO
mx=MOUSEX: my=MOUSEY
x=x0+mx-mx0
y=y0+my-my0
IF (ROUND(x+ljour*magnet) MOD ljour)<ljour*(magnet+magnet) THEN x=ROUND(x/ljour)*ljour
y=ROUND(y*quartdheure/hheure)*hheure/quartdheure
x=max(x,0):x=min(x,maxx)
y=max(y,0):y=min(y,maxy)
edcadre(currentev).left=x
edcadre(currentev).top=y
IF sameevent=true THEN x0=x:y0=y
DOEVENTS
LOOP UNTIL movingev=0
END SUB
SUB mousemoveedcadre(X AS INTEGER, Y AS INTEGER, Shift AS INTEGER)
END SUB
SUB unclickedcadre(Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QPANEL)
movingev=0 : edcadre(currentev).cursor=0
END SUB
SUB clicked(Button AS INTEGER, X AS INTEGER, Y AS INTEGER, Shift AS INTEGER, Sender AS QRICHEDIT)
bringtofront(Sender.tag)
END SUB
FUNCTION displayicon(i AS INTEGER, iconname AS STRING) AS INTEGER
edicon(i).hint=iconname
IF iconname="" THEN
edicon(i).visible=false
displayicon =0
ELSE
whichicon=VAL(FIELD$(iconname,CHR$(9),2))
iconname=FIELD$(iconname,CHR$(9),1)
nbicons=ExtractIcon(application.handle,iconname,-1)
IF nbicons=0 THEN
edicon(i).visible=false
displayicon =0
EXIT FUNCTION
END IF
IF whichicon>=nbicons THEN whichicon=0
edicon(i).visible=true
displayicon =bordureicone
DIM iconh AS LONG
CREATE licone AS QBITMAP
width=32
height=32
fillrect(0,0,32,32,&hffffff)
END CREATE
DIM r1 AS QRECT,r2 AS QRECT
iconh=ExtractIcon(application.handle,iconname,whichicon)
DrawIcon(licone.handle,0,0,iconh)
Destroyicon(iconh)
r1.left=0:r1.top=0:r1.right=bordureicone:r1.bottom=bordureicone
edicon(i).PARENT=edcadre(i)
edicon(i).left=2:edicon(i).top=2
edicon(i).width=bordureicone:edicon(i).height=bordureicone
edicon(i).stretchdraw(r1,licone.bmp)
edicon(i).onmousedown=clickedcadre
edicon(i).onmouseup=unclickedcadre
edicon(i).onmousemove=mousemoveedcadre
END IF
END FUNCTION
SUB createev(gauche AS INTEGER,lehaut AS INTEGER,large AS INTEGER,hauteur AS INTEGER,letexte AS STRING,iconname AS STRING)
nbevent++
IF nbevent>uboundED THEN
REDIM edcadre(nbevent) AS QPANEL
REDIM ed(nbevent) AS QRICHEDIT
REDIM edicon(nbevent) AS QIMAGE
REDIM edrect(nbevent) AS QCANVAS
uboundED++
END IF
edcadre(nbevent).left=gauche
edcadre(nbevent).top=lehaut
edcadre(nbevent).width=large
edcadre(nbevent).height=hauteur
edcadre(nbevent).PARENT=zcadre
edcadre(nbevent).borderstyle=0
edcadre(nbevent).COLOR=&hffffff
edcadre(nbevent).visible=True
edcadre(nbevent).cursor=0
edrect(nbevent).PARENT=edcadre(nbevent)
edrect(nbevent).tag=nbevent
edrect(nbevent).left=0 : edrect(nbevent).top=0
edrect(nbevent).width=edcadre(nbevent).width : edrect(nbevent).height=edcadre(nbevent).height
edrect(nbevent).onpaint=frameedrect
edrect(nbevent).onmousedown=clickedcadre
edrect(nbevent).onmouseup=unclickedcadre
edrect(nbevent).onmousemove=mousemoveedcadre
tailleicone=displayicon(nbevent,iconname)
ed(nbevent).left=tailleicone+bordure-5
ed(nbevent).top=bordure-5
ed(nbevent).width=large-tailleicone-bordure-bordure+6
ed(nbevent).height=hauteur-bordure-bordure+6
ed(nbevent).PARENT=edcadre(nbevent)
ed(nbevent).borderstyle=0
letexte=REPLACESUBSTR$(letexte,crSubst,crString)
ed(nbevent).text=letexte
ed(nbevent).onmousedown=clicked
ed(nbevent).tag=nbevent
END SUB
SUB createevfromstring(s AS STRING)
DIM letexte AS STRING, dimensions AS STRING, iconname AS STRING, hh1 AS STRING, hh2 AS STRING
letexte=FIELD$(s,separ,2)
dimensions =FIELD$(s,separ,3)
iconname=FIELD$(s,separ,4)
hh1=nthfield(dimensions,3):lehaut=ROUND((strheure(hh1)-heure1)*hheure)
hh2=nthfield(dimensions,4):lahauteur=(strheure(hh2)-strheure(hh1))*hheure
lagauche=(VAL(nthfield(dimensions,1))-firstdaydisplayed)*ljour
lalargeur=(VAL(nthfield(dimensions,2))-VAL(nthfield(dimensions,1)))*ljour
lejour=INT(VAL(nthfield(dimensions,1)))
createev(lagauche, lehaut, lalargeur, lahauteur, letexte, iconname)
END SUB
SUB bringtofront(i AS INTEGER)
IF currentev=i THEN EXIT SUB
cursorpos=ed(i).selstart
IF (i<>currentev)AND(currentev<>0) THEN framerect(edrect(currentev),0)
createevfromstring(eventstring(i))
edcadre(i).visible=false
ed(i).text="[[deleted]]"
currentev=nbevent
setfocus(ed(currentev).handle)
ed(currentev).selstart=cursorpos : ed(currentev).sellength=0
END SUB
SUB selectnone
IF (currentev<>0) THEN framerect(edrect(currentev),0)
currentev=0
END SUB
SUB buildweek
DIM s AS STRING
findweek(lundi)
nbevent=0
FOR i=1 TO nbeventsinweek
s=ev.item(WeekStartIndex)
ev.delitems(WeekStartIndex)
createevfromstring(s)
NEXT
selectnone
END SUB
DIM whichicon AS INTEGER, nbicons AS INTEGER
DIM nbiconsinrow AS INTEGER, nbrows AS INTEGER
DIM iconh AS LONG
DIM fshortname AS STRING, flongname AS STRING
CREATE iconform AS QFORM
width=356 : height=350
center
COLOR=&hffffff
CREATE iconz AS QCANVAS
left=0:top=0
width=iconform.width-24
END CREATE
END CREATE
SUB iconformshow
x=0 : y=0
FOR i=0 TO nbicons-1
iconh=ExtractIcon(application.handle,flongname,i)
DrawIcon(iconz.handle,x*36+2,y*36+2,iconh)
DestroyIcon(iconh)
x++
IF x>=nbiconsinrow THEN
y++ : x=0
END IF
NEXT
END SUB
SUB iconformclic (button AS LONG, x AS LONG, y AS LONG, shift AS LONG)
xx=INT(x/36) : yy=INT(y/36)
whichicon=xx+yy*nbiconsinrow
IF whichicon>=nbicons THEN whichicon=-1
iconform.visible=false
END SUB
SUB iconcancel
whichicon=-1
iconform.visible=false
END SUB
FUNCTION iconpicker(fname AS STRING) AS INTEGER
nbicons=ExtractIcon(application.handle,fname,-1)
IF nbicons=0 THEN
iconpicker=-1
EXIT FUNCTION
END IF
extension$=LCASE$(RIGHT$(fname,4))
IF (extension$=".ico")OR(nbicons=1) THEN
iconpicker=0
EXIT FUNCTION
END IF
flongname=fname
fshortname=FIELD$(fname,"\",TALLY(fname,"\")+1)
whichicon=-1
iconform.onpaint=iconformshow
iconform.onclose=iconcancel
iconform.onkeydown=iconcancel
iconz.onmousedown=iconformclic
iconform.CAPTION=s_iconsinfile+fshortname
nbiconsinrow=INT((iconz.width-8)/36) : nbrows=INT((nbicons+nbiconsinrow-1)/nbiconsinrow)
iconz.height=nbrows*36
IF iconz.height<iconform.clientheight THEN iconz.height=iconform.clientheight
iconform.visible=true
WHILE iconform.visible
DOEVENTS
WEND
iconpicker=whichicon
END FUNCTION
SUB selecticone
DIM s AS STRING,ss AS STRING,quelicone AS STRING
IF currentev=0 THEN EXIT SUB
CREATE dia AS QOPENDIALOG
filter=s_iconfilter
filterindex=1
initialdir=icondir
END CREATE
IF dia.EXECUTE=false THEN
quelicone=""
ELSE
quelicone=dia.filename
whichicon=iconpicker(quelicone)
IF whichicon<0 THEN
quelicone=""
ELSE
quelicone=quelicone+CHR$(9)+STR$(whichicon)
icondir=CURDIR$
END IF
END IF
tailleicone=displayicon(currentev,quelicone)
ed(currentev).left=tailleicone+bordure-5
ed(currentev).width=edcadre(currentev).width-tailleicone-bordure-bordure+6
END SUB
SUB weekdelete
DIM s AS STRING
IF currentev<1 THEN EXIT SUB
ed(currentev).text="[[deleted]]"
edcadre(currentev).visible=False
selectnone
END SUB
SUB weekcut
IF currentev=0 THEN EXIT SUB
IF ed(currentev).sellength<>0 THEN
myclipboard=""
ed(currentev).cuttoclipboard
ELSE
edcadre(currentev).visible=false
myclipboard=eventstring(currentev)
ed(currentev).selectall
ed(currentev).cuttoclipboard
ed(currentev).text="[[deleted]]"
selectnone
END IF
END SUB
SUB weekpaste
DIM s AS STRING
IF myclipboard="" THEN
IF currentev=0 THEN EXIT SUB
s=clipboard.text
ed(currentev).pastefromclipboard
ELSE
CreateEvFromString(myclipboard)
END IF
END SUB
SUB weekcopy
IF currentev=0 THEN EXIT SUB
IF ed(currentev).sellength<>0 THEN
myclipboard=""
ed(currentev).copytoclipboard
ELSE
myclipboard=eventstring(currentev)
clipboard.text=ed(currentev).text
END IF
END SUB
SUB clicflechegauche
savecarnet
hideallevents
lundi=advancedays(lundi,-7)
drawz
buildweek
END SUB
SUB clicflechedroite
hideallevents
savecarnet
lundi=advancedays(lundi,7)
drawz
buildweek
END SUB
SUB weekkeydown(key AS WORD, shift AS INTEGER)
SELECT CASE key
CASE 33 : clicflechegauche
CASE 34 : clicflechedroite
CASE 27 : systray
END SELECT
END SUB
SUB cliccalendr
DIM nouvjour AS STRING
nouvjour=calendrier
IF nouvjour="" THEN EXIT SUB
hideallevents
savecarnet
theweekday=weekday(nouvjour)
IF (theweekday=7) AND (firstdayofweek=0) THEN theweekday=0
lundi=advancedays(nouvjour,firstdaydisplayed-theweekday)
drawz
buildweek
END SUB
SUB weekinit
ljour=INT((panelwidth-2*leftmargin-lheures-6)/nbjours)
hheure=INT((panelheight-2*topmargin-hheader-6)/(nbheures+bottommargin+hnotes))
hheure=hheure-(hheure MOD quartdheure)
WeekPanel.width=panelwidth: WeekPanel.height=panelheight
zcadre.width=nbjours*ljour+3 : zcadre.height=hheure*(nbheures+hnotes+bottommargin)
z.width=nbjours*ljour : z.height=hheure*(nbheures+hnotes+bottommargin)
heures.height=hheure*nbheures+hheader+1
header.width=nbjours*ljour+3
fondboutond.left=header.width-20
FOR i=0 TO nbheures-1
etiqheure(i).CAPTION=STR$(heure1+i)
etiqheure(i).PARENT=heures
etiqheure(i).left=10
etiqheure(i).top=i*hheure+18
NEXT
opencarnet
buildweek
fileprint.enabled=true
editnew.enabled=false
edituse.enabled=false
editall.enabled=false
editfind.enabled=true
editfindnext.enabled=true
menuicon.enabled=true
menuicon.shortcut="CTRL+I"
projectinsert.shortcut=""
setfocus(weekpanel.handle)
END SUB
DIM findev AS INTEGER
SUB wkdofind
DIM i AS INTEGER, s AS STRING, p AS INTEGER, ss AS STRING, nouvjour AS STRING, theweekday AS INTEGER
s=findtext.text
IF s="" THEN EXIT SUB
FOR i=findev TO 1 STEP -1
ss=ed(i).text
IF ss<>"[[deleted]]" THEN
p=INSTR(LCASE$(ss),LCASE$(s))
IF p<>0 THEN
bringtofront(i)
EXIT SUB
END IF
END IF
NEXT
FOR i=weekstartindex TO ev.itemcount-1
ss=ev.item(i)
nouvjour=FIELD$(ss,separ,1)
ss=FIELD$(ss,separ,2)
IF ss<>"[[deleted]]" THEN
p=INSTR(LCASE$(ss),LCASE$(s))
IF p<>0 THEN
savecarnet : hideallevents
theweekday=weekday(nouvjour)
IF (theweekday=7) AND (firstdayofweek=0) THEN theweekday=0
lundi=advancedays(nouvjour,firstdaydisplayed-theweekday)
drawz
buildweek
findev=nbevent
wkdofind
EXIT SUB
END IF
END IF
NEXT
FOR i=0 TO weekstartindex-1
ss=ev.item(i)
nouvjour=FIELD$(ss,separ,1)
ss=FIELD$(ss,separ,2)
IF ss<>"[[deleted]]" THEN
p=INSTR(LCASE$(ss),LCASE$(s))
IF p<>0 THEN
savecarnet : hideallevents
theweekday=weekday(nouvjour)
IF (theweekday=7) AND (firstdayofweek=0) THEN theweekday=0
lundi=advancedays(nouvjour,firstdaydisplayed-theweekday)
drawz
buildweek
findev=nbevent
wkdofind
EXIT SUB
END IF
END IF
NEXT
END SUB
SUB wkmenufind
findev=nbevent
wkdofind
END SUB
SUB wkfindnext
findev=findev-1
wkdofind
END SUB
|
|