Positioning widgets

77 views
Skip to first unread message

zam...@gmail.com

unread,
Jul 19, 2012, 4:06:16 AM7/19/12
to google-we...@googlegroups.com
Hi All,

I would like to use this layout in my gwt app:

The main window has a VerticalPanel, the first element of  this VP is a TabPanel and the second is a status panel.  
1. I need to force the status panel to the bottom of screen. Could I do it with something? Maybe with a css?
I tried to use DockPanel, but I don't need north panel and it seems to be it can't be 0px height if it is empty:(

2. I need to know the size of free area inside the tabpanel. How can I get it? I tried with:
the screen size is:  $wnd.innerWidth; (JSNI)
getting tabpanel.tabbar size with tabpanel.getTabBar().getOffsetHeight()
the statusPanel size with statuspanel.getOffsetWidth()

the free space size should be:
screen size-statuspanel size-tabbar size;

It seems to be good in Opera browser, but cannot works exactly in FF and Chrome. 

Is there any other settings to getting exact size of free area? 

thx a lot
Zamek

Ümit Seren

unread,
Jul 19, 2012, 9:59:30 AM7/19/12
to google-we...@googlegroups.com
1.) For these kind of layouts I would always use the LayoutPanels. Instead of a DockLayoutPanel you can use a LayoutPanel. Something along these lines:

<g:LayoutPanel>
<g:layer left="0" right="0" top="0" bottom="15px">
    <!-- Main Window content !-->
</g:layer>
<g:layer left="0" right="0" top="15px" bottom="0">
   <!-- Status bar -->
</g:layer>
</g:LayoutPanel>

This will create a 15px status bar at the bottom and the rest will be filled by the main content window.
The advantage of using LayoutPanels is that when you resize the browser it will call onResize on the child widgets (provided they implement the RequiresResize interface). 

2.) Usually you can use getOffsetHeight() and getOffsetWidth() on the container widget to get the available dimensions. However you might have to defer the call with scheduleDeferred() until the end of the event loop because if you call the function to early (before all widgets are attached and the layout is done) it will return 0. 

zam...@gmail.com

unread,
Jul 20, 2012, 4:35:09 AM7/20/12
to google-we...@googlegroups.com
Hello,

It seems to be good! Thx a lot :)

thx
Zamek

Reply all
Reply to author
Forward
0 new messages