Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

Calendar style

 [1/2] from: mario:cassani:icl at: 19-Nov-2001 12:34

Hi all, during the making of a GUI I needed a calendar style for my layout so I used Allen's nice calendar.r code. My code seeks for some daily index putting an oval around the days when the index is found. Later the GUI is shown and, when I click on a day it is highlighted with a cross and the date is stored. Doing this the cross is removed from the previuosly clicked day (if any). The problem is that all the days with an oval are crossed by the click! I'm not a /View GUY ;P so I need some help to understand if it's wrong the way I use calendar/add-effect or if the calendar.r script is somehow buggy... Thank you for any help/suggestion Mario Snipplets of my code follow (watch line wraps): 8<---------------------------------------------------------- ; *** Open Calendar Style ; ======================== do %calendar.r ; Can be found on Rebolforces Rebsite ; *** The index seeking function (simplified, no cycles to look for the index) ; ============================================================================ index-seek: func [ todopath-base index-date ] [ index-year-end: index-date/year index-month-end: index-date/month index-day-end: index-date/day if exists? index-path: join todopath-base ["/" index-year "/" index-month "/" index-day "/index-todo.txt"] [ append date-data to-date rejoin [index-year "-" index-month "-" index-day] append/only date-data [oval] ] ] ; *** MAIN *** ; ************************ ; todopath-base and index-date are initialised ; ************************ index-seek todopath-base index-date ; ************************ ; In the main layout the following code appears ; ************************ styles calendars c: calendar with [show-navbar?: true] [ if c/effect? current-index-date 'cross [ c/remove-effect current-index-date 'cross ] ; ************************ ; do something changing 'current-index-date ; ************************ c/add-effect current-index-date 'cross ] date current-index-date data date-data 8<----------------------------------------------------------

 [2/2] from: allenk::powerup::com::au at: 20-Nov-2001 15:01

Hi Mario, Let me see if can understand what you are trying to do. I've worked from the following assumptions. 1. You build a list of acceptable dates marked with ovals, which you are doing by building a data block like date-data. 2. A user can only select one of the Oval dates? Any other crossed date is uncrossed 3. To save the state of the calendar, you will just save the contents of face/data. OK make the following changes. Find the line. f/parent-face/action none none none and change it too f/parent-face/action f/parent-face none none That just updates the code so we can use face inside the action block instead of having to using a word refering to the calendar (it did use c). Brings into line with current VID methods. Then replace the layout and example part of the script with this.. ;---Example ;dates and the display effects for those dates ; acceptable effects [cross bold italic underline oval 100.100.100] ; A PIM display could be created using this simple data struture date-data: reduce [ 13-11-2001 [oval cross] 2-11-2001 [oval] 10-11-2001 [oval] 23-12-2001 [oval] 2-12-2001 [oval] 4-12-2001 [oval] 1-12-2001 [oval] ] main-face: layout [ styles calendars calendar with [show-navbar?: true] [ if all [face/effect? face/date 'oval not face/effect? face/date 'cross] [ face/add-effect face/date 'cross foreach [date effects] face/data [ if (date <> face/date) [face/remove-effect date 'cross] ] ] ] data date-data ] ;-------------------------- So how does it work? Basically it adds and removes effects on dates in the data block based on the rules we have set. If the date clicked has the oval effect and isn't currently crossed, then we add the cross for the clicked date and remove the cross from any other date in the calendar's data block. Hope this helps. Cheers, Allen K