This Question is Answered

15 "helpful" answers available (3 pts)
6 Replies Last post: Jun 20, 2008 8:14 AM by Kamal

How to approach for a google calendar's Day/week/month view kind UI application

Jun 17, 2008 5:51 AM

Click to view URPradhan's profile Level 7 URPradhan 120 posts since
Mar 6, 2008
Friends

I need to write an application similar to google calendar's day-week-month view in different tabs. For month view I'm using the Curl's calendar control by sub classing its corresponding UI class. But not able to understand how to implement the day+week view of it.

For day-week view there would be time line column at left with 1hr difference (should also be configurable with a context menu) and at right there should be corresponding dotted lines representing the time line which again should be integrated to a calendar data model to traverse with dates.

Once the user will select (by pressing mouse button and dragging) a range of time then he/she will add the event to his/her calendar. Then the event should be available as a rectangle box over time line graph with a thin header (like title bar), few details and it should be draggable and stretchable to other time lines to modify the event. you can see the application at www.google.com/calendar

Can you plz give few pointers to achieve these above tasks which is very similar to google calendar ?

//Thank you
Click to view Kamal's profile Curl Kamal 120 posts since
Oct 17, 2007
1. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 20, 2008 5:37 AM
Since you need different Views for you calendar control you may choose to have one of the following Approach.

1. Write your own calendar control UI and depending on a flag to that UI, you show the day, week, month view.
2. Better, you may have three different subclasses of the UI. You can then create 3 Calendar Control's and each one of them uses its own custom UI. Make sure that the three calendar controls use the same data model.
3. As in step 2, you may have three different UI's. However you have one CalendarControl. You can then set the UI for the CalendarControl of your choice. You can always switch a CalendarControlUI with another one.

Kindly see my response to "Regarding Calendarcontrol". Here I have shown how to write your custom UI. You will also find an example in the Curl help for StandardCalendarControlUI.create-main-panel.

Now the question is how you can write something where you can drag-select a bunch of rows, each one of them corresponding to 1 hour of th time. You may use a Canvas for this UI. This canvas you may arrange a number of Frames, each representing a row (if each row represents an hour, you will have 24 of these). You may listen for "PointerPress", "DragStarted" and PointerRelease and "GrabRelease messages.

Here is some code that shows you how you can use the above mentioned messages to identify which rows where selected. Note that this is just an example to develop your ides on.


{curl 6.0, 7.0 applet}
{curl-file-attributes character-encoding = "windows-latin-1"}
 
 
{define-class public CustomFrame {inherits Frame}
  field public constant index:int
 
  {constructor public {default index:int, ...}
    set self.index = index
    {construct-super height = .5cm, width = 1in, ...}
  }
}
 
{define-class public CustomVBox {inherits VBox}
  field private dragging?:bool
  field private start-index:int
 
  {constructor public {default ...}
    || Setting opaque-to-events? to true makes sure that this box will get the
    || pointer events, even if it has a transparent background or no border.
    {construct-super opaque-to-events? = true, ...}
  }
 
  {method private {get-cutom-frame-at x:Distance, y:Distance}:int
    def cf =
        {self.find-graphic-at
            x, y,
            {proc {g:Graphic}:bool
                {return g isa CustomFrame}
            }
        } asa #CustomFrame
    {return
        {if-non-null cf then
            cf.index
         else
            -1
        }
    }
  }
  
  {method public {on-pointer-press e:PointerPress}:void
    {if e.state-mask.button-1? then
        set self.start-index = {self.get-cutom-frame-at e.x, e.y}
        {if self.start-index != -1 then
            || Grab the pointer so that all the pointer events are sent to this
            || box. Note that since this is an implicit grab, the grab will be
            || in effect till the Pointer is released or the Grab ends because
            || of say the View to which this Box belongs looses focus.
            {e.continue-implicit-pointer-grab self}
            || Consume the event to make sure that the Boxes parent
            || does not see it. Otherwise, the grab may end for this box
            || if the parent decides to grab the pointer.
            {e.consume}
        }
    }
    {super.on-pointer-press e}
  }
  
  {method public {on-drag-started e:DragStarted}:void
    {if self.start-index != -1 then
        set self.dragging? = true
        {e.consume}
    }
    {super.on-drag-started e}
  }
 
  {method public {on-pointer-release e:PointerRelease}:void
    def dragging? = self.dragging?
    set self.dragging? = false
    {if dragging? then
        {e.consume}
        def end-index = {self.get-cutom-frame-at e.x, e.y}
        {if end-index != -1 then
            {popup-message
                "Selected from: " & self.start-index & " to: " & end-index
            }
        }
        set self.start-index = -1
    }
    
    {super.on-pointer-release e}
  }
 
  {method public {on-grab-release e:GrabRelease}:void
    set self.dragging? = false
    set self.start-index = -1
    {e.consume}
    {super.on-grab-release e}
  }
 
  {method public {add-row index:int, ...}:void
    {self.add
        {CustomFrame index, ...}
    }
  }
}
 
 
{value
    def vb = {CustomVBox}
    {vb.add-row 1, background = "lime"}
    {vb.add-row  2, background = "red"}
    {vb.add-row 3, background = "pink"}
 
    vb
}
 
 


Message was edited by: Kamal
Click to view URPradhan's profile Level 7 URPradhan 120 posts since
Mar 6, 2008
2. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 19, 2008 12:03 PM
in response to: Kamal

Thank you.

But the problem with me is that to add the events on the top of the day/week view and which can be dragged + stretched to other time lines. Any pointer for this ?

Click to view Kamal's profile Curl Kamal 120 posts since
Oct 17, 2007
3. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 20, 2008 5:30 AM
in response to: URPradhan
I will try to answer your question though I am not sure if I understand it.

In the example that I wrote, If you start dragging from one frame and the release the pointer over the same or another frame in the VBox you get a popup message telling you how many frames you have selected. If you want to show this visually, you can use the PointerMotion to detect the selection (instead of PointerRelease). You may then set a different background to the Frames that are selected and then reset it back to its original gesture if they get unselected because of the drag gesture. One getting PointerRelease you may then replace all the selected Frames with another Frame or a TextArea. The height of this object cn be easily computed and will depend on the Frames that you are replacing it with.

By the way what is a day/week view you are referring to?

I am also adding some comments in the code I wrote earlier so that you can follow it easily.

-Kamal
Click to view Duke's profile Curl Duke 129 posts since
Oct 17, 2007
4. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 20, 2008 6:12 AM
in response to: URPradhan
You might also want to look at OverlayBox as a way of putting event descriptions on top of your timeline.
Click to view URPradhan's profile Level 7 URPradhan 120 posts since
Mar 6, 2008
5. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 20, 2008 8:06 AM
in response to: Kamal
Day-week view means .. exactly the similar UI like google's calendar ( www.google.com/calendar), whcih has da+week+month views.
Click to view Kamal's profile Curl Kamal 120 posts since
Oct 17, 2007
6. Re: How to approach for a google calendar's Day/week/month view kind UI application Jun 20, 2008 8:15 AM
in response to: URPradhan
In my first response I mentioned that you have a few ways to achieve your goal. In any case you will need to write your own UI. When you write your own UI. You can use any kind of Graphics, event handling, selection to achieve that. I have shown you some code that you would need to tweak to implement your own UI. If you are asking if there is something ready made for your purpose, the answer is no.

-Kamal

Message was edited by: Kamal