Project

General

Profile

Actions

Bug #649

closed

Image resource not displayed when Wt::AlignTop | Wt::AlignLeft used to set position

Added by Anonymous over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
12/21/2010
Due date:
% Done:

0%

Estimated time:

Description

The following code is taken from a part of my application that arranges views in a grid using the WGridLayout and has worked perfectly until I tried to stick a server generated image into the grid (I use a custom WResource to serve up the server generated image from a WImage). The image appears as a broken link:

    int margin = GetModel()->GetMargin();
    int rows = GetModel()->GetNumRows();
    int cols = GetModel()->GetNumColumns();

    Wt::WGridLayout* layout = new Wt::WGridLayout( this );

    layout->setVerticalSpacing( margin );
    layout->setHorizontalSpacing( margin*5 );
    layout->setContentsMargins( margin, margin, margin, margin );

    setLayout( layout, Wt::AlignTop | Wt::AlignLeft );

    for ( int j = 0; j < rows; ++j )
    {
        for ( int i = 0; i < cols; ++i )
        {
            Wt::WWidget* view = GetModel()->CreateView( this, j, i ) );
            if( view )
            {
                layout->addWidget( view, j, i, Wt::AlignTop | Wt::AlignLeft );
            }
        }
    }

However, if the two occurrences of "Wt::AlignTop | Wt::AlignLeft" are commented out, the images get displayed just fine. How can changing the alignment flags break the URL of the WResource? This certainly smells like a bug... Any idea what's going on?

I'm using the git version from maybe a month ago or so.

Cheers,

Dan


Files

test133.cc (838 Bytes) test133.cc Koen Deforche, 12/21/2010 12:32 PM
Actions #1

Updated by Koen Deforche over 13 years ago

  • File test133.cc test133.cc added
  • Status changed from New to Feedback
  • Assignee set to Koen Deforche

Hey,

Weird problem indeed. I could not reproduce however, adapting your code in a simpl test-case.

Can you see if you can break the attached test case ? Would it be possible to inspect the resulting DOM using Firebug to see what values are provided for the image src and check your access log to see what the server returns for the corresponding resources ?

Regards,

koen

Actions #2

Updated by Anonymous over 13 years ago

After a bit more digging I have more information. Firstly, the URL seems fine in that the server returns a status of 200 for the image. The reason the image appears as a broken in the browser is that my code has not populated my custom resource with data - the reason for this is that I populate the resource (and mark it as changed) when the image has its size set by the layout manager (I call setLayoutSizeAware(true)).

The confusing thing is that the broken image appears to be the right size in the browser, so I think that the layout manager is doing the right thing. However, the change in size is not communicated back to the server. I'll investigate further and try to generate a test case that has this behavior - it's a bit difficult as this is the result of a number of interacting classes in my code.

Cheers,

Dan

Actions #3

Updated by Anonymous over 13 years ago

Ok, this is my mistake, not a bug! The doco for WGridLayout states, with regard to alignment:

The alignment specifies the vertical and horizontal alignment of the item. The default value 0 indicates that the item is stretched to fill the entire grid cell. The alignment can be specified as a logical combination of a horizontal alignment (Wt::AlignLeft, Wt::AlignCenter, or Wt::AlignRight) and a vertical alignment (Wt::AlignTop, Wt::AlignMiddle, or Wt::AlignBottom).

So when I used Wt::AlignTop | Wt::AlignLeft, my widgets stopped being stretched to fill the cell. Apologies for the false report.

Cheers,

Dan

Actions #4

Updated by Koen Deforche over 13 years ago

  • Status changed from Feedback to Closed

Hey Daniel,

Indeed if the layout manager is not resizing the widget, then the size is also not communicated to a layoutSizeAware widget.

Regards,

koen

Actions

Also available in: Atom PDF