[wx-dev] [wxMac] Sizers and wxFRAME_SHAPED

Stefan Csomor csomor at advancedconcepts.ch
Wed Jul 30 00:36:09 PDT 2008


Hi Jorge

I see that there is a problem with sizers and shaped window, but I'm not
sure where to draw the line, if it is shaped then it needs a shape for
setting its outer size, there isn't a way like SetSize to do this, I could
just add an assert to a shaped frame if one tries to do it, this is
undefined behaviour (the shaped code btw isn't from me, but that's the way
it is set up to work).

Thus a layout in the way that a Fit or something on the outer toplevel
window can work is not possible, automatically rescaling the shape isn't the
appropriate solution either, as often the shape itself come from an image,
so the redraw would be incorrect. The driving force comes from the shape not
from something on the wxFrame.

So could you produce a simple snippet which should work under these premises
and still doesn't, so that we can look at how to tackle this ..

Thanks,

stefan




On 30.07.08 01:41, "David Jorge" <djorgepbl at gmail.com> wrote:

> Hi Stefan,
> 
> this code was just for testing purpose. My real code uses a SetShape
> (which works fine in windows and linux) after setting up the Frame.
> 
> My wxFrame has a top level wxPanel with a sizer and i don't know the
> exact width or height of the wxFrame, therefore i need to use
> GetBestSize() / GetMinSize() to know which size i must set in
> SetShape() for the region. This frame is being constructed with
> wxDefaultSize (width: 400, height 250)  and somehow wxWidget is
> summing these values to whatever value i set it with SetSize(...).
> 
> If i do SetSize(30,30), my frame will have a size of width=400+30 and
> height=250+30 (I found this after hours of debugging). Now i have a
> workaround  that is construct the frame with wxSize(1,1) instead of
> wxDefaultSize and remove this extra pixel afterwards. Its kinda ulgy
> but it works perfectly.
> 
> This litle example was just to find if the problem was mine or from
> wxWidget. Even the sample with SetShape() that comes with wxWidget has
> a problem with the sizers!!
> 
> Stefan, do you still think this isn't a bug?
> 
> On 2008/07/29, at 19:44, Stefan Csomor wrote:
> 
>> Hi David
>> 
>> if you have a wxFRAME_SHAPED window then you always have to set a
>> new Shape
>> using SetShape, you cannot resize the window otherwise on mac
>> 
>> Best,
>> 
>> Stefan
>> 
>> 
>> On 29.07.08 16:43, "David Jorge" <djorgepbl at gmail.com> wrote:
>> 
>>> Hi,
>>> 
>>> I'm trying to fix wxWidget behavior when using the frame style
>>> wxFRAME_SHAPED and have been debuging it but i've reach i dead end.
>>> 
>>> This code creates My frame with style wxFRAME_SHAPED:
>>> 
>>> ShapedFrame::ShapedFrame()
>>> : wxFrame((wxFrame *)NULL, wxID_ANY, wxEmptyString,
>>> wxDefaultPosition, wxDefaultSize,
>>>  wxFRAME_SHAPED |
>>> wxSIMPLE_BORDER
>>> | wxFRAME_NO_TASKBAR
>>> | wxSTAY_ON_TOP
>>> )
>>> {
>>>     m_hasShape = false;
>>> 
>>> mainPanel = new wxPanel(this);
>>> mainPanel->SetMinSize(wxSize(30,30));
>>> wxBoxSizer *frameSizer = new wxBoxSizer(wxVERTICAL);
>>> frameSizer->Add(mainPanel, wxSizerFlags(1).Expand());
>>> wxFrame::SetSize(wxSize(30, 30));
>>> }
>>> 
>>> 
>>> 
>>> When SetSize(wxSize(30, 30)) is executed:
>>> 
>>> calls
>>> 
>>> wxWindowMac::DoSetSize(int x, int y, int width, int height, int
>>> sizeFlags)
>>>   which internally calls DoMoveWindow( x, y, width, height );
>>> 
>>> DoMoveWindow calls:
>>> 
>>> void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int
>>> height)
>>> {
>>>     m_cachedClippedRectValid = false ;
>>> printf("Bounds: y: %d, x: %d, height: %d, width: %d
>>> \n",y,x,height,width);
>>> printf("------\n");
>>>     Rect bounds = { y , x , y + height, x + width} ;
>>> 
>>>     verify_noerr(SetWindowBounds( (WindowRef) m_macWindow,
>>> kWindowStructureRgn , &bounds )) ;
>>> printf("Bounds: y: %d, x: %d, height: %d, width: %d
>>> \n",y,x,height,width);
>>>     wxWindowMac::MacSuperChangedPosition() ; // like this only
>>> children will be notified
>>> }
>>> 
>>> Now, when the method SetWindowBounds() is called inside
>>> DoMoveWindow(...), a weird thing happens with the dimensions of the
>>> sizer which becomes a number which ha snothing to do with the given
>>> size.
>>> 
>>> This is the output:
>>> wxWidgets 2.8.8
>>> ##################################    1, hasflag
>>> ##################################    3
>>> (gdb) continue
>>> Current language:  auto; currently c++
>>> ---------HasFlag(wxFRAME_SHAPED)------
>>> ##################################    w: 400, h:250
>>> (gdb) continue
>>> -----------DoSetSize------------------------
>>> x: -1,y: -1, width: 30, height: 30
>>> currentW: 400,currentH: 250
>>> !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)x == wxDefaultCoord
>>> x = 0
>>> y == wxDefaultCoord
>>> y = 22
>>> Bounds: y: 22, x: 0, height: 30, width: 30
>>> ------
>>> -----------DoSetSize------------------------
>>> x: 0,y: 0, width: 430, height: 280   <------ It should be 30,30
>>> currentW: 0,currentH: 0
>>> 
>>> 
>>> I noticed that for some reason  when the line
>>> "verify_noerr(SetWindowBounds( (WindowRef) m_macWindow,
>>> kWindowStructureRgn , &bounds )) ;" is executed, DoSetSize is execute
>>> again, BUT now with the wrong width and Height.
>>> 
>>> Plz, help!!
>>> David
>>> _______________________________________________
>>> wx-dev mailing list
>>> wx-dev at lists.wxwidgets.org
>>> http://lists.wxwidgets.org/mailman/listinfo/wx-dev
>> 
>> -- 
>> 
>> Advanced Concepts AG
>> Software-Engineering
>> Heldweg 10
>> CH-8475 Ossingen
>> Switzerland
>> 
>> phone:+41 52 245 0 245
>> fax:+41 52 245 0 246
>> http://www.advanced.ch
>> mailto:csomor at advanced.ch
>> 
>> 
>> 
>> 
>> _______________________________________________
>> wx-dev mailing list
>> wx-dev at lists.wxwidgets.org
>> http://lists.wxwidgets.org/mailman/listinfo/wx-dev
> 
> _______________________________________________
> wx-dev mailing list
> wx-dev at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-dev

-- 

Advanced Concepts AG
Software-Engineering
Heldweg 10   
CH-8475 Ossingen
Switzerland

phone:+41 52 245 0 245
fax:+41 52 245 0 246
http://www.advanced.ch
mailto:csomor at advanced.ch






More information about the wx-dev mailing list