home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / e / EasyGUI_v33b2.lha / Src / Plugins / calendar.e < prev    next >
Text File  |  1997-02-02  |  2KB  |  69 lines

  1. OPT MODULE
  2.  
  3. MODULE 'tools/EasyGUI', 'tools/textlen',
  4.        'intuition/intuition', 'intuition/gadgetclass',
  5.        'gadgets/calendar', 'graphics/text',
  6.        'utility/date'
  7.  
  8. EXPORT OBJECT calendar OF plugin
  9.   date:PTR TO clockdata
  10.   disabled
  11. PRIVATE
  12.   calendar:PTR TO gadget
  13.   calendarbase
  14.   resize
  15. ENDOBJECT
  16.  
  17. PROC calendar(date,resizex=FALSE,resizey=FALSE,disabled=FALSE) OF calendar
  18.   self.calendarbase:=OpenLibrary('gadgets/calendar.gadget',37)
  19.   IF self.calendarbase=NIL THEN Raise("cal")
  20.   self.date:=date
  21.   self.resize:=(IF resizex THEN RESIZEX ELSE 0) OR
  22.                (IF resizey THEN RESIZEY ELSE 0)
  23.   self.disabled:=disabled
  24. ENDPROC
  25.  
  26. PROC end() OF calendar
  27.   IF self.calendarbase THEN CloseLibrary(self.calendarbase)
  28. ENDPROC
  29.  
  30. PROC min_size(ta,fh) OF calendar IS textlen('Wed',ta)+2*7,fh*7+13
  31.  
  32. PROC will_resize() OF calendar IS self.resize
  33.  
  34. PROC render(ta,x,y,xs,ys,w) OF calendar
  35.   self.calendar:=NewObjectA(NIL,'calendar.gadget',
  36.                            [GA_TOP,y, GA_LEFT,x, GA_WIDTH,xs, GA_HEIGHT,ys,
  37.                             GA_TEXTATTR,ta, GA_RELVERIFY,TRUE,
  38.                             GA_DISABLED,self.disabled,
  39.                             CALENDAR_CLOCKDATA,self.date, NIL])
  40.   IF self.calendar=NIL THEN Raise("cal")
  41.   AddGList(w,self.calendar,-1,1,NIL)
  42.   RefreshGList(self.calendar,w,NIL,1)
  43. ENDPROC
  44.  
  45. PROC clear_render(win:PTR TO window) OF calendar
  46.   IF self.calendar
  47.     RemoveGList(win,self.calendar,1)
  48.     DisposeObject(self.calendar)
  49.   ENDIF
  50. ENDPROC
  51.  
  52. PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF calendar
  53.   IF imsg.class=IDCMP_GADGETUP THEN RETURN imsg.iaddress=self.calendar
  54. ENDPROC FALSE
  55.  
  56. PROC message_action(class,qual,code,win:PTR TO window) OF calendar
  57.   self.date.mday:=code
  58. ENDPROC TRUE
  59.  
  60. PROC setdate(date=NIL) OF calendar
  61.   IF date THEN self.date:=date
  62.   SetGadgetAttrsA(self.calendar,self.gh.wnd,NIL,[CALENDAR_CLOCKDATA,self.date,NIL])
  63. ENDPROC
  64.  
  65. PROC setdisabled(disabled=TRUE) OF calendar
  66.   SetGadgetAttrsA(self.calendar,self.gh.wnd,NIL,[GA_DISABLED,disabled,NIL])
  67.   self.disabled:=disabled
  68. ENDPROC
  69.