Menu

Word Wrap wxSFTextShape

Help
iwbnwif
2013-03-24
2013-10-30
  • iwbnwif

    iwbnwif - 2013-03-24

    Is it possible to automatically word wrap in an wxSFTextShape?

    I understand that you can force multiline by inserting '\n' in the string, but I can't find a way of the text to automatically adjust to the size of the shape.

     
  • Michal Bližňák

    Unfortunately, the text cannot be wrapped automatically. If you really need this feature then, please, fill a feature request and I'll try to implement it later.

     
  • iwbnwif

    iwbnwif - 2013-03-26

    Hi, thank you for your response and for a really great framework.

    Yes, I would really like this feature - actually I have been looking at the possibilities to write it myself and submit a patch. Unfortunately I am a beginner and still getting my head around graphics contexts, device contexts and so forth.

    For my use case I only need to display the text, it will be edited elsewhere.

    Also I only plan to use the graphics context and not the old system (sorry if terminology is incorrect). This is because of the superior presentation with anti-aliasing.

    A workaround that I looked at was to use a wxLabel control but I had trouble when I tried to embed it in a rectangle. My use case basically requires to draw something like block diagrams / flow charts with descriptive text inside graphics shapes.

     
  • Michal Bližňák

    It should be possible to use wxSFControlShape to manage any GUI widget as demonstrated in relevant wxSF sample but IMHO it is not ideal solution of your problem, It would be definitely better solition to enhance functionality of wxSFTextShape. Btw, see CodeDesigner RAD (www.codedesigner.org) which is CASE tool created by using wxSF (it is open-source project) for some inspiration…

     
  • iwbnwif

    iwbnwif - 2013-03-27

    Thank you for the link to CodeDesigner. There is definitely a lot of inspiration in there and its an excellent exposition of wxWidgets.

    Slightly off topic, but I wonder why you have "Use enhanced graphics: False" as the default setting?

     
  • Michal Bližňák

    Because new drawing API (wxGraphicsContext) doesn't work well for me (it is quite slow and antialiased lines are too fat) on my notebook with really old integrated graphics chip… ;)

     
  • iwbnwif

    iwbnwif - 2013-03-28

    Thanks for pointing this out. I was previously thinking that using the native canvas would be faster than a generic one.

    I have (finally) managed to compile wxWidgets on MSW with wxUSE_GRAPHICS_CONTEXT = 1 to test this.

    Yes, on my XP SP3 Dell Mini 9 resizing shapes in wxSFDemo is noticeably slower with the graphics context enabled.

     
  • iwbnwif

    iwbnwif - 2013-08-08

    Back on topic!

    I have written a sort of wxSFAutoWrapTextShape class as a child that wraps text inside a parent wxSFRectShape, wxSFRoundRectShape or wxSFCircleShape.

    The shape classes need to be modified to skip FitToChildren (otherwise there is an argument between the shape resizing and the text resizing!)

    Would it be possible to add a style sfsNO_FIT_TO_CHILDREN so that the standard classes can be used.

     
  • Michal Bližňák

    Ok, now it is implemented in the trunk. Please, could you test it and tell me whether it works as expected?

     
  • iwbnwif

    iwbnwif - 2013-08-09

    Thanks, yes that is great!

    But damn, I just realised that I shouldn't have the style 'sfsALWAYS_INSIDE' set for the text. So probably the same result as sfsNO_FIT_TO_CHILDREN could be obtained by ensuring that none of the children have sfsALWAYS_INSIDE set.

    However I think sfsNO_FIT_TO_CHILDREN is a useful style to quickly set on and off for a shape.

     
  • iwbnwif

    iwbnwif - 2013-10-30

    The AutoWrapTextShape class is now updated so the text wraps better inside a circle or oval (similar to Visio). If anyone is interested please respond to this post but the code is a quite long because it also cache's the lines to save recalculating every time the shape is drawn or moves.

     

Log in to post a comment.