Hi.
Let use explicit minsize, maxsize for greedy elements.
Or, even explicit rastersize.

For resize, the autocorrection for childs size is possible, but cumbersone.
In attach example for busPane.ins.
In general - this is wrong way.

11/21/2014 23:01, Milind Gupta пишет:
Please help me figure out why this dialog behaves this way and what I can
do to fix it.
require("iuplua")

local busPane = {
    regDrop = iup.list{
        "ACBUS",  "ADBUS",
        DROPDOWN = "YES",
        EXPAND = "HORIZONTAL",
        VALUE = 1,
    },
    rwcheck = iup.toggle{
        TITLE = "Write"
    },
    dir = iup.text{
        MASK = ("[/I/O]"):rep(8),
        EXPAND = "HORIZONTAL",
        ACTIVE = "NO",
    },
    data = iup.text{
        MASK = ("[0-9a-fA-F]"):rep(2),
        EXPAND ="HORIZONTAL",
        ACTIVE ="NO",
    },
    ins = iup.label{
        WORDWRAP = "YES",
        ALIGNMENT = "ALEFT:ACENTER",
        EXPAND = "YES",
    },
}

busPane.vbox = iup.vbox{
    iup.hbox{
        busPane.rwcheck,
        busPane.regDrop,
        gap="2",
        margin="2x2"
    },
    --iup.hbox{
        busPane.ins,
    --},
    iup.hbox{
        iup.label{title="Direction: "},
        busPane.dir,
        gap="2",
        margin="2x2"
    },
    iup.hbox{
        iup.label{title="Data (Hex 8 bit): 0x"},
        busPane.data,
        gap="2",
        margin="2x2"
    },
    iup.fill{}
}

function busPane.rwcheck:action(state)
    if state == 1 then
        -- Checked
        busPane.dir.active = "YES"
        busPane.data.active = "YES"
    else
        -- unchecked
        busPane.dir.active = "NO"
        busPane.data.active = "NO"
    end
end

local addButton = iup.button{title="Add Before current 
Line",expand="HORIZONTAL"}
local appendbutton = iup.button{title="Append",expand="HORIZONTAL"}
local doneButton = iup.button{title = "Done",expand = "HORIZONTAL"}
local actionTabs = iup.tabs{
    busPane.vbox;
    tabtitle0="Registers",
    tabtitle1="Delay",
    tabtitle2="ACBUS/ADBUS",
    expand="YES",
}


local dlg = iup.dialog{
    iup.vbox{
        actionTabs,
        iup.hbox{
            addButton,
            appendbutton,
            doneButton,
            gap="2",
            margin="2x2",
        },
    },
    size="QUARTERxQUARTER",

    -- user function
    save_dwdh = function (this, child)
        local w0,h0 = this.RASTERSIZE:match("(%d+)x(%d+)")
        local w1,h1 = child.RASTERSIZE:match("(%d+)x(%d+)")

        this.child = child
        this.dw = w0 - w1
        this.dh = h0 - h1

        child.EXPAND = "NO"
        child.RASTERSIZE = child.RASTERSIZE
        child.MINSIZE = child.RASTERSIZE
        child.MAXSIZE = child.RASTERSIZE
        iup.Refresh(child)
    end,
    -- user function
    fix_dwdh = function (this)
        if this.child then
            local w0,h0 = this.RASTERSIZE:match("(%d+)x(%d+)")
            this.child.MINSIZE = ("%dx%d"):format(w0-this.dw, h0-this.dh)
            this.child.MAXSIZE = this.child.MINSIZE
            this.child.RASTERSIZE = this.child.MINSIZE
            iup.Refresh(this.child)
        end
    end,
    -- resize callback
    resize_cb = function (this, width, height)
        this:fix_dwdh()
    end,

}

dlg:show()

busPane.ins.title = "Enter the Direction and data. Direction is a string with 
just I or O characters standing for Input and Output respectively."
dlg:save_dwdh(busPane.ins)

-- Main IUP events loop
if (iup.MainLoopLevel()==0) then
  iup.MainLoop()
end

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to