Martin Drautzburg wrote:
> Hello all,
> 
> I need to write an agenda  view, with a timesheet (hours/days) in the 
> background and with "items" drawn as boxes with text. I dont' quite know 
> where to start. Here are some specific questions:

I usually just start with a simple approach, and learn the right way while 
programming :)
However, I don't write 'real' GUI applications, just small simple ones, not 
much more than a canvas 
in a window.

> (1) Should I use a DrawingArea for the timesheet and draw marks for days, 
> hours and possibly some lines on it. This seems doable, but I will always 
> have to convert time-units into pixel units and back when I place anything on 
> there or when I scroll the sheet. Is there something more elegant?

I'd use a DrawingArea, but I don't know whether an existing application, or a 
custom widget exists 
for this kind of thing. I can imagine you are not the first writing this kind 
of application.
Somebody may have written a generic thingie for you. If not, you can consider 
doing that :)

Yep, you need to draw lines. Decide x pixels/hour, you know the base time, and 
you have an offset. 
Doesn't seem too difficult.

> (2) The timesheet conceptually has infinite size, but only a small part of it 
> is visible. If I scroll to the next day and I wants smooth scrolling, then 
> the next day needs to be already "there" before it is fully visible. I was 
> thinking of having a larger Pixbuf in the background which has an extra "head 

Sounds way too complicated to me.
Drawing a few lines and a few words is done faster than you can blink with your 
eyes. I would not 
worry about it until you actually have this problem.

> day" which is one day ahead of what is visible (and a tail day likewiswe). 
> Whenever I have scrolled a full day I would have to add another head day to 
> the pixbuf and I could discard a tail day. Is that the way to do it?

No idea, drawing the actual contents should be no problem. Retrieving the data 
may be, but then 
you'll have that same problem in your approach too.

> (4) How can I do the items. Visually they are just boxes with some text. I 
> assume it will be tedious to "draw" them on the drawing area, because then I 
> have to re-implement lots of stuff. What would you do?

Draw text on the drawing area :)
The classes there are pretty smart, it can render multi-line text, with a 
number of text-effects. 
Perhaps you should first investigate whether it meets your requirements.

> (5) Finally the items need to handle overlaps in a semi-clever way, to the 
> extend that overlapping items need to take only half the space (or a 
> third ...) so they can be drawn next to each other. I could probably come up 
> with some packing algorithm, but the whole problem is so close to what 
> geometry managers do out of the box, I was hoping I could achieve the same 
> thing with hboxes/vboxes and what else is out there.

hbox/vbox do not do overlapping afaik.

> 
> How would you guy approach this?

1. Try to find an existing agenda application.
2. If 1 fails, try to find an agenda application that you can extend.
3. If 2 fails, try to find an agenda widget.
4. If 3 fails, write your own.

> 
> Cheers,
> Martin
> 
> 

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to