Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
I have a couple of simple (hopefully) questions:
How can the size of the wxSFShapeCanvas be 'fixed'. I.e. how can I make it at least 1000 x 1000 pixels? At the moment it seems to resize to the extents of all the objects added or the window size, whichever is greater.
Is it safe to draw directly to the canvas, i.e. add lines, text etc. by overriding wxSFShapeCanvas::OnDraw or processing EVT_PAINT? I would like to add a border / title block to my drawings but don't need them to be managed by wxSFDiagramManager (but do them it to be scaled via the ScaledDC).
Thanks for helping!
More research has found the answer to question 1. To achieve a fixed canvas size, subclass wxSFShapeCanvas and override wxSFShapeCanvas::OnUpdateVirtualSize.
Ad 2: Please, could you try to use overrided wxSFShapeCanvas::DrawContent(...) virtual function and let me to know whether it worked for you? You must use the latest SVN trunk code (rev 419 or higher).
Thank you for this change, I tried it and it works!
I am sorry but my original question wasn't clear. I want to draw mostly using the normal wxShapeFramework functionality but also want to add a static border to the diagrams.
For example imagine an electrical schematic where the components are wxRectShapes etc. but around the outside is a drawing border and also there is a title block. The border and title block are static and don't need to be clickable.
What I think might be okay is below the section "// show grid" to add a call to a virtual function like "DrawStaticObjects" which can then be overridden in an application. For now I have overridden wxSFShapeCanvas::DrawContent(..) as you suggest but copy and pasted all the original code into the overide and added my border drawing bits after the grid is drawn
You don't need to copy the sources of original DrawContent() function into your custom implementation: try to use the following approach:
void MyCanvas::DrawContent(wxDC& dc, bool fromPaint)
// draw original content
// here you can place your drawing code
Of course, your drawing will appear on the top of the original content but it should be ok for your needs. If you want to draw UNDER the chart, then I have to allow user to suppress clearing of the canvas before drawing (i.e. disable solid or/and gradient fill of the canvas) - I suppose it could be implemented as a new cancas style. In this case, you could place your drawing code also before the invocation of the original DrawContent() function.
Another option is to declare new function like:
virtual void DrawBackground(wxDC &dc, bool fromPaint) and call it below the grid drawing as you suggested but IMHO the first solution is more flexible. Any thoughts?
Doh! yes of course I could have done this. For some reason I was blinkered into thinking I would have call the base class DrawContent at the end of my override.
With regards to a virtual DrawBackground, I am not sure how many people would need such a function but as well as my case it would allow a custom grid, adding a wallpaper, 'DRAFT' watermark etc.
Well maybe the answer is to have a virtual DrawBackground before the shapes are drawn and a virtual DrawForeground afterwards. Just a thought...
I have updated wxSF:
I hope the changes will match your needs.
Thank you, this is perfect!
I would like to be able to contribute something back this project, please let me know if there is any help you need.
What about to commit your AutoWrapTextShape class?.. ;) Also testing on Windows 8 would be appreciated. Moreover, if you use wxSF for any academic research/projects, you could put references to my articles dealing with wxSF into your articles if any.
I would be very happy to commit the AutoWrapTextShape but I can't work out how to do so!
At the moment I am more or less using wxWidgets etc. for my own entertainment but in the back of my mind are some more serious ideas and I will of course credit your framework if they ever come about.
You can attach the sources (e.g. in some archive) here and I will look at it and commit.
Here it is. Please bear in mind that I am very much a newbie!! At least I can tell you there are the following problems:
All comments / critics are very, very welcome as I would like to improve :)