NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 75 76 77 78 79 … 93 Next »
splitting a long string into multiple strings

 
  • 0 Vote(s) - 0 Average
splitting a long string into multiple strings
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#1
2005-03-09, 01:53 AM
anyone know how to take a string that wouldnt be able to fit in a rectangle and would require an extra page and split it at the exact point where it no longer fits and then draw that string on another page?

im trying to take the actors bio and split it into multiple pages so the user can press page down/up to go through the pages. but i have no idea how to do this, anyone have experience with this, or know where i might begin?
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#2
2005-03-09, 02:19 AM
Figure out roughly how many characters can fit on the rectangle (including spaces), and then use the substring method to extract out the number of characters that you can display. Keep track of the last position you extracted from and then use that if you have even more text to display.

You'll also want to take in the variable aspect of the width being different and not always a fixed size. So if you can figure out how many characters fit in the largest rectangle, you can then use an algorithim to dynamically adjust the number of characters based on the width or height of the rectangle.

MSDN:
http://msdn.microsoft.com/library....pic.asp



jrockintuitive
Offline

Senior Member

Posts: 292
Threads: 19
Joined: Dec 2004
#3
2005-03-09, 03:31 AM
Let me provide you with another alternative.

Instead of page up and page down you can provide a scroll.

I don't know how to do this in C# (yet) but in C++ this is how I would do this:
Create an window or a bitmap to the size you want
Draw the text on the bitmap or form.
when the user scrolls up the rect.top that you use to draw the text would be a negative number. The bitmap or form never moves.

The idea here is that you draw the entire string in a box and the bitmap or form will cut the text on the top and bottom approprialtly... thus the illusion of a text box and scroll effect.

If you want me to try this in C#, let me know
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#4
2005-03-09, 04:17 AM
jrockintuitive that probably sounds like the best solution, KingArgyle its a little to much of guess work, could be errors in that, text cut off etc (i was originally going to try something like this). jrockintuitive can try and see if you can get it working in c# and let me know how you get on? thanks guys for the help.
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#5
2005-03-09, 05:03 AM
Yeah, my way is a bit more coding, but also a little more memory efficient. But since you are dealing with a graphics envirnoment anyway, Jrocks way is probably the best way to go.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#6
2005-03-09, 05:06 AM
theres just an issue with the character size, if you take the average, what if there are 50 "i"s on a line or 50 "w"'s;sure would probably never happen but:
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

see, big difference.
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#7
2005-03-09, 05:16 AM
Not if you use a Monospaced font. [Image: smile.gif]
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#8
2005-03-09, 05:17 AM
yeah i was also thinking of doing that Tongue
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#9
2005-03-09, 05:26 AM
Here is something that was done in MFC using C++ that you might be able to adapt. Again, probably more complicated then you really want so sometimes the XP (Extreme Programming) way is the way to go (the simplest method).

http://groups-beta.google.com/group....89b2065
jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#10
2005-03-09, 12:24 PM
Check out the source for the scrolling textbox widget control.  You can see how I handled the overflow of text and scrollbars, which is basically by rendering all of the text to a bitmap, and then showing only a windowed section of that bitmap in the control (window=size of control):

http://cvs.sourceforge.net/viewcvs....=markup

Which also uses the vscrollbar:

http://cvs.sourceforge.net/viewcvs....=markup

and hscrollbars:

http://cvs.sourceforge.net/viewcvs....=markup
JasonF
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (5): 1 2 3 4 5 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  is there a service?method which returns listings for multiple channels? reven 16 7,003 2022-04-11, 04:30 PM
Last Post: mandai
  Replace characters in strings bgowland 5 2,448 2013-07-06, 03:42 AM
Last Post: mvallevand
  Multiple genres in npvr.db3 bgowland 5 2,852 2013-04-16, 09:53 PM
Last Post: ACTCMS
  Multiple lists like in Search Screen cncb 7 3,280 2012-08-08, 09:11 PM
Last Post: cncb
  Multiple views for a single list imilne 18 5,514 2011-04-22, 11:06 PM
Last Post: sub
  Run Multiple File Conversions On Your 4 Core -Burn Your Processor luttrell1962 12 4,590 2010-03-25, 07:33 AM
Last Post: luttrell1962
  Multiple Instance Conversion Program luttrell1962 0 1,129 2010-02-24, 08:16 PM
Last Post: luttrell1962
  Tunging string question. whurlston 3 1,832 2009-01-02, 04:51 PM
Last Post: whurlston
  multiple instances of a plugin idkpmiller 8 2,727 2008-09-06, 01:48 AM
Last Post: psycik
  How to draw a string in PVRX2? alibert 8 2,684 2007-07-21, 04:41 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode