dynamically set size of desktop window based on content

  1. #1

    dynamically set size of desktop window based on content

    Love the desktop sample - wish there was more documentation.

    I am creating a desktop window and i want to resize it to fit the content within the window.

                
    var w = desk.createWindow({
                    icon: "Application",
                    id: myWindow,
                    title: "My Window",
                    width: 1000,
                    height: 600,
                    maximizable: true,
                    minimizable: true,
                    autoLoad: {
                        url: url,
                        mode: "iframe",
                        showMask: true,
                        maskMsg: "Loading " + url + "..."
                    }
                });
    
                w.center();
                w.show();
    this of course shows the window 1000 pixels wide (see tasks_big.gif)

    Click image for larger version. 

Name:	tasks_big.gif 
Views:	133 
Size:	93.7 KB 
ID:	3357

    I want the window to resize be just wide and high enough to fit the contents so it looks like (tasks_small.gif)

    Click image for larger version. 

Name:	tasks_small.gif 
Views:	132 
Size:	89.1 KB 
ID:	3358

    The size and number of fields in a given form is dynamic so i can't set a hard width...i want it to be liquid so it fits the contents with a certain amount of padding all the way around.
  2. #2

    solved?

    
            function resizeWindow(df) {
                var w = 0, h = 0, tw = 0;
                for (i = 0; i < df.items.length - 1; i++) {
                    var obj = df.items.get(i);
                    tw = obj.getEl().getWidth();
                    h = h + obj.getEl().getHeight();
                    if (obj.label) tw = tw + obj.label.getWidth();
                    w = tw > w ? tw : w;
                }
                top.setWindowSize(entity, id, w + 80, h + 200);
            }
  3. #3

Similar Threads

  1. Replies: 2
    Last Post: Jul 26, 2012, 2:12 AM
  2. [CLOSED] Automatic window height based on content
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 28, 2011, 3:49 PM
  3. [CLOSED] Dynamically added control and window size
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 07, 2011, 8:11 PM
  4. Replies: 0
    Last Post: Feb 22, 2010, 12:24 PM
  5. Replies: 0
    Last Post: Dec 10, 2009, 6:54 PM

Tags for this Thread

Posting Permissions