(dc, text , maxWidth, defEllipsis="...")
| 60 | |
| 61 | |
| 62 | def GetPartialText(dc, text , maxWidth, defEllipsis="..."): |
| 63 | ellipsis = defEllipsis |
| 64 | base_w, h = dc.GetTextExtent(ellipsis) |
| 65 | |
| 66 | lenText = len(text) |
| 67 | drawntext = text |
| 68 | w, dummy = dc.GetTextExtent(text) |
| 69 | |
| 70 | while lenText > 0: |
| 71 | |
| 72 | if w + base_w <= maxWidth: |
| 73 | break |
| 74 | |
| 75 | w_c, h_c = dc.GetTextExtent(drawntext[-1]) |
| 76 | drawntext = drawntext[0:-1] |
| 77 | lenText -= 1 |
| 78 | w -= w_c |
| 79 | |
| 80 | while len(ellipsis) > 0 and w + base_w > maxWidth: |
| 81 | ellipsis = ellipsis[0:-1] |
| 82 | base_w, h = dc.GetTextExtent(ellipsis) |
| 83 | if len(text) > lenText: |
| 84 | return drawntext + ellipsis |
| 85 | else: |
| 86 | return text |
| 87 | |
| 88 | |
| 89 | def CreateDropShadowBitmap(bitmap, opacity): |
nothing calls this directly
no outgoing calls
no test coverage detected