Re: Why does this behave the way it does?



Robert Pearce said the following at 02/28/2012 11:29 AM :

> 
> I've not looked at the internals of Gtk::Table for a while, but...
> 
> You have defined a table of 80x25 homogeneous cells in a fixed size
> window. You then populate some of the cells. Now GTK calculates the
> table size by first asking how big it wants to be, then setting it to
> the window size if possible. The size request on a table proceeds to
> ask all contained widgets how big they want to be. It then works out
> the cell sizes from which to answer the question about its size. IF
> configured for homogeneous, this algorithm is to establish the largest
> single cell size and multiply by the number of cells, in each
> dimension. You haven't populated any single cells. If you're lucky, GTK
> will figure out that the largest single cell width is one fifth of your
> five-cell-wide text entry. Then it works out the total table size.
> 

So let's make sure I understand what you're saying.

What I believe I was doing in the code:

1. I have defined a window is 640 pixels wide and 400 pixels high.
2. I have defined a table that is 80 columns wide and 25 rows high.
3. I have defined the table to have homogeneous cells.
4. I have put the table into the window, and in the process told gtkmm that
there is no padding.

At this point, I expected that each notional cell would be 8 pixels wide
and 16 pixels high.

But it sounds like you don't agree that this will be true unless I'm lucky.
Is that so?

And if that is so, how do I tell gtkmm that this is the size I require each
cell to be? (The whole point of this exercise being to get a table with
constant, predictable cell size, into which monospaced text can later be
written.)

> Now just suppose this total table size is bigger than the fixed window
> size. What does GTK do then? It can't satisfy all your stipulations. It
> MUST violate one of them. It would seem reasonable to violate the
> homogeneity.

You lost me.

I've told gtkmm how big I want the window to be (haven't I?):
   window.set_size_request(SCREEN_WIDTH, SCREEN_HEIGHT);

I've told gtkmm how big I want the table to be (haven't I?):
   Gtk::Table  table(N_ROWS, N_COLS, true);

If I then put five characters into a five-character cell, it displays
exactly as I would expect. If I also put five characters into a
twelve-character cell, exactly what stipulation is violated?

I think you are saying that somehow putting some text into the
twelve-character cell makes the total table size larger that the fixed
window size. But how can this be true? I've put only five characters into a
widget that occupies 12 cells. There is plenty of room for those characters
without increasing the width of the table (you can see that there's plenty
of space left to the right of the characters).

Hence my mystification :-(

I could understand it if I was trying to stuff too many characters into the
second widget. That would cause the second widget to expand to accommodate
the text. And that in turn (because the cells are homogeneous) would cause
the first widget also to expand laterally. Everything would grow
proportionally in the horizontal direction. That all makes perfect sense.
But since I'm not over-filling the second widget, what causes the lateral
expansion?

Incidentally, I don't see any evidence that homogeneity has been lost
anywhere in this process. The width of the cells changes, but it looks to
me that the widths of *all* cells changes, so homogeneity seems to be
maintained.

  Doc

-- 
Web:  http://www.sff.net/people/N7DR

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]