1. Pixel graphics text alignment

--part1_d94ff0a7.24b11055_boundary

  How do I align text in pixel graphics mode?  What I've been doing for the
past month (which is the source of all my questions) is working on a
sophisticated college football coaching game.  Right now I'm using win32lib
to work on the interface.  What I want to do is make a roster window that
will add each player as an entry in a List.  Each player has a jersey number,
class (Fr, So ...) and various attributes like speed, hitting, etc etc.  The
reason I'm using a listbox is so you can click on the player, then click on
certain buttons like 'cut', 'move up', 'move down', open a stats window, and
so on.
  I could achieve alignment if I use Courier New, since all characters are a
uniform size, but that's what I'm trying to avoid.  Does anyone have an idea?
  I attached an example roster, which is aligned b/c it's in text mode.  I
want to try to get it looking exactly like that, but in Listboxes.  Or, is
there some other medium besides Lists that will do the trick?

Thanks in advance,
Derek Brown

--part1_d94ff0a7.24b11055_boundary
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="ROSTER.TXT"

Offensive Players
                  SPD HIT PAS AWA RUS REC BLO
QB   2  Bryant     50  17  93  84  15  32  13 =20
QB   4  Alston     57  18  87  85  17  29  33 =20
QB  11  Springer   43  19  81  84  41  38  23 =20
T   59  Leavitt    23  90  13  11  13  13  86 =20
T   64  Byars      18  87  12  14  10  15  84 =20
T   71  House      19  71  15  15  15  11  93 =20
T   77  McKellar   12  81  15  14  11  10  84 =20
T   65  Jennings   16  80  11  13  13  12  84 =20
T   50  Bass       20  90  11  12  12  13  73 =20
G   61  Blackwell  20  81  12  14  10  11  94 =20
G   66  Shumate    26  78  11  12  11  15  90 =20
G   76  Amey       31  76  14  10  15  15  83 =20
G   79  Royals     21  87  14  12  14  11  72 =20
G   73  Dreyfus    34  71  15  10  12  15  81 =20
G   78  Ritter     21  71  10  15  10  14  79 =20
C   57  Lowry      21  84  10  13  15  15  82 =20
C   67  Nelson     24  71  14  11  15  13  83 =20
C   63  Rivers     28  71  12  14  13  15  81 =20
FB  16  Freeman    42  43  11  28  70  46  64 =20
FB  49  Mack       51  65  12  19  65  28  45 =20
FB   8  Gilbert    40  47  16  18  60  48  52 =20
TB  40  Kirby      92  40  26  28  84  63  36 =20
TB  37  Spencer    90  40  19  17  84  39  35 =20
TB   6  Conley     88  37  28  16  77  28  26 =20
TE  18  Martin     61  69  14  11  17  60  52 =20
TE  87  Hedrick    53  67  10  12  17  50  55 =20
TE  26  Christian  55  67  11  14  30  52  52 =20
WR  85  Powell     86  15  14  17  13  93  21 =20
WR  81  Nixon      87  18  14  13  17  87  17 =20
WR  83  Stanley    82  20  14  15  29  87  25 =20
WR  27  Lim        89  17  26  26  38  81  24 =20
WR  22  Moran      88  10  17  17  26  78  25 =20
WR  84  Zimlich    81  19  12  21  10  79  12 =20

Defensive Players
                  SPD HIT TCK COV INT SBL
CB  32  Sikes      99  26  35  94  25  16 =20
CB  36  Free       84  35  31  86  62  13 =20
CB  10  Parker     90  20  20  76  14  16 =20
CB  47  Rodgers    93  32  16  71  48  14 =20
CB  23  Moser      98  16  18  65  59  19 =20
CB   9  Burge      94  15  15  66  27  18 =20
S   39  Parrish    90  33  56  65  17  12 =20
S   35  Tucker     87  29  53  68  50  16 =20
S   20  Duke       84  27  56  68  10  19 =20
S   29  Roe        81  26  55  66  56  20 =20
S   42  Tiller     78  37  49  72  59  10 =20
S   41  Owen       74  25  53  68  24  29 =20
OLB 30  Hudson     57  60  68  60  50  45 =20
OLB 12  Thompson   70  52  61  41  63  38 =20
OLB 25  Jamison    64  48  59  49  51  24 =20
OLB 45  Minor      56  43  60  58  98  38 =20
OLB 33  Paris      60  47  59  51  41  27 =20
OLB 51  Craft      68  47  53  40  58  24 =20
DE  95  Stubbs     30  75  40  21  22  89 =20
DE  74  London     28  79  52  25  26  84 =20
DE  72  Petite     20  76  60  37  27  83 =20
DE  55  Goldsmith  16  73  42  30  82  80 =20
DE  70  Erwin      27  77  47  33  86  74 =20
DE  52  Bonner     26  75  51  14  84  70 =20
DT  96  Townsend   17  95  59  11  48  88 =20
DT  56  Staley     13  95  50  13  72  86 =20
DT  98  Glaze      11  91  54  10  15  88 =20
DT  97  McIntyre   25  83  45  12  56  88 =20
DT  75  Hopkins    16  88  53  11  41  81 =20
DT  91  Rawles     23  82  58  10  73  86 =20
DT  94  Romans     12  84  45  13  12  84 =20
DT  53  Rouse      19  78  58  15  54  87 =20
DT  93  Webber     16  88  56  11  77  78 =20

Kickers and Punters
                  ACC STR
K   54  McCullugh  95  46 =20
P   13  McKellar   57  79 =20


--part1_d94ff0a7.24b11055_boundary--

new topic     » topic index » view message » categorize

2. Re: Pixel graphics text alignment

Just an idea
 You dont say how you are filling the listbox and that maybe your problem.

 It seems to me  that if you concatonate each column entry across the row
 into a string (QB )+(  2)+(  Bryant )+(    50) ,,,,, ETC
 and then install that concatonated string into the list box, for each row
 then all of the columns should line up. Changing an entry, would require
 replacing the row string.
Bernie

new topic     » goto parent     » topic index » view message » categorize

3. Re: Pixel graphics text alignment

On Sun, 04 Jul 1999, you wrote:
> >%_  How do I align text in pixel graphics mode? ......
> I could achieve alignment if I use Courier New, since all characters are a
> uniform size, but that's what I'm trying to avoid.  Does anyone have an idea?
> I attached an example roster, which is aligned b/c it's in text mode.  I
> want to try to get it looking exactly like that, but in Listboxes.  Or, is
> there some other medium besides Lists that will do the trick?

Hi:

I just encountered the same problem when working with accounting reports.
Short answer, since you're using numbers in tabular format, you have no choice
but to use a monospaced font..  What's wrong with proportional fonts?

Example: four ones    1111 pack closer together than four 0000 if you
use a proportional font.
To get the columns to allign correctly you either have to use a font where all
numerals take up the same number of pixels <--> or add blank pixels between
narrower numbers, in effect, creating your own monospaced font.

If you use proportional fonts, you have to choose between having the first
characters lining up, and the right hand side being ragged, or the right side
lining up, and the left side being "misaligned"., i.e. 100 not aligning with
111 Both approaches are unattractive. It's really a typesetting problem more
than a computer one.

Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: Pixel graphics text alignment

On Sun, 04 Jul 1999, you wrote:
> Just an idea
>  You dont say how you are filling the listbox and that maybe your problem.
>
>  It seems to me  that if you concatonate each column entry across the row
>  into a string (QB )+(  2)+(  Bryant )+(    50) ,,,,, ETC
>  and then install that concatonated string into the list box, for each row
>  then all of the columns should line up. Changing an entry, would require
>  replacing the row string.
> Bernie

Of course that would help, the easy way is to use addItem(List1,sprintf("%12s
%4d ...",...)) to format each list entry identically (filling with spaces and
justifying each entry left or right as needed).
The problem gets worse when you try to use a proportional font, because of the
fact that different letters and numbers, for example: i,1, take up a lot less
width than H,0. Therefore, different numbers of spaces need to be added to get
the next column to line up. Pascal used to have a clunky way to measure string
widths, (in pixels) so that you could add enough extra blank pixels to the
string to get your alignment back. Maybe windows API has some kind of
text-width function? (I think Jiri's font library does - but we're talking
about Windows here)

Irv

new topic     » goto parent     » topic index » view message » categorize

5. Re: Pixel graphics text alignment

Irv
 What I was thinking is that not paying any attention to what a column
 contains each concatenated piece would be the same size and that
 would align the columns, which might not be the same as sprintf function.
Bernie

new topic     » goto parent     » topic index » view message » categorize

6. Re: Pixel graphics text alignment

On Sun, 04 Jul 1999, you wrote:
> Irv
>  What I was thinking is that not paying any attention to what a column
>  contains each concatenated piece would be the same size and that
>  would align the columns, which might not be the same as sprintf function.
> Bernie

If you concatenate without "padding" the fields, then they will be different
sizes:
adam  (4 letters)
jefferson (9 letters)
so the following column won't line up
adam 123
jefferson 123

If instead you use sprintf("%-12s %3d",{name,number})
then you get
adam+8  spaces then the number
jefferson+3 spaces then the number.

That lines things up _if_ you are using a monospaced typeface.
adam         123
jefferson    123
Even this won't line the numbers up if you use a proportional font.
(They don't line up on my e-mail client, for example, because it uses a
proportional font. The two ff's take up less width than the m, for
example).

Irv

new topic     » goto parent     » topic index » view message » categorize

7. Re: Pixel graphics text alignment

Irv
Maybe you don't see what I'am getting at.
Each cell that the gliph is always so many pixels across, the kerfing
only moves the character around in that cell so wouldn't the average
misalignment be smaller because of using a smaller pieces. When your
looking at your e-mail it is being inserted into the listbox as a
continuous string. Maybe I'am wrong.
Bernie

new topic     » goto parent     » topic index » view message » categorize

8. Re: Pixel graphics text alignment

On Sun, 04 Jul 1999, you wrote:
> Irv
> Maybe you don't see what I'am getting at.
> Each cell that the gliph is always so many pixels across, the kerfing
> only moves the character around in that cell so wouldn't the average
> misalignment be smaller because of using a smaller pieces. When your
> looking at your e-mail it is being inserted into the listbox as a
> continuous string. Maybe I'am wrong.
> Bernie

Try filling a list with strings, and changing the font, you'll
see what actually happens.  There should be some kind of "tab"
setting that would line up the columns, but I don't know if Windows
implements such a thing.

Irv

new topic     » goto parent     » topic index » view message » categorize

9. Re: Pixel graphics text alignment

Derek Brown wrote:


>  How do I align text in pixel graphics mode?

There is a custom control that does this, but I haven't implemented it into
Win32Lib. I think the only common controls that got implemented were the
file open/save dialogs.

The control you have in mind is typically implemented using two Custom
Controls. The first is the List View, which allows multiple columns in a
list, including optional bitmaps. The second is the Header, which is a
horizontal window for control labels.

Past that point, I really can't help. My version of Petzold doesn't really
cover the topic that well. It's possible to emulate the control, but I'm not
sure you want to go through the trouble. If you want, I can  give you some
details, but it's a bit of work.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

10. Re: Pixel graphics text alignment

I appreciate all the help.  I finally had to resort to using courier new,
but this might be temporary as I might look into David Cuny's suggestion.

Thanks,
Derek Brown

new topic     » goto parent     » topic index » view message » categorize

11. Re: Pixel graphics text alignment

Irv
I was wrong.
I have another solution for tab problem that I am looking into if
it works I will let everyone Know.
Bernie

new topic     » goto parent     » topic index » view message » categorize

12. Re: Pixel graphics text alignment

David,

I am by no means an expert (and I use that term laughingly), but according
to the Win32API help file, it appears that setting the ListBox control
style to LBS_MULTICOLUMN (#200) and sending the LB_SETCOLUMNWIDTH (#195)
message to set the column width, it could do the trick. What do you think?


>Derek Brown wrote:
>
>
>>  How do I align text in pixel graphics mode?
>
> David Cuny wrote:
>
>There is a custom control that does this, but I haven't implemented it into
>Win32Lib. I think the only common controls that got implemented were the
>file open/save dialogs.
>
>The control you have in mind is typically implemented using two Custom
>Controls. The first is the List View, which allows multiple columns in a
>list, including optional bitmaps. The second is the Header, which is a
>horizontal window for control labels.
>
>Past that point, I really can't help. My version of Petzold doesn't really
>cover the topic that well. It's possible to emulate the control, but I'm
not
>sure you want to go through the trouble. If you want, I can  give you some
>details, but it's a bit of work.
>

new topic     » goto parent     » topic index » view message » categorize

13. Re: Pixel graphics text alignment

Gary Dumer wrote:

> it appears that setting the ListBox control style to
> LBS_MULTICOLUMN (#200) and sending the
> LB_SETCOLUMNWIDTH (#195)
> message to set the column width, it could do the trick.

No, sorry. It indeed sets up a multicolumn list, but like this:

    item1    item5
    item2    item6
    item3
    item4

Perhaps LB_SETTABSTOPS would work. I was under the impression that the
Win3.1 API supported the kind of style that's being talked about.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

14. Re: Pixel graphics text alignment

Hello,

>   How do I align text in pixel graphics mode?

I don't know if this problem has already been figured out or not but here's
my suggestion:  use a separate list box for each collumn.  I know this will
take more code just to get the lists to work together like a single box but
it could also introduce more ability than you'd have otherwise.

Just a suggestion
Lewis Townsend


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu