piDogScrollingCanvas

I just wanted to let everyone know that I’ve posted piDogScrollingCanvas v1.0

I’m pretty happy with the result. I’ve optimized things pretty tightly and use all native rendering for each platform. The only place I might be able to make significant improvements would be using GL under windows. I’ll be expanding on the example list view subclass and adding more custom controls based on piDogScrollingCanvas in the future.

There are too many features/capabilities to list so please check out the demo project and docs. There is also a link to download builds of the demo project.
More Info

Great it looks good. I have two questions:

  1. Does piDogScrollingCanvas works with the MAS restritions (e.g Quicktime) ?
  2. CalendarControl: Can you add a feature to display the calendar week number with week beginns on Sunday or Monday?

Yes, Cocoa builds are sandbox friendly and only call into Cocoa.Framework

I could easily add that option to CalendarControl, it has the option internally based on the user’s language setting, but I can add a property to override it. I’ll get that posted later today.

I’ve added a StartOfWeek property to the Calendar Control. piDogCalendarControl . You can set it in the IDE or via code.

Is there any way to display the week number at the beginning of each row in the calendar view?

There is not, but you could add the week to the first day cell.

Something like this…

Function CellTextPaint(g as graphics, d As Date) As Boolean if d.DayOfWeek=me.StartOfWeek+1 then dim tSize As Integer=g.TextSize dim weekText As String="Week "+Str(d.WeekOfYear) g.TextSize=8 g.DrawString(weekText,g.Width/2-g.StringWidth(weekText)/2,g.Height-1) g.TextSize=tSize //To set the textsize back to original for drawing the day number end if End Function

Is there a way to delete an item that user select ?

I’ve added a removeItem method to the demo listView. I also changed the edititem event to selectionChanged.
I also removed a harmless but annoying breakpoint from the encrypted class…

Grab the new version here 1.0.2

The listView is pretty nice and useable.
But I cannot figure out how to draw things in the items (in the PaintDragLayer or PaintOverlayLayer). Both didn’t work for me.

I’ll be putting together a tutorial to better explain how everything works, but the basic idea is that you can treat the scrollingLayer and dragLayer as you would treat a regular canvas, but the size is not locked to the size of the control. The StaticLayer works pretty much the way a generic canvas would work, but rendered above the other layers.

You can set an area to be redrawn by calling RefreshRectScrollingLayer, RefreshRectDragLayer, or RefreshRectStaticLayer.
Then when the associated paint event (PaintScrollingLayer, PaintDragLayer or PaintOverlayLayer) fires, you can redraw the content within the area needing a redraw using the passed offsets and zoom factor.

The layers will redraw from the bottom up. For example, if you refreshed a rectangle in the scrolling layer, the PaintDragLayer and PaintOverlayLayer events will fire with the appropriate offsets to draw into the same rectangle.

The listView is at this point really just meant to be an example of how the canvas could be used. Take a look at the Paint method of the ListItem Class within the piDogSimpleListView Module. That is where the drawing happens. The ListItem class is essentially just an object that can contain data, display the data and contain instances of ListItem.

@jim mckay
Firstly, this control is great. One question, what’s the best way to save the entire piDogScrollingCanvas as a JPEG or PNG? I’m basically using it as a simple way to resize a photo (ScrollingLayer Picture) and then add labels (custom drawn arrows, on the DraggableLayer).

Also, is it possible to stop the user from zooming out too far? Currently, there doesn’t seem to be an elegant way to stop zooming out when the entire image is visible on the screen (normal expected behaviour).

[quote=87921:@Garry Pettet]Also, is it possible to stop the user from zooming out too far? Currently, there doesn’t seem to be an elegant way to stop zooming out when the entire image is visible on the screen (normal expected behaviour).

[/quote]
You could add an event handler for the Magnify Event (I’m assuming this is under OSX with trackpad zooming)

[code]Function Magnify(Zoom As Double,x as Double,y as double) As boolean
dim minZoom As Double= min(me.width/me.ScrollingLayerWidth,me.Height/me.ScrollingLayerHeight)
dim newZoom As Double=me.Zoom+Zoom

if newZoom<minZoom then
me.Zoom=minZoom
Return true
end if
End Function

[/code]

Although I think the Zoom parameter should probably be the value that zoom will be after the event fires… currently it is essentially the zoomDelta value.

It would seem I aught to add a couple of methods… DrawInto, DrawScrollingLayerInto, DrawOverlayLayerInto etc…

That would be very useful.