uo_calendar_small.sru 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. $PBExportHeader$uo_calendar_small.sru
  2. $PBExportComments$日历控件用户对象
  3. forward
  4. global type uo_calendar_small from userobject
  5. end type
  6. type cb_ok from commandbutton within uo_calendar_small
  7. end type
  8. type cb_exit from commandbutton within uo_calendar_small
  9. end type
  10. type em_year from editmask within uo_calendar_small
  11. end type
  12. type pb_ok from picturebutton within uo_calendar_small
  13. end type
  14. type pb_ddlb from picturebutton within uo_calendar_small
  15. end type
  16. type dw_cal from datawindow within uo_calendar_small
  17. end type
  18. type ddlb_month from dropdownlistbox within uo_calendar_small
  19. end type
  20. end forward
  21. global type uo_calendar_small from userobject
  22. integer width = 887
  23. integer height = 820
  24. long backcolor = 80263328
  25. long tabtextcolor = 33554432
  26. event ue_close ( )
  27. cb_ok cb_ok
  28. cb_exit cb_exit
  29. em_year em_year
  30. pb_ok pb_ok
  31. pb_ddlb pb_ddlb
  32. dw_cal dw_cal
  33. ddlb_month ddlb_month
  34. end type
  35. global uo_calendar_small uo_calendar_small
  36. type variables
  37. Int ii_Day, ii_Month, ii_Year
  38. String is_old_column
  39. String is_DateFormat
  40. end variables
  41. forward prototypes
  42. public function integer days_in_month (integer month, integer year)
  43. public subroutine enter_day_numbers (integer ai_start_day_num, integer ai_days_in_month)
  44. public function int get_month_number (string as_month)
  45. public function integer unhighlight_column (string as_column)
  46. public subroutine set_date (date ad_date)
  47. public subroutine set_date_format (string as_date_format)
  48. public subroutine draw_month (integer year, integer month)
  49. public subroutine init_cal (date ad_start_date)
  50. public function integer highlight_column (string as_column)
  51. end prototypes
  52. event ue_close();closewithreturn(parent,string(id_date_selected,'yyyymmdd')) //userself
  53. end event
  54. public function integer days_in_month (integer month, integer year);//Most cases are straight forward in that there are a fixed number of
  55. //days in 11 of the 12 months. February is, of course, the problem.
  56. //In a leap year February has 29 days, otherwise 28.
  57. Integer li_DaysInMonth, li_Days[12] = {31,28,31,30,31,30,31,31,30,31,30,31}
  58. // Get the number of days per month for a non leap year.
  59. li_DaysInMonth = li_Days[Month]
  60. // Check for a leap year.
  61. If Month = 2 Then
  62. // If the year is a leap year, change the number of days.
  63. // Leap Year Calculation:
  64. // Year divisible by 4, but not by 100, unless it is also divisible by 400
  65. If ( (Mod(Year,4) = 0 And Mod(Year,100) <> 0) Or (Mod(Year,400) = 0) ) Then
  66. li_DaysInMonth = 29
  67. End If
  68. End If
  69. //Return the number of days in the relevant month
  70. Return li_DaysInMonth
  71. end function
  72. public subroutine enter_day_numbers (integer ai_start_day_num, integer ai_days_in_month);Int li_count, li_daycount
  73. //Blank the columns before the first day of the month
  74. For li_count = 1 to ai_start_day_num
  75. dw_cal.SetItem(1,li_count,"")
  76. Next
  77. //Set the columns for the days to the String of their Day number
  78. For li_count = 1 to ai_days_in_month
  79. //Use li_daycount to find which column needs to be set
  80. li_daycount = ai_start_day_num + li_count - 1
  81. dw_cal.SetItem(1,li_daycount,String(li_count))
  82. Next
  83. //Move to next column
  84. li_daycount = li_daycount + 1
  85. //Blank remainder of columns
  86. For li_count = li_daycount to 42
  87. dw_cal.SetItem(1,li_count,"")
  88. Next
  89. //If there was an old column turn off the highlight
  90. unhighlight_column (is_old_column)
  91. is_old_column = ''
  92. end subroutine
  93. public function int get_month_number (string as_month);Int li_month_number
  94. CHOOSE CASE as_month
  95. CASE "Jan"
  96. li_month_number = 1
  97. CASE "Feb"
  98. li_month_number = 2
  99. CASE "Mar"
  100. li_month_number = 3
  101. CASE "Apr"
  102. li_month_number = 4
  103. CASE "May"
  104. li_month_number = 5
  105. CASE "Jun"
  106. li_month_number = 6
  107. CASE "Jul"
  108. li_month_number = 7
  109. CASE "Aug"
  110. li_month_number = 8
  111. CASE "Sep"
  112. li_month_number = 9
  113. CASE "Oct"
  114. li_month_number = 10
  115. CASE "Nov"
  116. li_month_number = 11
  117. CASE "Dec"
  118. li_month_number = 12
  119. END CHOOSE
  120. return li_month_number
  121. end function
  122. public function integer unhighlight_column (string as_column);//If the highlight is on the column set the border of the column back to normal
  123. string ls_return
  124. If as_column <> '' then
  125. ls_return = dw_cal.Modify(as_column + ".border=0")
  126. If ls_return <> "" then
  127. MessageBox("Modify",ls_return)
  128. Return -1
  129. End if
  130. End If
  131. Return 1
  132. end function
  133. public subroutine set_date (date ad_date);
  134. end subroutine
  135. public subroutine set_date_format (string as_date_format);// Set the format.
  136. is_DateFormat = as_date_format
  137. // Set the date with the new format.
  138. If Not isnull(id_date_selected) then
  139. set_date (id_date_selected)
  140. End If
  141. end subroutine
  142. public subroutine draw_month (integer year, integer month);Int li_FirstDayNum, li_cell, li_daysinmonth
  143. Date ld_firstday
  144. String ls_month, ls_cell, ls_return
  145. //Set Pointer to an Hourglass and turn off redrawing of Calendar
  146. SetPointer(Hourglass!)
  147. SetRedraw(dw_cal,FALSE)
  148. //Set Instance variables to arguments
  149. ii_month = month
  150. ii_year = year
  151. //check in the instance day is valid for month/year
  152. //back the day down one if invalid for month ie 31 will become 30
  153. Do While Date(ii_year,ii_month,ii_day) = Date(00,1,1)
  154. ii_day --
  155. Loop
  156. //Work out how many days in the month
  157. li_daysinmonth = days_in_month(ii_month,ii_year)
  158. //Find the date of the first day in the month
  159. ld_firstday = Date(ii_year,ii_month,1)
  160. //Find what day of the week this is
  161. li_FirstDayNum = DayNumber(ld_firstday)
  162. //Set the first cell
  163. li_cell = li_FirstDayNum + ii_day - 1
  164. //If there was an old column turn off the highlight
  165. unhighlight_column (is_old_column)
  166. //Set the Title
  167. ls_Month = string(ii_Year)
  168. em_year.text = ls_month
  169. ddlb_month.text = string(ii_month,'00')
  170. //Enter the day numbers into the datawindow
  171. enter_day_numbers(li_FirstDayNum,li_daysinmonth)
  172. //Define the current cell name
  173. ls_cell = 'cell'+string(li_cell)
  174. //Highlight the current date
  175. highlight_column (ls_cell)
  176. //Set the old column for next time
  177. //is_old_column = ls_cell
  178. //Reset the pointer and Redraw
  179. SetPointer(Arrow!)
  180. dw_cal.SetRedraw(TRUE)
  181. end subroutine
  182. public subroutine init_cal (date ad_start_date);Int li_FirstDayNum, li_Cell, li_DaysInMonth
  183. String ls_Year, ls_Month, ls_Return, ls_Cell
  184. Date ld_FirstDay
  185. //Insert a row into the script datawindow
  186. dw_cal.InsertRow(0)
  187. //Set the variables for Day, Month and Year from the date passed to
  188. //the function
  189. ii_Month = Month(ad_start_date)
  190. ii_Year = Year(ad_start_date)
  191. ii_Day = Day(ad_start_date)
  192. //Find how many days in the relevant month
  193. li_daysinmonth = days_in_month(ii_month, ii_year)
  194. //Find the date of the first day of this month
  195. ld_FirstDay = Date(ii_Year, ii_month, 1)
  196. //What day of the week is the first day of the month
  197. li_FirstDayNum = DayNumber(ld_FirstDay)
  198. //Set the starting "cell" in the datawindow. i.e the column in which
  199. //the first day of the month will be displayed
  200. li_Cell = li_FirstDayNum + ii_Day - 1
  201. //Set the Title of the calendar with the Month and Year
  202. //ls_Month = get_month_string(ii_Month) + " " + string(ii_Year)
  203. ls_Month = string(ii_Year)
  204. em_year.text = ls_month
  205. ddlb_month.text = string(ii_month,'00')
  206. //Enter the numbers of the days
  207. enter_day_numbers(li_FirstDayNum, li_DaysInMonth)
  208. dw_cal.SetItem(1,li_cell,String(Day(ad_start_date)))
  209. //Define the first Cell as a string
  210. ls_cell = 'cell'+string(li_cell)
  211. //Display the first day in bold (or 3D)
  212. highlight_column (ls_cell)
  213. //Set the instance variable i_old_column to hold the current cell, so
  214. //when we change it, we know the old setting
  215. is_old_column = ls_Cell
  216. end subroutine
  217. public function integer highlight_column (string as_column);//Highlight the current column/date
  218. int li_days
  219. li_days = integer(mid(as_column,5))
  220. if li_days > 28 then
  221. do until isdate(em_year.text + '-' + ddlb_month.text + '-' + dw_cal.getitemstring(1,li_days))
  222. li_days --
  223. loop
  224. end if
  225. choose case li_days
  226. case 1
  227. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell1.x) - 5)
  228. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell1.y) - 5)
  229. case 2
  230. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell2.x) - 5)
  231. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell2.y) - 5)
  232. case 3
  233. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell3.x) - 5)
  234. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell3.y) - 5)
  235. case 4
  236. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell4.x) - 5)
  237. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell4.y) - 5)
  238. case 5
  239. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell5.x) - 5)
  240. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell5.y) - 5)
  241. case 6
  242. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell6.x) - 5)
  243. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell6.y) - 5)
  244. case 7
  245. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell7.x) - 5)
  246. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell7.y) - 5)
  247. case 8
  248. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell8.x) - 5)
  249. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell8.y) - 5)
  250. case 9
  251. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell9.x) - 5)
  252. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell9.y) - 5)
  253. case 10
  254. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell10.x) - 5)
  255. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell10.y) - 5)
  256. case 11
  257. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell11.x) - 5)
  258. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell11.y) - 5)
  259. case 12
  260. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell12.x) - 5)
  261. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell12.y) - 5)
  262. case 13
  263. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell13.x) - 5)
  264. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell13.y) - 5)
  265. case 14
  266. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell14.x) - 5)
  267. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell14.y) - 5)
  268. case 15
  269. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell15.x) - 5)
  270. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell15.y) - 5)
  271. case 16
  272. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell16.x) - 5)
  273. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell16.y) - 5)
  274. case 17
  275. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell17.x) - 5)
  276. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell17.y) - 5)
  277. case 18
  278. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell18.x) - 5)
  279. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell18.y) - 5)
  280. case 19
  281. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell19.x) - 5)
  282. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell19.y) - 5)
  283. case 20
  284. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell20.x) - 5)
  285. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell20.y) - 5)
  286. case 21
  287. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell21.x) - 5)
  288. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell21.y) - 5)
  289. case 22
  290. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell22.x) - 5)
  291. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell22.y) - 5)
  292. case 23
  293. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell23.x) - 5)
  294. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell23.y) - 5)
  295. case 24
  296. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell24.x) - 5)
  297. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell24.y) - 5)
  298. case 25
  299. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell25.x) - 5)
  300. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell25.y) - 5)
  301. case 26
  302. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell26.x) - 5)
  303. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell26.y) - 5)
  304. case 27
  305. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell27.x) - 5)
  306. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell27.y) - 5)
  307. case 28
  308. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell28.x) - 5)
  309. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell28.y) - 5)
  310. case 29
  311. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell29.x) - 5)
  312. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell29.y) - 5)
  313. case 30
  314. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell30.x) - 5)
  315. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell30.y) - 5)
  316. case 31
  317. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell31.x) - 5)
  318. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell31.y) - 5)
  319. case 32
  320. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell32.x) - 5)
  321. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell32.y) - 5)
  322. case 33
  323. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell33.x) - 5)
  324. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell33.y) - 5)
  325. case 34
  326. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell34.x) - 5)
  327. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell34.y) - 5)
  328. case 35
  329. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell35.x) - 5)
  330. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell35.y) - 5)
  331. case 36
  332. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell36.x) - 5)
  333. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell36.y) - 5)
  334. case 37
  335. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell37.x) - 5)
  336. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell37.y) - 5)
  337. case 38
  338. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell38.x) - 5)
  339. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell38.y) - 5)
  340. case 39
  341. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell39.x) - 5)
  342. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell39.y) - 5)
  343. case 40
  344. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell40.x) - 5)
  345. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell40.y) - 5)
  346. case 41
  347. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell41.x) - 5)
  348. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell41.y) - 5)
  349. case 42
  350. dw_cal.object.p_sel.x = string(long(dw_cal.object.cell42.x) - 5)
  351. dw_cal.object.p_sel.y = string(long(dw_cal.object.cell42.y) - 5)
  352. end choose
  353. ii_day = integer(dw_cal.getitemstring(1,li_days))
  354. id_date_selected = date(ii_year, ii_month, ii_Day)
  355. is_old_column = 'cell' + string(li_days)
  356. Return 1
  357. end function
  358. event constructor;id_date_selected = today()
  359. end event
  360. on uo_calendar_small.create
  361. this.cb_ok=create cb_ok
  362. this.cb_exit=create cb_exit
  363. this.em_year=create em_year
  364. this.pb_ok=create pb_ok
  365. this.pb_ddlb=create pb_ddlb
  366. this.dw_cal=create dw_cal
  367. this.ddlb_month=create ddlb_month
  368. this.Control[]={this.cb_ok,&
  369. this.cb_exit,&
  370. this.em_year,&
  371. this.pb_ok,&
  372. this.pb_ddlb,&
  373. this.dw_cal,&
  374. this.ddlb_month}
  375. end on
  376. on uo_calendar_small.destroy
  377. destroy(this.cb_ok)
  378. destroy(this.cb_exit)
  379. destroy(this.em_year)
  380. destroy(this.pb_ok)
  381. destroy(this.pb_ddlb)
  382. destroy(this.dw_cal)
  383. destroy(this.ddlb_month)
  384. end on
  385. type cb_ok from commandbutton within uo_calendar_small
  386. integer x = 379
  387. integer y = 684
  388. integer width = 233
  389. integer height = 92
  390. integer taborder = 60
  391. integer textsize = -9
  392. integer weight = 400
  393. fontcharset fontcharset = ansi!
  394. fontpitch fontpitch = variable!
  395. fontfamily fontfamily = swiss!
  396. string facename = "Arial"
  397. string text = "确定"
  398. end type
  399. event clicked;parent.postevent('ue_close')
  400. end event
  401. type cb_exit from commandbutton within uo_calendar_small
  402. integer x = 631
  403. integer y = 684
  404. integer width = 233
  405. integer height = 92
  406. integer taborder = 50
  407. integer textsize = -9
  408. integer weight = 400
  409. fontcharset fontcharset = ansi!
  410. fontpitch fontpitch = variable!
  411. fontfamily fontfamily = swiss!
  412. string facename = "Arial"
  413. string text = "取消"
  414. end type
  415. event clicked;parent.postevent('ue_close')
  416. init_cal(today())
  417. end event
  418. type em_year from editmask within uo_calendar_small
  419. integer x = 37
  420. integer y = 24
  421. integer width = 302
  422. integer height = 84
  423. integer taborder = 20
  424. integer textsize = -9
  425. integer weight = 400
  426. fontcharset fontcharset = gb2312charset!
  427. fontpitch fontpitch = fixed!
  428. fontfamily fontfamily = modern!
  429. string facename = "新宋体"
  430. long textcolor = 16711680
  431. borderstyle borderstyle = stylelowered!
  432. string mask = "####"
  433. boolean autoskip = true
  434. boolean spin = true
  435. double increment = 1
  436. string minmax = "1900~~2999"
  437. end type
  438. event other;if (lparam = 33554433) and (em_year.text <> string(ii_year)) then
  439. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  440. end if
  441. end event
  442. type pb_ok from picturebutton within uo_calendar_small
  443. integer x = 1207
  444. integer y = 744
  445. integer width = 91
  446. integer height = 72
  447. integer taborder = 40
  448. integer textsize = -8
  449. integer weight = 400
  450. fontcharset fontcharset = ansi!
  451. fontpitch fontpitch = variable!
  452. fontfamily fontfamily = swiss!
  453. string facename = "Arial"
  454. string text = "ok"
  455. boolean default = true
  456. alignment htextalign = left!
  457. vtextalign vtextalign = vcenter!
  458. end type
  459. event clicked;
  460. parent.postevent('ue_close')
  461. end event
  462. type pb_ddlb from picturebutton within uo_calendar_small
  463. integer x = 910
  464. integer y = 744
  465. integer width = 91
  466. integer height = 80
  467. integer taborder = 50
  468. integer textsize = -8
  469. integer weight = 400
  470. fontpitch fontpitch = variable!
  471. fontfamily fontfamily = swiss!
  472. string facename = "MS Sans Serif"
  473. string picturename = "ddlb.bmp"
  474. alignment htextalign = left!
  475. end type
  476. event clicked;
  477. //Works as a toggle, if the DropDown is visible, make it invisible
  478. //otherwise make it visible
  479. date ld_date
  480. If dw_cal.visible then
  481. dw_cal.visible = FALSE
  482. else
  483. //Reset the datawindow
  484. reset(dw_cal)
  485. // If there is already a date in the edit box then make this the
  486. // current date in the calendar, otherwise use today
  487. If ii_day = 0 Then ii_day = 1
  488. ld_date = date(ii_year, ii_month, ii_day) // This line used for debugging
  489. init_cal(date(ii_year, ii_month, ii_day))
  490. dw_cal.visible = TRUE
  491. dw_cal.setfocus()
  492. End If
  493. end event
  494. type dw_cal from datawindow within uo_calendar_small
  495. event ue_dwnkey pbm_dwnkey
  496. integer width = 1385
  497. integer height = 668
  498. integer taborder = 10
  499. string dataobject = "d_calendar"
  500. borderstyle borderstyle = stylelowered!
  501. end type
  502. event ue_dwnkey;long ll_cell
  503. If keydown(keyRightArrow!) and keydown(keyControl!) then
  504. if long(ddlb_month.text) >= 12 then
  505. em_year.text = string(long(em_year.text) + 1)
  506. ddlb_month.text = '1'
  507. else
  508. ddlb_month.text = string(long(ddlb_month.text) + 1)
  509. end if
  510. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  511. return
  512. Elseif keydown(keyLeftArrow!) and keydown(keyControl!) then
  513. if long(ddlb_month.text) <= 1 then
  514. em_year.text = string(long(em_year.text) - 1)
  515. ddlb_month.text = '12'
  516. else
  517. ddlb_month.text = string(long(ddlb_month.text) - 1)
  518. end if
  519. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  520. return
  521. elseif keydown(keyupArrow!) and keydown(keyControl!) then
  522. em_year.text = string(long(em_year.text) + 1)
  523. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  524. return
  525. elseif keydown(keydownArrow!) and keydown(keyControl!) then
  526. em_year.text = string(long(em_year.text) - 1)
  527. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  528. return
  529. End If
  530. if keydown(keyupArrow!) then
  531. ll_cell = long(mid(is_old_column,5)) - 7
  532. if ll_cell > 0 then
  533. if getitemstring(1,ll_cell) <> "" then
  534. highlight_column("cell" + string(ll_cell))
  535. ii_day = integer(getitemstring(1,ll_cell))
  536. id_date_selected = date(ii_year, ii_month, ii_Day)
  537. end if
  538. end if
  539. end if
  540. if keydown(keydownArrow!) then
  541. ll_cell = long(mid(is_old_column,5)) + 7
  542. if ll_cell < 42 then
  543. if getitemstring(1,ll_cell) <> "" then
  544. highlight_column("cell" + string(ll_cell))
  545. ii_day = integer(getitemstring(1,ll_cell))
  546. id_date_selected = date(ii_year, ii_month, ii_Day)
  547. end if
  548. end if
  549. end if
  550. if keydown(keyleftArrow!) then
  551. ll_cell = long(mid(is_old_column,5)) - 1
  552. if ll_cell > 0 then
  553. if getitemstring(1,ll_cell) <> "" then
  554. highlight_column("cell" + string(ll_cell))
  555. ii_day = integer(getitemstring(1,ll_cell))
  556. id_date_selected = date(ii_year, ii_month, ii_Day)
  557. end if
  558. end if
  559. end if
  560. if keydown(keyrightArrow!) then
  561. ll_cell = long(mid(is_old_column,5)) + 1
  562. if ll_cell < 42 then
  563. if getitemstring(1,ll_cell) <> "" then
  564. highlight_column("cell" + string(ll_cell))
  565. ii_day = integer(getitemstring(1,ll_cell))
  566. id_date_selected = date(ii_year, ii_month, ii_Day)
  567. end if
  568. end if
  569. end if
  570. if keydown(keyenter!) then
  571. parent.postevent('ue_close')
  572. end if
  573. end event
  574. event clicked;String ls_clickedcolumn, ls_clickedcolumnID
  575. String ls_day, ls_return
  576. string ls_col_name
  577. //Return if click was not on a valid dwobject, depending on what was
  578. //clicked, dwo will be null or dwo.name will be "datawindow"
  579. If IsNull(dwo) Then Return
  580. If Pos(dwo.name, "cell") = 0 Then Return
  581. //Find which column was clicked on and return if it is not valid
  582. ls_clickedcolumn = dwo.name
  583. ls_clickedcolumnID = dwo.id
  584. If ls_clickedcolumn = '' Then Return
  585. //Set Day to the text of the clicked column. Return if it is an empty column
  586. ls_day = dwo.primary[1]
  587. If ls_day = "" then Return
  588. //Convert to a number and place in Instance variable
  589. ii_day = Integer(ls_day)
  590. //If the highlight was on a previous column (is_old_column <> '')
  591. //set the border of the old column back to normal
  592. unhighlight_column (is_old_column)
  593. //Highlight chosen day/column
  594. dw_cal.object.p_sel.x = string(long(dwo.x) - 5)
  595. dw_cal.object.p_sel.y = string(long(dwo.y) - 5)
  596. //Set the old column for next time
  597. is_old_column = ls_clickedcolumn
  598. //Return the chosen date into the SingleLineEdit in the chosen format
  599. id_date_selected = date(ii_year, ii_month, ii_Day)
  600. ////parent.postevent('ue_close')
  601. end event
  602. event doubleclicked;String ls_day
  603. //Return if click was not on a valid dwobject, depending on what was
  604. //clicked, dwo will be null or dwo.name will be "datawindow"
  605. If IsNull(dwo) Then Return
  606. If Pos(dwo.name, "cell") = 0 Then Return
  607. //Set the Day to the chosen column
  608. ls_day = dwo.primary[1]
  609. if ls_day ='' then return
  610. //Return the chosen date into the SingleLineEdit in the chosen format
  611. ii_day = Integer(ls_day)
  612. id_date_selected = date(ii_year, ii_month, ii_Day)
  613. set_date (id_date_selected)
  614. parent.postevent('ue_close')
  615. end event
  616. type ddlb_month from dropdownlistbox within uo_calendar_small
  617. event mousemove pbm_mousemove
  618. integer x = 443
  619. integer y = 24
  620. integer width = 229
  621. integer height = 704
  622. integer taborder = 40
  623. boolean bringtotop = true
  624. integer textsize = -9
  625. integer weight = 400
  626. fontcharset fontcharset = gb2312charset!
  627. fontpitch fontpitch = variable!
  628. string facename = "宋体"
  629. long textcolor = 16711680
  630. boolean sorted = false
  631. boolean vscrollbar = true
  632. string item[] = {"01","02","03","04","05","06","07","08","09","10","11","12"}
  633. borderstyle borderstyle = stylelowered!
  634. end type
  635. event other;//If (lparam = 33554433) And (ddlb_month.Text <> String(ii_month)) THEN
  636. // draw_month ( Integer(em_year.Text), Integer(ddlb_month.Text) )
  637. //END IF
  638. //
  639. end event
  640. event selectionchanged;
  641. //if (lparam = 33554433) and (ddlb_month.text <> string(ii_month)) then
  642. //draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  643. //end if
  644. if(ddlb_month.text <> string(ii_month)) then
  645. draw_month ( integer(em_year.text), integer(ddlb_month.text) )
  646. end if
  647. end event