Calendar: Difference between revisions
Content added Content deleted
Line 4,755: | Line 4,755: | ||
<lang ring> |
<lang ring> |
||
# Project : Calendar |
# Project : Calendar |
||
# Date : 2018/06/ |
# Date : 2018/06/05 |
||
# Author : Gal Zsolt (~ CalmoSoft ~) |
# Author : Gal Zsolt (~ CalmoSoft ~) |
||
# Email : <calmosoft@gmail.com> |
# Email : <calmosoft@gmail.com> |
||
Line 4,766: | Line 4,766: | ||
win1 = new qwidget() { |
win1 = new qwidget() { |
||
day = list(12) |
day = list(12) |
||
pos = newlist(12,37) |
pos = newlist(12,37) |
||
month = list(12) |
month = list(12) |
||
week = list(7) |
week = list(7) |
||
weekday = list(7) |
weekday = list(7) |
||
button = newlist(7,6) |
button = newlist(7,6) |
||
monthsnames = list(12) |
monthsnames = list(12) |
||
week = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] |
week = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] |
||
months = ["January", "February", "March", "April", "May", "June", "July", |
months = ["January", "February", "March", "April", "May", "June", "July", |
||
"August", "September", "October", "November", "December"] |
"August", "September", "October", "November", "December"] |
||
daysnew = [[5,1], [6,2], [7,3], [1,4], [2,5], [3,6], [4,7]] |
|||
mo = [4,0,0,3,5,1,3,6,2,4,0,2] |
|||
mon = [31,28,31,30,31,30,31,31,30,31,30,31] |
|||
m2 = (((1969-1900)%7) + floor((1969 - 1900)/4) % 7) % 7 |
|||
mon = [31,28,31,30,31,30,31,31,30,31,30,31] |
|||
for n = 1 to 12 |
|||
m2 = (((1969-1900)%7) + floor((1969 - 1900)/4) % 7) % 7 |
|||
month[n] = (mo[n] + m2) % 7 |
|||
for n = 1 to 12 |
|||
x = (month[n] + 1) % 7 + 1 |
|||
for m = 1 to len(daysnew) |
|||
if daysnew[m][1] = x |
|||
nr = m |
|||
ok |
|||
next |
|||
day[n] = daysnew[nr][2] |
|||
next |
|||
next |
|||
for m = 1 to 12 |
|||
next |
|||
for n = 1 to day[m] - 1 |
|||
pos[m][n] = " " |
|||
for m = 1 to 12 |
|||
next |
|||
next |
|||
for m = 1 to 12 |
|||
next |
|||
for n = day[m] to 37 |
|||
next |
|||
if n < (mon[m] + day[m]) |
|||
pos[m][n] = n - day[m] + 1 |
|||
for m = 1 to 12 |
|||
else |
|||
pos[m][n] = " " |
|||
ok |
|||
next |
|||
next |
|||
ok |
|||
next |
|||
next |
|||
setwindowtitle("Calendar") |
setwindowtitle("Calendar") |
||
setgeometry(100,100,650,800) |
setgeometry(100,100,650,800) |
||
Line 4,814: | Line 4,810: | ||
settext("") |
settext("") |
||
} |
} |
||
year = new qpushbutton(win1) |
year = new qpushbutton(win1) |
||
{ |
{ |
||
Line 4,820: | Line 4,815: | ||
year.settext("1969") |
year.settext("1969") |
||
} |
} |
||
for n = 1 to 4 |
|||
nr = (n-1)*3+1 |
|||
showmonths(nr) |
|||
next |
|||
for n = 1 to 12 |
|||
showweeks(n) |
|||
next |
|||
for n = 1 to 12 |
|||
showdays(n) |
|||
next |
|||
show() |
|||
} |
|||
exec() |
|||
} |
|||
func showmonths(m) |
|||
monthsnames[1] = new qpushbutton(win1) |
|||
for n = m to m + 2 |
|||
monthsnames[n] = new qpushbutton(win1) |
|||
setgeometry(120,40,60,20) |
|||
{ |
|||
if n%3 = 1 |
|||
col = 120 |
|||
rownr = floor(n/3) |
|||
if rownr = 0 |
|||
rownr = n/3 |
|||
ok |
|||
if n = 1 |
|||
row = 40 |
|||
else |
|||
row = 40+rownr*180 |
|||
ok |
|||
else |
|||
colnr = n%3 |
|||
if colnr = 0 |
|||
colnr = 3 |
|||
ok |
|||
rownr = floor(n/3) |
|||
if n%3 = 0 |
|||
rownr = floor(n/3)-1 |
|||
ok |
|||
col = 120 + (colnr-1)*160 |
|||
row = 40 + rownr*180 |
|||
ok |
|||
setgeometry(col,row,60,20) |
|||
monthsnames[n].settext(months[n]) |
|||
} |
|||
next |
|||
func showweeks(n) |
|||
monthsnames[2] = new qpushbutton(win1) |
|||
for m = 1 to 7 |
|||
col = m%7 |
|||
setgeometry(280,40,60,20) |
|||
if col = 0 col = 7 ok |
|||
weekday[m] = new qpushbutton(win1) |
|||
{ |
|||
colnr = n % 3 |
|||
if colnr = 0 |
|||
colnr = 3 |
|||
ok |
|||
rownr = floor(n/3) |
|||
if n%3 = 0 |
|||
rownr = floor(n/3)-1 |
|||
ok |
|||
colbegin = 60 + (colnr-1)*160 |
|||
rowbegin = 60 + (rownr)*180 |
|||
setgeometry(colbegin+col*20,rowbegin,20,20) |
|||
weekday[m].settext(week[m]) |
|||
} |
|||
next |
|||
func showdays(ind) |
|||
monthsnames[3] = new qpushbutton(win1) |
|||
if ind >=1 and ind <= 3 |
|||
rowbegin = 60 |
|||
setgeometry(440,40,60,20) |
|||
ok |
|||
monthsnames[3].settext(months[3]) |
|||
if ind >=4 and ind <= 6 |
|||
rowbegin = 240 |
|||
ok |
|||
if ind >=7 and ind <= 9 |
|||
rowbegin = 420 |
|||
ok |
|||
{ |
|||
if ind >=10 and ind <= 12 |
|||
setgeometry(60+col*20,60,20,20) |
|||
rowbegin = 600 |
|||
weekday[n].settext(week[n]) |
|||
ok |
|||
} |
|||
for m = 1 to 6 |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
if ind%3 = 1 |
|||
colbegin = 60 |
|||
elseif ind%3 = 2 |
|||
colbegin = 220 |
|||
else |
|||
colbegin = 380 |
|||
ok |
|||
setgeometry(colbegin+col*20,rowbegin+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[ind][nr] != " " |
|||
button[n][m].settext(string(pos[ind][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,60+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[1][nr] != " " |
|||
button[n][m].settext(string(pos[1][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,60+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[2][nr] != " " |
|||
button[n][m].settext(string(pos[2][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,60+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[3][nr] != " " |
|||
button[n][m].settext(string(pos[3][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
monthsnames[4] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(120,220,60,20) |
|||
monthsnames[4].settext(months[4]) |
|||
} |
|||
monthsnames[5] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(280,220,60,20) |
|||
monthsnames[5].settext(months[5]) |
|||
} |
|||
monthsnames[6] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(440,220,60,20) |
|||
monthsnames[6].settext(months[6]) |
|||
} |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,240,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,240,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,240,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,240+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[4][nr] != " " |
|||
button[n][m].settext(string(pos[4][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,240+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[5][nr] != " " |
|||
button[n][m].settext(string(pos[5][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,240+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[6][nr] != " " |
|||
button[n][m].settext(string(pos[6][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
monthsnames[7] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(120,400,60,20) |
|||
monthsnames[7].settext(months[7]) |
|||
} |
|||
monthsnames[8] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(280,400,60,20) |
|||
monthsnames[8].settext(months[8]) |
|||
} |
|||
monthsnames[9] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(440,400,60,20) |
|||
monthsnames[9].settext(months[9]) |
|||
} |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,420,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,420,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,420,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,420+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[7][nr] != " " |
|||
button[n][m].settext(string(pos[7][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,420+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[8][nr] != " " |
|||
button[n][m].settext(string(pos[8][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,420+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[9][nr] != " " |
|||
button[n][m].settext(string(pos[9][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
monthsnames[10] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(120,580,60,20) |
|||
monthsnames[10].settext(months[10]) |
|||
} |
|||
monthsnames[11] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(280,580,60,20) |
|||
monthsnames[11].settext(months[11]) |
|||
} |
|||
monthsnames[12] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(440,580,60,20) |
|||
monthsnames[12].settext(months[12]) |
|||
} |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,600,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,600,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
weekday[n] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,600,20,20) |
|||
weekday[n].settext(week[n]) |
|||
} |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(60+col*20,600+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[10][nr] != " " |
|||
button[n][m].settext(string(pos[10][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(220+col*20,600+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[11][nr] != " " |
|||
button[n][m].settext(string(pos[11][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
for n = 1 to 7 |
|||
for m = 1 to 6 |
|||
col = n%7 |
|||
if col = 0 col = 7 ok |
|||
row = m |
|||
button[n][m] = new qpushbutton(win1) |
|||
{ |
|||
setgeometry(380+col*20,600+row*20,20,20) |
|||
nr = (m-1)*7+n |
|||
if nr <= 37 |
|||
if pos[12][nr] != " " |
|||
button[n][m].settext(string(pos[12][nr])) |
|||
ok |
|||
ok |
|||
} |
|||
next |
|||
next |
|||
show() |
|||
} |
|||
exec() |
|||
} |
|||
</lang> |
</lang> |
||
Output image: |
Output image: |