Hi Shaselai,
Assuming your goal is to fix the size of the AbsolutePanel, you could
try replacing HorizontalSplitPanel with HorizontalPanel. Then:
absolutePanel.setSize("x_px", "y_px"); // you could derive these
values from Window.getClientWidth() etc
// add your VSP and AP to the HP
horizontalPanel.setCellWidth(absolutePanel,
absolutePanel.getOffsetwidth());
horizontalPanel.setCellHeight(absolutePanel,
absolutePanel.getOffsetheight();
horizontalPanel.setCellWidth(verticalSplitPanel,"100%");
You may find you need to size the height of the HorizontalPanel itself
explicitly to make this work properly - I don't know because I've
never used an AP in this way before.
To create a gap between the VSP and the AP, the simplest way is
horizontalPanel.setspacing("x_px"). Alternatively introduce a third
cell (e.g. a SimplePanel), set it's height to 100% and it's width to
how many pixels you want, and decorate it how you wish.
So far this will fix the size of the AbsolutePanel and leave the
VerticalSplitPanel to fill up any remaining width. I suspect this may
not be what you want, perhaps because the VSP contains lists of items
you want to drag into the AP, and you would rather the VSP had a fixed
width, and the AP fill out the remaining client area. You could
achieve this by getting hold of Window.getClientWidth() and setting
the width of the AP relative to that. This would have the effect of
fixing the width of the VSP. However you will still have a problem if
the user resizes their browser.
To get round this I would suggest looking at a couple of
possibilities:
1. HorizontalSplitPanel is (or was, it's recently changed) difficult
to extend, but HorizontalPanel is not. Therefore you could hook it up
to a WindowResizeListener (or have it implement WindowResizeListener
itself) from which you could resize the AP and it's children. Or you
could use a Composite containing the HP to do the same thing The
javadoc for AP puts it like this:
"An absolute panel positions all of its children absolutely, allowing
them to overlap.Note that this panel will not automatically resize
itself to allow enough room for its absolutely-positioned children. It
must be explicitly sized in order to make room for them.Once a widget
has been added to an absolute panel, the panel effectively "owns" the
positioning of the widget. Any existing positioning attributes on the
widget may be modified by the panel."
So I think the problem with an AP in an HSP is that AP does not
respond to resizing of its parent, but clearly you can resize it
explicitly youself. Of course the width of the VSP will still be fixed
and you may not really want that, you really want an HSP....
2. The problem with HSP is that it does not fire an event when the
splitter is moved, and I recall that a year ago tried to extend it to
add such an event, but found I couldn't (without copying the code
itself) because the critical methods where private (i.e. access to the
splitter element was private). I see there is now a protected method
Element getSplitElement() so you could extend HorizontalSplitPanel to
implement the MouseListener interface (or override
onBrowserEvent(Event event)). Because you can now get hold of the
splitter element (you couldn't before) you can check if a mouse down
event occurs on the splitter and pick up it's new location on mouse up
in the same way that HSP does internally. Basically crib the HSP code
and make sure you don't consume the event, i.e. pass it on to the
underlying HSP superclass, and use a DeferredCommand to delay resizing
your AP until HSP has finished it's own work. You should be able to
read the new splitter positions to work out your resizing numbers for
the AP.
Note the splitter position does not change if the browser window
itself is resized, so if you hook up your extended HSP (per option 2)
to a WindowResizeListener you can again access the splitter position
to calculate redraw sizes of the AP in the event the use changes the
browser window after the HSP has resized itself. Again you probably
have to use a DeferredCommand so you don't do it until the HSP has
itself finished.
regards
gregor
On Oct 22, 4:42 pm, shaselai <[EMAIL PROTECTED]> wrote:
> How do I do that? Right now the setup is like:
> Class DragGUI extends VerticalPanel{
> HorizontalSplitPane.addRightWidget(AbsolutePanel);
> VerticalSplitPane.addTopWidget(topVerticalPanel);
> VerticalSplitPane.addBottomWidget(bottomVerticalPanel);
> HorizontalSplitPane.addLeftWidget(VerticalSplitPane);
>
> }
>
> On Oct 21, 12:47 pm, gregor <[EMAIL PROTECTED]> wrote:
>
> > Don't think so. Could you use a plain HorizontalPanel with maybe three
> > cells if you want some decoration to saplit left and right?
>
> > On Oct 21, 3:29 pm, shaselai <[EMAIL PROTECTED]> wrote:
>
> > > gregor,
> > > is there a way to force the splitpane not draggable? i didnt really
> > > see it in the api and if there is a way to do that it would be great
> > > too!
> > > thanks!
>
> > > On Oct 20, 3:19 pm, gregor <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Shaselai,
>
> > > > I was half worried you would say "AbsolutePanel". If you use one, all
> > > > bets are off as to how it works in resizing situations - it's
> > > > basically up to you - I'm not competent to advise you how to best
> > > > proceed.
>
> > > > As I understand it, AbsolutePanel works fixed pixel by pixel over the
> > > > browsers current window area, so if you move the panel itself (e.g.
> > > > by moving the HSP splitter for example) anything you previously put
> > > > into it will think it was where it was before you moved it, so to
> > > > speak.
>
> > > > I think working with D&D and AP's, you can't expect HSP to work
> > > > properly, but I may be wrong. There may be a way to move the whole
> > > > shooting match, but most cool examples of AP stuff I've seen have
> > > > always been in a fixed position.
>
> > > > No help I'm afraid
> > > > gregor
>
> > > > On Oct 20, 7:47 pm, shaselai <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi gregor,
>
> > > > > On my right side is an Absolutepanel. The API says it doesnt resize
> > > > > automatically and I am using that panel for drag and drop which
> > > > > requires an Absolutepanel so I don't think i can change that panel.
> > > > > Now I tried putting the absolutepanel inside a verticalpanel instead.
> > > > > What happens now is the absolutepanel need to be resized to 100%,100%
> > > > > so it can fit inside the vertical panel. However, when i start drag
> > > > > objects inside the absolutepanel/verticalpanel the verticalpanel's
> > > > > scrollbar keeps extending in the X direction when there's more than
> > > > > enough space. So if i drag a widget over it may have a huge width and
> > > > > same height... kind of annoying especially it happens everytime i
> > > > > drag. Do you know why this is happening? Also, is there a way to
> > > > > listen to the HSP so when the user moves it i can dynamically change
> > > > > the size of the absolutepanel so objects dont get squished? Or perhaps
> > > > > there is a way to make the HSP non-draggable so i dont need to worry
> > > > > about?
>
> > > > > thanks!
>
> > > > > AbsolutePanel dragPane;
> > > > > VerticalPanel dragContainer;
> > > > > dragPane.setSize("100%","100%")
> > > > > dragContainer.setSize("100%","100%")
> > > > > dragContainer.add(dragPanel);
>
> > > > > On Oct 20, 2:03 pm, gregor <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi Shaselai,
>
> > > > > > HSP can be complex in this respect - more details required for
> > > > > > pinpoint assistance.
>
> > > > > > However in general:
>
> > > > > > - Use a container panel (maybe Composite?) for your RHS and set it's
> > > > > > size to (100%,100%)
> > > > > > - Place your RHS widgets in this container and size them in relation
> > > > > > to it %-wise.
> > > > > > - then leave the HSP to deal with overall sizing itself - don't get
> > > > > > involved with managing this yourself
>
> > > > > > This works pretty much OK for horizontal sizing, but maybe won't for
> > > > > > vertical sizing. HSP has an inbuilt ScrollPanel that will stretch
> > > > > > the
> > > > > > display downward (i.e. document-style) if required. Repost details
> > > > > > if
> > > > > > you have a problem with this.
>
> > > > > > regards
> > > > > > gregor
>
> > > > > > On Oct 20, 5:36 pm, shaselai <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I am using a horizontalsplitpanel. I divided into 2 halves and the
> > > > > > > right half has widgets in it. The problem arrives when I move the
> > > > > > > split panel around by dragging the "dot" left and right. The
> > > > > > > widgets
> > > > > > > on the right side appears to be "out of the panel" when i drag
> > > > > > > the bar
> > > > > > > too much to the right. How do i listen to the drag so that when it
> > > > > > > does happen i can increase the panel size on the right so widgets
> > > > > > > dont
> > > > > > > "disappear"? thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---