1. #1
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default [1.2.3] Can't constrain window with container

    [1.2.3] Can't constrain window with container


    Hi,

    The following code won't constrain a window within a container.
    I have seen examples using ExtJS, so either my code is wrong, there's a bug, or GXT can't do this yet.

    If there is another way to do this, please guide me in the right direction.

    Code:
        
        public void onModuleLoad()
        {
            ContentPanel center = new ContentPanel();
            center.add(new Html("Center"));
            center.setSize(400, 400);
            
            ContentPanel west = new ContentPanel();
            west.add(new Html("West"));
            west.setSize(100, 400);
            
            HorizontalPanel main = new HorizontalPanel();
            main.add(west);
            main.add(center);
            
            Window w = new Window();
            w.setSize(200, 200);
            w.setConstrain(true);
            w.setContainer(center.getElement());
            w.show();
        }
    Regards,
    The Jackal

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    The container is only for maximazing the window. Not for dragging.

  3. #3
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default


    Hi,

    I've see this done in ExtJS - for example in Saki's http://examples.extjs.eu

    The panel/window -> Simple Window/Panel auto load example the window is limited to the center panel (see pic).

    Can this be done in GXT?

    Regards,
    Carl.
    Attached Images

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    EXTJs is not exactly the same than GXT. I move this into the help forum.

  5. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    I look into adding this for the GXT2.0 release.

  6. #6
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default


    Thanks Sven.

  7. #7
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      0  

    Default


    +1

  8. #8
    Sencha User francescoNemesi's Avatar
    Join Date
    Apr 2007
    Location
    London (UK), Milan (ITA)
    Posts
    148
    Vote Rating
    0
    francescoNemesi is on a distinguished road

      0  

    Default


    I do this already with GXT 1.2.3 with the following code

    Code:
            Draggable draggable = getDraggable();
            draggable.setContainer(container);
    where container is the Component that you want to use as container.

    Hope this helps

  9. #9
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Yes draggable already has this.

  10. #10
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default


    Well those hints have a mostly working solution - I can constrain the title of the window (it's "draggable") to a container... which effectively means a window is contained in a center panel in every direction but south.

    The code I used is

    Code:
        private class ConstrainedWindow extends Window {
            private Container constrainContainer = null;
            public void setConstrainContainer(Container<Component> constrainContainer)
            {
                this.constrainContainer = constrainContainer;
            }
            
            @Override
            protected void afterRender()
            {
                super.afterRender();
                Draggable d = getDraggable();
                d.setContainer(constrainContainer);
            }
        };
    Usage:

    Code:
    ConstrainedWindow w = new ConstrainedWindow();
    w.setConstrainContainer(myContainer);